Problem with AST Output for Java
See original GitHub issueThe Node Types in the AST Output for Java are not very specific. As can be seen below, “SimpleName” type is applicable for variables, methods as well as class names; which reduces its value.
Is there anything that can be done to improve upon this?
PFB the input source code I was using, for quick reference:
`public class sample_java_2{
public static void main(String[] args){
int x = 10;
int y = 15;
int z;
if (x < y) {
z = 2*x;
}
else {
z = 5*x;
}
}
}`
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Abstract Syntax Tree (AST) in Java - GeeksforGeeks
AST's are mainly used in compilers to check code for their accuracy. If the generated tree has errors, the compiler prints an error...
Read more >How to fix error while installing AST-View on Eclipse
I'm trying to install AST-view plugin on Eclipse. It visualizes the AST (abstract syntax tree) of a Java file open in the editor....
Read more >Eclipse JDT - Abstract Syntax Tree (AST) and the Java Model
The AST is a detailed tree representation of the Java source code. The AST defines an API to modify, create, read and delete...
Read more >CSE 401/M501 22sp - Project II - Parser+AST - Washington
The output of the new AST Visitor should be a readable representation of the abstract tree, not a "de-compiled" version of the program,...
Read more >ast — Abstract Syntax Trees — Python 3.11.1 documentation
Source code: Lib/ast.py The ast module helps Python applications to process ... optional in the grammar (using a question mark), the value might...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @SpirinEgor thanks for the reply. I forgot replying, the ANTLR parser has been really helpful. I couldn’t find it in the documentation, it might be a good idea to add this in there.
Hi @jsanket9578, thanks for reaching out.
You can use the type label of the parent node(s) to get context information for each SimpleName.