[antlr-interest] A question about extracting comments

Fan Yang yhhf_dy at yahoo.com
Fri Oct 11 08:11:44 PDT 2002


Hi everybody,

I'm new to Antlr. I want to develop a parser for a language. In the 
language it uses REM and ' as keywords for comment. I wrote the 
following grammar to deal with comments. for ' kind of comments is 
ok. But it is obviously that "rem " is nondeterminism upon IDENT. But 
I don't know how to remove it. Would you please help me erase the 
nondeterminism error. 

thanks a lot.

COMMENT
: "rem "
| '\'' (~('\n'|'\r'))* ('\n'|'\r'('\n')?)
{$setType(ANTLR_USE_NAMESPACE(antlr)Token::SKIP); newline();}
; 

IDENT
options {testLiterals=true;}
:('a'..'z'|'_') ('a'..'z'|'_'|'0'..'9')* 
;

WS_ 
:(' '
| '\t'
){ _ttype = ANTLR_USE_NAMESPACE(antlr)Token.SKIP; }
;



 

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



More information about the antlr-interest mailing list