In ANTLR, we can use syntactic predicates to solve certain issues as follows. This is just a simple example.
a : (L K)=> b
| c
;
b : L K
;
c : L M
;
What I want to know is how to achieve the same thing in JAVACC? Thanks.
There is a concept called SYNTACTIC LOOKAHEAD in javacc. You can use that to achieve same behavior.
For an example assume your grammar rule is as follows. void Expr(): {} { Call () | Var() }
If you need to do a lookahead of unknown times then you can for something like
void Expr():
{}
{
LOOKAHEAD(Call())
Call () | Var()
}
For more information please refer http://javacc.java.net/doc/lookahead.html