Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

The reason for the ANTLR4 Grammar error in not accepting a[1+2] is that the ANTLR4 grammar specifies a certain syntax and structure for the input code. If the syntax and structure of the input code do not match the grammar rules specified by ANTLR4 grammar, then an error is thrown. In this case, it is possible that the grammar rules specified by ANTLR4 do not allow arithmetic expressions inside array indexes, and so an error is thrown when the code a[1+2] is encountered.