[antlr-interest] BUG - Antlr is snooping in comments
Austin Hastings
Austin_Hastings at Yahoo.com
Fri Oct 12 12:44:00 PDT 2007
/* There's a comment here, too. */
scope Mumble {
int foo; /* Comment at the end? (x = 1) */
}
After scratching my head for a while over a mysterious error message, I
finally got the example case above.
From what I can tell, ANTLR treats the curly braces as delimiting some
mysterious other language -- this is decent, since it is trying to be
language-agnostic. But the error message is a killer:
[antlr3] error(148):
/home/austin/parrot/languages/hlasm/lib/grammar/HlasmSyntax.g:60:14:
rule parameters may not have init values: x
It took a while for me to understand what the problem was: apparently
ANTLR is not *totally* ignoring what happens inside the curlies. It is
trying to make sure that no initializers are provided -- possibly
indicating that this was (or still is) a common problem. But it is going
about it by looking for something like /\w+ =/ in the block, and
generating an error if it is found.
For me this has translated into "you may not use equal sign in comments
inside a scope block," which is amusing and annoying at the same time. I
submit that when this kind of thing is found, it should be a warning
rather than an error.
Or maybe antlr needs a tuneable warning / error system.
=Austin
More information about the antlr-interest
mailing list