[antlr-interest] Problem with new lines
Sharon Li
hushlee83 at yahoo.com.sg
Wed Feb 5 15:01:08 PST 2003
Hello,
can anyone help me with this?
1) My lexer can't seem to recognize newlines. Thanks.
/**************************** Lexer class ***************************************/
class ViewLexer extends Lexer;
options {
charVocabulary='\3'..'\377';
filter=true;
k = 4;
defaultErrorHandler=false;
}
//protected SYMBOL : (SIGN|'%'|'/'|'.'|','|'*');
protected LETTER : ( 'a'..'z' | 'A'..'Z' ) ;
protected DIGIT : ( '0'..'9' ) ;
protected SIGN : ('-'|'+');
COLON : ':';
DOT : '.';
COMMA : ',';
NUMERIC : (SIGN)? (DIGIT)+ ((DOT) (d:DIGIT)*)*
;
WORD : (LETTER) (LETTER|DIGIT)*
;
SL_COMMENT
: "//"
(~('\n'|'\r'))* ('\n'|'\r'('\n')?)?
{$setType(Token.SKIP); newline();}
;
//COMMENT : "/*" (options {greedy=false;} :.)* "*/" ;
NEWLINE : ('\r''\n')=> '\r''\n'
| '\r'{newline();}
| '\n'{newline();}
{
newline();
$setType(Token.SKIP);
}
;
WS : (' '|'\t') { $setType(Token.SKIP); } ;
/**************************************** End of lexer *************************************/
2) How can I check for comments. How do I write a parser rule that allows comments ?
Thanks a lot!!
Yahoo! Travel
- Valentine surprise deals. Book now!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20030206/52b60e16/attachment.html
More information about the antlr-interest
mailing list