[antlr-interest] Match the End of File
Ari Steinberg
ari.steinberg at embarcadero.com
Mon Jul 19 06:53:13 PDT 2004
I think the lexer identifier you're looking for EOF_CHAR.
Ari
-----Original Message-----
From: xcolwell [mailto:xcolwell at yahoo.com]
Sent: Friday, July 16, 2004 10:58 PM
To: antlr-interest at yahoogroups.com
Subject: [antlr-interest] Match the End of File
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
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