[antlr-interest] Global Dynamic Scope

David-Sarah Hopwood david-sarah at jacaranda.org
Thu Nov 12 11:05:27 PST 2009

Claude Moulin wrote:
> Hello Jim,
> The bug is very strange and I made many tests in order to identify the
> problem.
> It is due to comments inserted in scope declarations. Sometimes they are
> accepted; in other cases no. It is impossible for me to know why.
> When there is a problem, lines like: // $myscope::varname = 0; also give
> an error even if they are comments.

The $ should be escaped if it is in a comment (or other non-expression
content such as within a string or character literal), i.e.

// \$myscope::varname = 0;

Yes, it's annoying. The reason is that since ANTLR doesn't parse the
target language, it can't tell which parts are comments or literals,
and so it will still report errors if the $-reference is not valid.

(If it is valid to refer to $myscope::varname in that context, then
it should be harmless for it be expanded within a comment, except that
looking at the generated code may be confusing.)

David-Sarah Hopwood  ⚥  http://davidsarah.livejournal.com

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 292 bytes
Desc: OpenPGP digital signature
Url : http://www.antlr.org/pipermail/antlr-interest/attachments/20091112/4fe3e26c/attachment.bin 

More information about the antlr-interest mailing list