One example text I like to parse is like this -
@comment {
{ something }
{ something else }
}
Basically "@comment" is the key to search, after that is a pair of matching braces. I do not need to parse what is between the braces. Since this is similar to C' multi-line comment, I have my grammar based on that:
grammar tryit;
tryit : top_cmd
;
WS : ('\t' | ' ')+ {$channel = HIDDEN;};
New_Line : ('\r' | '\n')+ {$channel = HIDDEN;};
top_cmd :cmds
;
cmds
: cmd+
;
cmd
: Comment
;
Comment
: AtComment Open_Brace ( options {greedy = false; }: . )+ Close_Brace
;
AtComment
: '@comment'
;
Open_Brace
: '{'
;
Close_Brace
: '}'
;
But in testing in ANTLRWORKS, I get a EarlyExitException immediately.
Do you see what is wrong?