Im trying to remove a choice conflict from javacc grammar in LL(1) (without look ahead):
I already have grammar defined
I know I have to do some left factoring but im stumped on how to go about doing this one:
Here is some sample code:
void expression2() :{}{
fragment() (<MULT_SIGN>|<DIV_SIGN>|<MOD_SIGN> fragment())* (expression2()| {})
}
void fragment() :{}{
<ID>
|<LEFTPARENTHESES>arg_list()<RIGHTPARENTHESES>
|<TRUE>
|<FALSE>
|<NUM>
|(<PLUS_SIGN>|<MINUS_SIGN>)fragment()
}
void condition() :{}{
<NOT>expression2()|expression2()
(<EQ_SIGN>|<NOT_EQUAL_SIGN>|<LESS_THAN_SIGN>|<GREATER_THAN_SIGN>|<LESS_THAN_OR_EQUAL_SIGN>|<GREATER_THAN_OR_EQUAL_SIGN>|<AND>|<OR>)expression2()
|<ID>
}
the warning is:
Warning: Choice conflict involving two expansions at
line 226, column 20 and line 228, column 2 respectively.
A common prefix is: <ID>
Consider using a lookahead of 2 for earlier expansion.
where:
line 226, column 20 corresponds to the 2nd expression2() in condition() on the first line
line 228, column 2 corresponds to <ID>
in condition() on the last line