[antlr-interest] Match the End of File
xcolwell
xcolwell at yahoo.com
Fri Jul 16 19:58:27 PDT 2004
Hi,
I am trying to write a lexer to match a multi-line comment.
However, there is a catch. If a "comment" is started but never
terminated, I want to match it also. For example, I would like to
match
/* comment */EOF
as well as
/* comment EOF
under the same token. I am just getting into ANTLR, so I used Mr.
Parr's Java grammar from antlr.org as a starting point. It appears
that '\uFFFF' is the EOF character used internally. I can't find a
nice identifier in the documents. The modification I would like to
make is below.
ML_COMMENT
:
options {
generateAmbigWarnings=false;
}
:
{ LA(2)!='/' }? '*'
| '\r' '\n' {newline();}
| '\r' {newline();}
| '\n' {newline();}
| ~('*'|'\n'|'\r')
)*
("*/" | '\uFFFF' )
;
But unfortunately this does not work. Is there an EOF identifier I am
missing? How would one write a rule for what I am trying to do?
Best Regards,
Brien
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/antlr-interest/
<*> To unsubscribe from this group, send an email to:
antlr-interest-unsubscribe at yahoogroups.com
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list