[antlr-interest] Nested comments - char set inversion error
mzukowski at yci.com
mzukowski at yci.com
Mon Apr 14 08:06:10 PDT 2003
You can look at the java or gcc grammars to get a working C-style comment
for antlr.
It's complaining about the "\r\n" in the ~(). In fact you can leave that
part out of the
inversion since you already have '\r' and '\n' alone.
Monty
-----Original Message-----
From: mwi2k01 [mailto:mwi2k01 at yahoo.com]
Sent: Monday, April 14, 2003 6:08 AM
To: antlr-interest at yahoogroups.com
Subject: [antlr-interest] Nested comments - char set inversion error
Hi,
I need to write a lexer/parser for a language that has nested
comments.
Searching for a while for doing something like this in ANTLR pointed
me to ANTLR tutorial by Scott Stanchfield
(http://javadude.com/articles/antlrtut/)
where there is an example of 'C-style comment in ANTLR 2.0'
--------------------
// multiple-line comments
ML_COMMENT
: "/*"
( { LA(2)!='/' }? '*'
| ('\n'|"\r\n"|'\r') { newline(); }
| ~('*'|'\n'|"\r\n"|'\r')
)*
"*/"
{ $setType(Token.SKIP); }
;
---------------------
but I couldn't get this to work in ANTLR.
I'm getting this error when trying to generate lexer/parser
'xxx.g:16:28: This subrule cannot be inverted. Only subrules of the
form:
(T1|T2|T3...) or
('c1'|'c2'|'c3'...)
may be inverted (ranges are also allowed).
Exiting due to errors.'
Searching for this error in google pops out this page
http://www.antlr.org/bug/21.html
which suggest that it was a 'Char set inversion bugs' in ANTLR 2.20b
and was fixed in 2.4.0.
I'm using the latest ANTLR 2.7.2 release and after copy/paste the
exact grammar rfc822addr.g from http://www.antlr.org/bug/21.html
I'm still getting the same error (like described in the bug) !!!
Anyone can give me a hint/help ?
Thanks in advance,
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list