grammars-v4 icon indicating copy to clipboard operation
grammars-v4 copied to clipboard

Aterm

Open teverett opened this issue 1 year ago • 2 comments

teverett avatar May 05 '24 21:05 teverett

@kaby76 I seem to have something not quite right in this commit. I see errors like " expected". Would you mind taking a look?

Test.java:187: error: <identifier> expected
        ParseTree tree = parser.();

teverett avatar May 05 '24 21:05 teverett

Trgen tries to find a start rule but it cannot because it is not an EOF-terminated start rule. The grammar should be augmented with a rule like start_ : term_ EOF ;. Not only does this help trgen find the start rule in the grammar but it forces the parser to read all input to the end of file instead of prematurely stopping at an error, backing up, and reporting success. For an example, see https://github.com/antlr/grammars-v4/issues/2405 and specifically the exercise of modifying the "calculator" grammar and parsing input "1 2". In other words, even if one sets the start symbol in the pom.xml, it may not always parse correctly.

kaby76 avatar May 05 '24 22:05 kaby76