[antlr-interest] Problem with Single Line Comments

ramyasivadas ramyasivadas at yahoo.co.in
Mon May 12 04:00:04 PDT 2003


Hi,
I have defined single line comment and multiline comment as follows:

SL_COMMENT
: "//"
(~('\n'|'\r'))* ('\n'|'\r'('\n')?)?
		{ _ttype = 

ANTLR_USE_NAMESPACE(antlr)Token::SKIP; }
;

ML_COMMENT
    :    "/*"
         (  { LA(2)!='/' }? '*'
         | '\n' { newline(); }
         | ~('*'|'\n')
         )*
         "*/"
		{ _ttype = 

ANTLR_USE_NAMESPACE(antlr)Token::SKIP; }
    ;

When a file with the comments are parsed, an exception is thrown 
depending on the string that appears following the "//" and the "/*" 
characters.
I just want the parser to ignore the string that follows immediately 
after the "//" or "/*" till the newline is encountered.
Can anyone please suggest me a solution for the problem.

Thanks in advance.
Regards,
Ramya



 

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




More information about the antlr-interest mailing list