OK, the answer is like this :
ui: UI OBR (screen)* CBR;
screen: ....
model : MODEL modelBody;
modelBody: genericBlock; // no more BRACKETED_TEXT
genericBlock
: OBR
( TEXT
| QUOTED_TEXT
| OPAR
| CPAR
| genericBlock
)*
CBR
;
OBR: '{';
CBR: '}';
OPAR: '(';// this was part of the initial grammar file, but left out
CPAR: ')';// same here
...
TEXT : ('a'..'z'|'A'..'Z'| '_' | '-' )+ ;
Question still remains, and I hope someone can clear it. Why do I have to declare all the tokens which will not be present in the generic block ? If lexer encounters a declared TOKEN inside the genericBlock
, he fails. Why is that I specifically told it to match anything else other than OBR
and CBR
.