[antlr-interest] Lexer help

odzsoi odzsoi at yahoo.com
Wed Apr 9 10:20:24 PDT 2003


Hi, 
 
 I would need your help to create a lexer for a simple templating language that would 
eat up everything that is not between two dollars ($), but replaces two dollars to a 
single dollar. 
 
For example: 
blabla$something$$$blabla$something2$bla$$bla 
 
should be lexed as (blabla) (something) ($blabla) (something2) (bla$bla). 
 
My lexer grammar is: 
TEXT                   :       (   ~('$') // Not dollar  
				    | '$'! '$' // Or two dollars 
				   )+ ; 
 
DOLLAR		  :	   '$'	; 
 
AntLR says: 
 
warning: lexical nondeterminism between rules TEXT and DOLLAR upon 
template.g:     k==1:'$' 
template.g:     k==2:<end-of-token> 
 
That I don't understand. If there is only a single $, it should be matched as DOLLAR of 
course. 
 
Thanks for your help. 


 

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




More information about the antlr-interest mailing list