[antlr-interest] Look ahead for the end of rule token

Gavin Lambert antlr at mirality.co.nz
Mon Dec 29 13:18:19 PST 2008


At 07:15 30/12/2008, Marian Nedelescu wrote:
>I need to parse xdoclet tags that start with @ and doesn't have 
>any end token.
>What I know is that this tag end at EOF or when another tag 
>starts with '@'.
>How can I specify that the ending token of the rule is '@' and 
>then to put is pack or to look ahead to the next token?

xdoclet_statement
     :  '@' (~('@' | EOF))*
     ;

Bear in mind though that since this is a parser rule, your lexer 
must still be able to generate some kind of token for all the 
content that will be matched by this rule.



More information about the antlr-interest mailing list