This works because lexer tokens are greedy:
LINE_COMMENT
: '//' (~('\n'|'\r'))* '\r'? '\n'?
{ $channel=HIDDEN; }
;
Sam
From: [email protected]
[mailto:[email protected]] On Behalf Of Brent Yates
Sent: Wednesday, February 11, 2009 11:52 AM
To: [email protected]
Subject: [antlr-interest] Lexer issues when block ends with EOF instead
ofEOL
Assuming a standard LINE comment form such as:
SL_COMMENT
: '//' ( options {greedy=false;} : . )* '\r'? '\n'
{$channel=HIDDEN;}
;
What is the best way to handle a file which ends with a single line
comment but no EOL?
If I add the EOF to the rule I get the following error:
SL_COMMENT
: '//' ( options {greedy=false;} : . )* '\r'? ('\n'|EOF)
{$channel=HIDDEN;}
;
ANTLR Parser Generator Version 3.1.1
error(201): SystemVerilogLexer.g:592:43: The following alternatives can
never be matched: 1
This problem occurs with other rules as well. Is it expected that files
which end with no EOL are bad or should the lexer handle it?
Thanks.
Brent Yates
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"il-antlr-interest" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/il-antlr-interest?hl=en
-~----------~----~----~----~------~----~------~--~---
List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe:
http://www.antlr.org/mailman/options/antlr-interest/your-email-address