[antlr-interest] PEG-style "and" predicates

Jim Idle jimi at temporal-wave.com
Mon Jul 2 08:40:24 PDT 2007



> -----Original Message-----
> From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-
> bounces at antlr.org] On Behalf Of Wincent Colaiuta
> Sent: Monday, July 02, 2007 8:15 AM
> To: ANTLR Interest
> Subject: [antlr-interest] PEG-style "and" predicates
> I could change my rule to this:
> 
>    FOO : 'bar' ' '* ('\n' | '\r' | EOF) ;
> 
> But that isn't what I want; I want a 'bar' token and I don't want the
> trailing whitespace and newline to be included in the token.

How about this (C Target):

FOO 
	
: 'bar'

	{ MARK(); } 

	    ' '* ('\n' | '\r' | EOF)

	{ REWINDLAST();	}

;

Then assuming that bar without the trailing stuff can be managed by some
other rule, then it should be fine.

Jim



More information about the antlr-interest mailing list