[antlr-interest] Token stream filter

Ric Klaren klaren at cs.utwente.nl
Thu Jun 3 01:43:34 PDT 2004


On Thu, Jun 03, 2004 at 09:24:07AM +0100, Anthony Youngman wrote:
> Thanks. Actually, Monty's solution should work ...

It looks a lot simpler ;)

> but seeing as you seem to know these things, taking this line from my
> original post

I'm only theorizing ;)

> 	(id:IDENT {if text != "REM" throw tokenmatchexception}|"*"|"!")
>
> which is the exception I need to throw here?

If you're trying to make the rule work inside a ( )=>( ) construct then it
should be something RecognitionException like (or derived of it)

> So - I can feed the lexer output into my deremer parser - and I can then
> feed the output from that into my main parser?

If you follow Monty's framework you should be ok I guess.

> And if I have a rule like
>
> commentst : (EOL | SEMI) ("*" | "!")! (~(EOL)*)! ;
>
> it will then eat everything between the initial eol/semi and final eol,
> but it will let those two tokens through to the next parser?

If you write the code in nextToken to do that it will. The ! operator
controls treebuilding it's not the lexer's ! operator. At least I was under
the impression you wanted to use a parser to do the filtering not a lexer
in front of your original lexer.

Cheers,

Ric
--
-----+++++*****************************************************+++++++++-------
    ---- Ric Klaren ----- j.klaren at utwente.nl ----- +31 53 4893755  ----
-----+++++*****************************************************+++++++++-------
 Time what is time - I wish I knew how to tell You why - It hurts to know -
          Aren't we machines - Time what is time - Unlock the door
               - And see the truth - Then time is time again
                From: 'Time what is Time' by Blind Guardian



 
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