If you want digits to be interpreted as single tokens sometimes and as integers at others, you need to use lexical states. See the documentation and the FAQ. You can probably switch states on a {
and back on a }
. Something like this
<DEFAULT> TOKEN : {
<DIGIT : ["0"-"9"]>
}
<INBRACES> TOKEN : {
<NUMBER : (["0"-"9"])+ >
}
<*> TOKEN {
<LBRACE : "{" > : INBRACES
|
<RBRACE : "}" > : DEFAULT
|
...other rules apply in all states...
}