[antlr-interest] Exclusion rule
Liviu U
liviu.u at gmail.com
Sat Jul 7 04:44:16 PDT 2007
I would like to have a rule that matches a C# block but ignores everything
inside
something like:
block '{' anything '}' ....
I tried to use the syntax i saw in token definition... ~X to match anything
except X. The problem is that the recursion never stops even with a simple
input text
if i have nested blocks.
Any clue?
grammar Test2;
options
{
backtrack=true;
}
tokens
{
TK_BLOCK;
}
prog
: (ID | block)*;
block
: '{' ( block | ( ~( '}' ) )* ) * '}';
WS : (' '|'\r' | '\n' | '\t' )+ {skip();};
ID : 'a'..'z'|'A'..'Z';
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20070707/7e8d73df/attachment.html
More information about the antlr-interest
mailing list