antlr / grammars-v4

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

[build] Add testing for grammar ambiguity. #4276

Closed kaby76 closed 1 month ago

kaby76 commented 1 month ago

I'm really excited about this one!!

This change adds testing for grammar ambiguity using trperf. The tool essentially runs the parser with the ProfilingATNSimulator. (It does not test the grammar using Z3/SMT. I am still working on that.)

The output is a little hard to read, but you can see the list of symbols that are ambiguous after all parses.

The entire list of grammars and ambiguity at this point are here: ambig.txt

Note, the actual ambiguous parse trees can be obtained using trparse --ambig, but that can take a lot of time, so it is not done.

teverett commented 1 month ago

@kaby76 thanks. This is great.