[antlr-interest] Grammar handling of whitespaces

Jim Idle jimi at temporal-wave.com
Thu Feb 7 12:14:55 PST 2008


But, if you can't have a single lexer rule for that, then the gated 
predicate looking at hidden tokens is required.

However, perhaps the OP thought that the hidden WS would be hidden from 
other lexer rules too? Which it isn't of course. If there is a 
whitespace, it would fail to match a rule:

X: 'aaaa' ':'?

'aaaa' WS ':' would be different tokens.

Jim

> -----Original Message-----
> From: Gavin Lambert [mailto:antlr at mirality.co.nz]
> Sent: Thursday, February 07, 2008 10:57 AM
> To: Shawn Poulson; Johannes Luber; Erik Kratochvil
> Cc: antlr-interest at antlr.org
> Subject: Re: [antlr-interest] Grammar handling of whitespaces
> 
> At 05:28 8/02/2008, Shawn Poulson wrote:
>  >In boost::spirit, they utilize a directive "lexeme_d[]" that
>  >surrounds parser references that are not processed by the
>  >skip parser (in this case, the WS rule), thereby enforcing
>  >no whitespace inbetween.  e.g. "lexeme_d[ 'T' >> int_p >>
>  >':' >> int_p ]" is valid in spirit.
>  >Maybe ANTLR could use an equivalent directive?
> 
> Umm, yes, that's called "a lexer rule".
> 
> 
> --
> No virus found in this outgoing message.
> Checked by AVG Free Edition.
> Version: 7.5.516 / Virus Database: 269.19.21/1265 - Release Date:
> 7/02/2008 11:17
> 
> 




More information about the antlr-interest mailing list