I am using Lexical state in JavaCC parser to switch from one state to other, after it matches Token A1.
< DEFAULT > TOKEN :
{
<A1 : "Hello"> : STATE2
| <A2 : "World">
}
< STATE2 > TOKEN :
{
<B1: "World"> : DEFAULT
}
When I try to parse Hello Wolrd, It throws Token Manager Error.
Because in STATE2 there is no rule to match any prefix of " Wolrd"
. In case you meant "Hello World"
, it is because there is no rule in STATE2 to match any prefix of " World"
.
If you want to ignore spaces, add a rule
<DEFAULT, STATE2> SKIP : { " " }