|
JavaCC: Placement of token definition |
|
|
|
|
Written by Sleepy Egg
|
|
Thursday, 23 June 2005 |
|
The order of placing token definitions matters.
example:
TOKEN:
{
<AAA : "aaa">
| <MORE_A : (["a"'>)*>
}
token AAA is more specific comparing to MORE_A, so must place before MORE_A. When token manager looks for the type of a token, it will match the regular expressions (tokens) from top to bottom (or left to right).
If we don't follow this rule, u may get unexpected result.
exmple:
"aaa" will actually match MORE_A when u have AAA after MORE_A.
|