[antlr-interest] Token stream filter
Anakreon
anakreonmejdi at yahoo.gr
Wed Jun 2 06:19:22 PDT 2004
Anthony Youngman wrote:
Hello Anthony.
This is the whay I did it although the comments are lost so it might not be what
you need.
In the rule which matches identifiers i have this code:
if (_ttype == REM) {
mLINE(false);
_ttype = STATEMENT_END;
}
The mLINE is generated by the rule:
protected LINE : (~'\n')* '\n' {newline();};
> This sounds like it should be very easy, but I can't see how to do it
> ...
>
> I want to filter the token stream coming out of the lexer (and I can't
> see how to do it using the lexer's filter - can I do the same thing in
> the parser?). Anyways, I want to match the following sequence
>
> (newline | semi) ("rem" | "*" | "!" ) ~( "=" | "(" ) ({greedy=false} .)
> newline)
>
> eating everything EXCEPT the newline, which needs to be passed through
> to the parser. Note also, that while "*" and "!" are tokens, "rem" is an
> ident. Of course, if I need "rem" to be a token, presumably if this rule
> fails I can convert it back to an ident?
>
> Or do I need to write my own token stream to do this (if so, where do I
> look for an example?)
>
> Cheers,
> Wol
>
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