abstract-syntax-tree Questions

2

Solved

I am trying to understand the process by which python code gets executed. Suppose the source has a function definition. Using ast.parse(), I parse it into an ast, which will contain an instance of ...
Trevethick asked 13/2, 2018 at 5:10

1

Solved

Let's take typescript file: class A { private x? = 0; private y? = 0; f() { console.log(this.x, this.y); delete this.x; } } const a = new A(); a.f(); I'm building it in webpack using aweso...

3

Solved

I have a general idea of what an AST is, but I want to know how to construct one. If you're given a grammar and a parse tree, how do you construct the AST? How do you do it if you're given a gram...
Mauve asked 12/11, 2009 at 11:24

1

Is it possible to dump an arbitrary LibCST node into Python code? My use case is that I want to extract the code for functions that match a specific naming scheme. I can extract the FunctionDef nod...
Fiorenze asked 26/3, 2020 at 13:4

3

Solved

Let's start by considering python3.8.5's grammar, in this case I'm interested to figure out how to transpile python Comparisons to c. For the sake of simplicity, let's assume we're dealing with a v...

6

I am trying to work on a script that manipulates another script in Python, the script to be modified has structure like: class SomethingRecord(Record): description = 'This records something' aut...
Delve asked 29/9, 2016 at 20:35

1

Solved

I'm looking to make a tool which generates method stubs from some given input. I've seen the ast package, but it seems to represent an already parsed AST, which has information about where in the s...
Wilfredowilfrid asked 1/11, 2016 at 17:24

4

Solved

There are many node types to detect, ie: VariableDeclarator FunctionExpression MemberExpression AssignmentExpression The eslint website explains the rules but doesn't provide all of the availab...
Apparent asked 23/9, 2016 at 16:14

2

Solved

The following test attempts to use AST to add fields to a struct. The fields are added correctly, but the comments are added out of order. I gather the position may need to be specified manually, b...
Tehuantepec asked 25/7, 2015 at 16:25

4

Solved

Is there a way to convert a given Python abstract syntax tree (AST) to a source code? Here is a good example of how to use Python's ast module, specifically a NodeTransformer. I was looking for a ...
Intendance asked 22/9, 2010 at 22:41

3

Solved

I'm trying to generate Java source code with JDT/AST. I now have MethodDeclaration and want to add a code snippet (from another source) to the method body. The code snippet can contain any Java cod...
Herne asked 10/12, 2012 at 12:50

2

Solved

I would like to extract the comments from a typescript source file, preferably with their line numbers. I tried doing it like this: var program = ts.createProgram(files, { target: ts.ScriptTarget...

1

I'm trying to implement a tree-processing algorithm in Haskell, and (due to the fact this is my first Haskell program!), am struggling with the design of the data structures. Can any of the FP guru...
Pretext asked 14/4, 2019 at 21:18

0

I am building an application for which I would like a naive user to define a simple function. I would then like to take this function and convert it into an abstract syntax tree. This should also w...
Godless asked 22/3, 2020 at 8:37

5

Solved

I am learning on my own about writing an interpreter for a programming language, and I have read about Abstract Syntax Trees. I have an idea of what they are, but I do not see their use. Why are A...
Wat asked 5/10, 2010 at 0:38

2

Solved

I am currently generating a custom AST from a new language specification I have designed. This custom AST contains different nodes that I have designed with all the information I need in order to n...

1

Solved

I have strings, which describe mathematical formulas and I would like to convert it into lists of meaningful parts. The function ast_ does know how to parse it, to displays it as an Abstract Syntax...
Logrolling asked 5/2, 2020 at 20:27

1

clang-check -ast-dump -ast-dump-filter=<function_name> main.c gives a AST (only a function declaration) of the particular code. How can we represent generated AST in JSON format? PS: I Wan...
Pikeman asked 29/11, 2019 at 10:21

1

I clean generated .class files, and re-build my app. If the first call to generated AST constructor happens from a .java class, I get an error. But if I call a constructor generated by an @Immutabl...
Antigen asked 19/9, 2015 at 16:52

3

Solved

I often need to rename variables when refactoring code, which I currently do in a somewhat hacky way using regexs - I end up having to come with silly text workaround workarounds for the lack of ac...
Instantaneous asked 31/10, 2013 at 15:24

2

Say I have an arbitrary Coq Term (in AST format using s-expressions/sexp) for example: n = n + n and I want to automatically convert it to: = n + n n by traversing the AST tree (which is simple...
Bitten asked 20/3, 2019 at 4:55

2

Solved

I've written a VS Code extension that uses TypeScrpt AST API for organizing class members. My issue is that after running ts.transform(...) and than convert transformed syntax tree back to text all...

2

Solved

I recently saw that the go yaml lib has new version (V3) with the nodes capabilities (which in my opinion is a killer feature :) ) which can helps a lots with modifying yamls without changing the ...
Gerda asked 14/4, 2019 at 11:40

4

Solved

I am trying to get hold on Clang. So, I would like to view the AST generated by Clang after parsing the given program. Is it possible to dump AST in .dot or .viz format? Is there any tool out there...
Incentive asked 1/9, 2013 at 15:40

2

Is it possible to compile an AST to a binary in Golang? Or does the API not expose that feature. The way libraries currently do this, such as Gisp, is to print out the AST using the go/printer pack...
Gantlet asked 1/10, 2015 at 1:15

© 2022 - 2024 — McMap. All rights reserved.