[antlr-interest] Confusion with protected lexer rules

Jason jasonriz at yahoo.com
Wed Feb 25 13:36:53 PST 2004


$setType(Token.SKIP) does just what I want.  I should
have thought of that.  Thanks Robin.

-jason

--- Robin Debreuil <robin at debreuil.com> wrote:
> Are you referencing those rules anywhere? It seems
> to me your ID rules
> shouldn't be protected, but it depends what you
> want. If you want to get
> that one but then ignore it in the stream you can
> use:
> { _ttype = Token.SKIP; }
> like usually done with whitespace...
> 
> Cheers,
> Robin
> 
> 
> > Hello,
> >
> > The following is a small excerpt of my grammar:
> >
> > //BEGIN EXCERPT
> > protected REG_ID: ALPHA_CHAR ( ALPHA_CHAR | DIGIT
> )* {
> > System.out.println("Jason REG_ID"); }
> >   ;
> > protected ALPHA_CHAR: ('a'..'z' | 'A'..'Z') {
> > System.out.println("Jason ALPHA_CHAR"); }
> >   ;
> > protected DIGIT: ('0'..'9') {
> > System.out.println("Jason DIGIT"); }
> >   ;
> > protected ID: REG_ID { System.out.println("Jason:
> > ID"); }
> > //END EXCERPT
> >
> > None of these rules are firing.  If I remove the
> > 'protected' keyword from REG_ID everything behaves
> as
> > I'd expect but then of course a token gets
> returned to
> > the Parser which I don't want.  So, the is there
> any
> > way I can get the lexer to recognize these rules
> > without ever sending a token to the parser?  If
> push
> > comes to shove I can ignore the token in the
> parser
> > but I'd rather keep the solution confined to the
> > lexer.  Thanks in advance for any thoughts you may
> > have.
> >
> > -jason
> >
> > __________________________________
> > Do you Yahoo!?
> > Yahoo! Mail SpamGuard - Read only the mail you
> want.
> > http://antispam.yahoo.com/tools
> >
> >
> >
> > Yahoo! Groups Links
> >
> >
> >
> >
> >
> >
> 
> 
> 
>  
> Yahoo! Groups Links
> 
> 
>      antlr-interest-unsubscribe at yahoogroups.com
> 
>  
> 


__________________________________
Do you Yahoo!?
Yahoo! Mail SpamGuard - Read only the mail you want.
http://antispam.yahoo.com/tools


 
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