Syntactic errors on optional rules in Antlr 4 doesn't work as expected
问题 I am using Antlr 4.7.2. I am trying to implement an "if else" statement: Main problem is that optional rule is not being included on ParseTree, for this reason I think I am not getting the syntax's errors on that optional rule. Ones of my current grammar definition are: prog : stat+ ; stat : func_declaration #rFuncDeclStat | if_stat #rIfStat | while_stat #rWhileStat | for_stat #rForStat | 'return' expr? STAT_END #rReturnStat | LET ID ('=' expr)? STAT_END #rVarDeclStat | var_reference '=' expr