我在ANTLR中编写了以下语法。我面临左递归错误,因为在下面的语法中存在间接左递归:
logicalExpression
: subSearchCondition delim (logicalOp delim subSearchCondition delim)* ;
subSearchCondition
: (NOT)? delim LPAREN delim searchCondition delim RPAREN delim
| (NOT)? delim predicate delim;
searchCondition
: logicalExpression;
在上面的语法中,logicalExpression调用了subSearchCondition,而subSearchCondition又调用了searchCondition,但是searchCondition正在调用logicalExpression,因此在logicalExpression和searchCondition之间存在间接递归。
请帮助解决此语法的左递归。请逐步解释