abstract-syntax-tree Questions

6

Solved

Abstract Syntax Tree.. I always heard that compile to SpiderMonkey AST on Github. So, is that a actual standard of JS syntax tree? And there's V8, is V8 using the same kind of AST? How can I play...
Bertberta asked 21/4, 2013 at 4:28

2

Solved

I'm trying to create a tiny interpreter for TI-BASIC syntax. This is a snippet of TI-BASIC I'm trying to interpret A->(2+(3*3)) I've tokenized the code above into this sequence of tokens: T...
Predicant asked 9/7, 2014 at 19:6

1

I'm tinkering with Python's ast (Abstract Syntax Trees) module. Using ast.NodeVisitor, it is possible to walk a source tree and display information such as each node's name like so: class MyAST(a...
Iminourea asked 27/5, 2019 at 9:53

15

Solved

I want to programmatically edit python source code. Basically I want to read a .py file, generate the AST, and then write back the modified python source code (i.e. another .py file). There are wa...
Oxidimetry asked 20/4, 2009 at 14:51

1

After creating a start of a function that converts the Annotation type back into a type: @typechecked def extract_type_from_annotation( *, annotation: Union[ Subscript, Index, Name, Annotation, ...
Gower asked 28/10, 2023 at 14:14

2

I have to modify around 1 000 of typescript files in a specific way: I need to replace all StringLiteral and JsxText tokens with a CallExpression to a translation function for internationalization ...

2

Consider the following struct definition in foo.cc: struct Foo { int &bar; }; Because bar has reference type, the implicit trivial default constructor Foo::Foo() is implicitly deleted. Howeve...
Kelsey asked 12/3, 2021 at 12:4

4

Solved

I am trying to read the assocated Doc comments on a struct type using Go’s parser and ast packages. In this example, the code simply uses itself as the source. package main import ( "fmt" "go/a...
Sorehead asked 25/10, 2013 at 3:41

5

Given a string: var str1 = "25*5+5*7"; Without using eval or the constructor function in JavaScript, how would I be able to write a function called "output" that takes in the string and outputs...

5

Solved

I'm trying to use syn to create an AST from a Rust file and then using quote to write it to another. However, when I write it, it puts extra spaces between everything. Note that the example below i...
Whatley asked 17/1, 2021 at 19:21

7

Solved

I have a dictionary that is stored in a db field as a string. I am trying to parse it into a dict, but json.loads gives me an error. Why does json.loads fail on this and ast.literal_eval works? Is...
Ulcerous asked 9/2, 2015 at 6:7

4

Solved

I've been searching A LOT about this and I couldn't find anything useful that REALLY helps me build an AST. I already know that ANTLR4 doesn't build AST like ANTLR3 used to do. Everyone say: "Hey, ...
Orphaorphan asked 30/4, 2015 at 14:58

2

I'd like to use JavaScript to parse an html document into an abstract syntax tree, where each node also includes start and end line numbers (and hopefully also character positions) for each node. A...
Flagrant asked 13/10, 2014 at 21:23

2

Solved

I'm looking for a Python library for parsing code into its abstract syntax tree representation. There exists a built-in module, named ast, however, it is only designed for parsing Python code...

2

Solved

I am looking for a function that converts a math string passed as an argument (with the operations +, -, /, *), that returns an object that contains pieces of the math string, in an ordered/better ...
Persis asked 24/12, 2022 at 17:1

2

Solved

With Clang we can do: clang -cc1 -ast-dump j.c TranslationUnitDecl 0x7fbcfc00f608 <<invalid sloc>> <invalid sloc> |-TypedefDecl 0x7fbcfc00fea0 <<invalid sloc>> <i...
Sac asked 18/11, 2019 at 22:45

2

Solved

I want to modify Markdown files programmatically. I have been looking into Markdown parsers and tried a few of them; namely Marked, Markdown-it and Commonmark. They give access to an AST, which all...
Curtain asked 1/6, 2021 at 23:55

1

I have an infix expression that I have tokenised and would like to proceed to create an abstract syntax tree. I understand the shunting-yard algorithm used in these cases. I have only found ways to...
Livable asked 25/1, 2014 at 21:58

8

Solved

I can get AST without comments using import ast module = ast.parse(open('/path/to/module.py').read()) Could you show an example of getting AST with preserved comments (and whitespace)?
Palmation asked 17/9, 2011 at 18:29

1

I understand eval string-to-function is impossible to use on the browsers' application programming interfaces, but there must be another strategy to use third party dependencies without node.js on ...
Jaques asked 15/5, 2022 at 14:50

1

Solved

What's the best way to get the surrounding function name from a file position via the source code alone (no runtime checks)? For example say I have some code: func MyFunc() { doSomething() // pack...
Podesta asked 14/4, 2022 at 0:5

5

Solved

I'm generating AST using clang. I've got following file (lambda.cpp) to parse: #include <iostream> void my_lambda() { auto lambda = [](auto x, auto y) {return x + y;}; std::cout << ...
Hydroponics asked 20/1, 2015 at 14:58

5

I'm trying to read in a string representation of a Tuple from a file, and add the tuple to a list. Here's the relevant code. raw_data = userfile.read().split('\n') for a in raw_data : print a b...

4

Solved

I am implementing a simple C-like language in OCaml and, as usual, AST is my intermediate code representation. As I will be doing quite some traversals on the tree, I wanted to implement a visitor ...

1

Solved

I'm hoping to use SWC in Rust to generate some TypeScript code. Unfortunately, it seems the emitter can only print JavaScript. Is this correct, or is there a way to print TypeScript? For instance, ...

© 2022 - 2024 — McMap. All rights reserved.