antlr / grammars-v4

Grammars written for ANTLR v4; expectation that the grammars are free of actions.
MIT License
10.09k stars 3.69k forks source link

Tests with a lexer that has error channel and produces such tokens should fail #3541

Open ris58h opened 1 year ago

ris58h commented 1 year ago

Some lexers in the repo has error channel (https://github.com/search?q=repo%3Aantlr%2Fgrammars-v4+channels+%7B+ERROR+language%3AANTLR&type=code&l=ANTLR) and some of them produce such tokens in tests. For example https://github.com/ris58h/grammars-v4/blob/1966b6081dc49a24e6641259de0eaa483b8565da/javascript/javascript/examples/Generators.js#L38 where start token has ERROR channel (there are other places BTW). These test should fail.

I couldn't find a settings in https://github.com/antlr/antlr4test-maven-plugin to do it. May be we can fix it, may be it requires upstream changes.

kaby76 commented 1 year ago

To make error rules fit in the trgen tester or the old Maven tester, the easiest is to just have the error reported using an Antlr error listener NotifyErrorListeners(). It seems wrong to not report the error.