Skip to content

Java parser to generate custom AST#8

Closed
1001mei wants to merge 4 commits intomainfrom
parser
Closed

Java parser to generate custom AST#8
1001mei wants to merge 4 commits intomainfrom
parser

Conversation

@1001mei
Copy link
Contributor

@1001mei 1001mei commented Sep 26, 2023

Background

The java parser library currently being used returns a concrete syntax tree (CST). The process of converting it into an abstract syntax tree (AST) takes much effort and is complicated by the fact that it does not following Java Language Specification (JLS) faithfully. For example, the precedence of * over + in the expression 1 + 2 * 3 is not reflected in the CST output.

In an attempt to get rid of above hassles, this PR uses a parser generator pegjs to generate a Java parser that can return a custom AST. The references used are as follows:

Work Done

  • Support parsing for simple class and method declaration
  • Support parsing for arithmetic expressions
  • Write more tests to check for correctness

@1001mei
Copy link
Contributor Author

1001mei commented Oct 18, 2023

Seems like we will be continue using java-parser library, so will close this PR and parser branch will be used for my own exploration.

@1001mei 1001mei closed this Oct 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant