[antlr-interest] Isn't the lexer supposed to break out from a rule upon EOF?
    Rodrigo B. de Oliveira 
    rbo at acm.org
       
    Fri Apr 23 05:47:41 PDT 2004
    
    
  
Hi!
I'm having trouble with an antlr generated C# lexer on rules such as the
following:
<snip>
SL_COMMENT:
 "#"! (~('\r'|'\n')!)*
 { $setType(Token.SKIP); }
 ;
</snip>
The lexer refuses to return a token when it encounters an EOF inside the
inverted rule,
in other words, lexing a string like "#foo" would never return while lexing
something like "#foo\n" will.
Is this the expected behaviour?
My solution has been to add a specific check for EOF_CHAR to every inverted
rule in
my grammar:
<snip>
SL_COMMENT:
 "#"! ({EOF_CHAR != LA(1)}?~('\r'|'\n')!)*
 { $setType(Token.SKIP); }
 ;
</snip>
Any thoughts are very welcome!
Thanks in advance,
Rodrigo
 
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