antlr / grammars-v4

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

[bison] Bison grammar contains several Bison-idiomatic rules. #4312

Closed kaby76 closed 2 weeks ago

kaby76 commented 2 weeks ago

In the Bison grammar, which is derived from the Bison .y grammar and is used by Trash for conversion of Bison grammars to Antlr4, there are several rules that are non-standard Antlr4 syntax. This causes problems for any Antlr4-generated parser because of stack overflow while reading large Bison grammars, e.g., https://github.com/postgres/postgres/blob/027124a872d7b5dfddc69590af42f626b1727dba/src/backend/parser/gram.y

https://github.com/antlr/grammars-v4/blob/5ed2a3a3b9c2944a0fc60eaee26ccc1da2e7e26b/bison/BisonParser.g4#L76-L79

https://github.com/antlr/grammars-v4/blob/5ed2a3a3b9c2944a0fc60eaee26ccc1da2e7e26b/bison/BisonParser.g4#L195-L199

https://github.com/antlr/grammars-v4/blob/5ed2a3a3b9c2944a0fc60eaee26ccc1da2e7e26b/bison/BisonParser.g4#L214-L218

https://github.com/antlr/grammars-v4/blob/5ed2a3a3b9c2944a0fc60eaee26ccc1da2e7e26b/bison/BisonParser.g4#L224-L227

All these should be refactored to use the kleene *-operator instead.