no compilationUnit method found in many languages' parsers
- Dominant language
- Java
- Stars
- 19k
- Forks
- 3.5k
- PR merge metrics
- No merged PRs in 30d
Description
Hi,
I'm new here and I am trying to use antlr4 for parsing some codes in my repo.
In Java or C, It works fine. I have created a listener for collecting info, such as method decl, invoke and so on.
```
Java8Parser parser = new Java8Parser(tokens);
ParseTree tree = parser.compilationUnit();
ParseTreeWalker walker = new ParseTreeWalker();
J8MethodListener listener = new J8MethodListener();
walker.walk(listener, tree);
```
But in other languages, such as go/python, I noticed that no compilationUnit method found in the parsers, which was automatically generated by g4 file.
```
GoParser parser = new GoParser(tokens);
GoMethodListener listener = new GoMethodListener();
parser. oh no
// no compilationUnit here
```
I do not know how to generate a parsetree without this method.
Thanks for your help
google mail list url: https://groups.google.com/g/antlr-discussion/c/3DSZKLBp6Qw
Contributor guide
Research direction
Start by reviewing the Java8Parser, GoParser, and Python parser entry points and the referenced ANTLR discussion thread. Determine how the grammars expose their top-level parse rules and document the correct way to build a parse tree for languages without a compilationUnit method.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, go, java, python
- Domain
- compilers
- Issue type
- Documentation
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100