Decide on the associativity of the operator. If you want the operator to have a left associativity:
void searchExp():
{}
{
relExp() ( logOp() relExp() )*
| "(" searchExp() ")"
}
If you'd like to search more for this, the problem is generally called resolving left recursion.
On Tue, Mar 24, 2009 at 10:03 AM, Bertram
<bertram@...> wrote:
Hello,
I am new to Javacc, so there might be a very obvious solution to this.
This is a left recursion problem (Left recursion detected:).
Here the 1:1 translation of the related BNF description:
void searchExp():
{}
{
relExp()
| searchExp() logOp() searchExp() // this line is the problem
| "(" searchExp() ")"
}
void logOp():
{}
{
<T_OR>
| <T_AND>
}