我使用ANTLR创建语法,但我得到了这个错误
error(211): [fatal] rule conditions has non-LL(*) decision due to recursive rule invocations reachable from alts 1,2. Resolve by left-factoring or using syntactic predicates or using backtrack=true option.
我的语法规则:
conditions
: '(' conditions ')'
| condition (C_BINARY_OPERATOR conditions)?
;
condition
: expression C_CONDITIONAL_OPERATOR expression
;
expression
: (term) (('+'|'-') term)*
;
term
: (factor) (('*' | '/') factor)*
;
factor
: C_ID
| C_NUMBERS
| '(' expression ')'
;
// Binary Operators for Logical Calculation
C_BINARY_OPERATOR
: '&&'
| '||'
;
// Conditonal Operators
C_CONDITIONAL_OPERATOR
: '>'
| '<'
| '=='
| '!='
| '=<'
| '=>'
;
如何修复此错误?
请参阅ANTLR网站上的此页面。它包含有关如何修复错误的信息。
好吧,错误确实显示"通过左因子分解或使用句法谓词或使用回溯=true选项来解决"。这令人困惑吗?