[antlr-interest] Re: Antlr 3.0 spaces between tokens

Monty Zukowski monty at codetransform.com
Thu Nov 11 12:48:55 PST 2004


On Nov 10, 2004, at 11:13 PM, lgcraymer wrote:

>
> As usual--you ignore whitespace during parsing.  Then when you need
> the whitespace around a token, you peek into the token stream around
> the point of interest.  It doesn't help if whitespace is really a
> syntax feature and not just a token separator.
>
> --Loring
>
>
> --- In antlr-interest at yahoogroups.com, "matthew ford"
> <Matthew.Ford at f...> wrote:
>> A bit too clever for me  how do you write the parser rules?

Use a semantic predicate.  Seems to me you could use similar techniques 
as Don Caton just asked about to check for whitespace in makeToken() 
and you could even attach that information to a custom Token, then the 
parser can just use a semantic predicate to ask the token if it had 
whitespace before or after.

Monty



 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/antlr-interest/

<*> To unsubscribe from this group, send an email to:
    antlr-interest-unsubscribe at yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 





More information about the antlr-interest mailing list