I'm having a singular issue with JavaCC at the moment. I have my grammar defined, the language is LL(1) and all Left Recursion has been removed. I'm getting a choice conflict error (dumped below). I believe it is caused by the line expr2()
line calling itself and causing a conflict. I'm honestly completely stumped. I don't even know how to go about fixing the problem.
Here's the snippet of code generating the warning:
void expr() : {}
{
<LBRAC> arg_list() <RBRAC> expression2()
}
void expr2() : {}
{
section() (<SUB>|<ADD>|<MUL>|<DIV>|<MOD> section())* expr2()
| {}
}
void section() : {}
{
<IDENTIFIER> | <TRUE> | <FALSE> | <REAL> | (<ADD> | <SUB>) section() | expr()
}
And the warning is:
Warning:
Choice conflict in (...)* construct at line 233, column 14.
Expansion nested within construct and expansion following construct
have common prefixes, one of which is: "-"
Consider using a lookahead of 2 or more for nested expansion.
Parser generated with 0 errors and 1 warnings.
Where line 233 corrisponds to first line in expr2()
@Juan Lopes wrote:
The OP replied:
@Theodore Norvell wrote: