antlr4
antlr4 copied to clipboard
antlr 4.10.1 generates invalid go parser
Steps to reproduce:
alias antlr='java -jar ~/Downloads/antlr-4.10.1-complete.jar'
git clone https://github.com/ethereum/solidity solidity
cd solidity/docs/grammar
antlr -Dlanguage=Go -o parser SolidityLexer.g4 SolidityParser.g4
In the generated solidity_parser.go file, there're both func NewExpressionContext and type NewExpressionContext, which causes syntax error.
Likely a "symbol conflict" in the grammar with the target.
Likely a "symbol conflict" in the grammar with the target.
Is it possible to automatically fix this conflict for antlr?
Is it possible to automatically fix this conflict for antlr?
There's code to bypass these conflicts, but the list of conflicting symbols is hard-coded (at least I think it is).
Try renaming one symbol at a time in the grammar(s) with "expression" and see what fixes the problem. We typically use a trailing underscore character, e.g., "expression" => "expression_".
Is it possible to automatically fix this conflict for antlr?
There's code to bypass these conflicts, but the list of conflicting symbols is hard-coded (at least I think it is).
Try renaming one symbol at a time in the grammar(s) with "expression" and see what fixes the problem. We typically use a trailing underscore character, e.g., "expression" => "expression_".
Is it possible to add extra conflicting symbols from user side?
Is it possible to add extra conflicting symbols from user side?
My understanding is that it is a static list, no way to add to the list, or add a prefix or postfix string to generated names, etc. See this discussion.