[antlr-interest] Calling scala methods from ANTLR grammar - lots of warnings!
Alex Eagle
alexeagle at google.com
Fri Sep 11 11:12:31 PDT 2009
Hi Terrance and others,
I'm using ANTLR3, and in my tree grammar I'm assembling an object
model in Scala. When I add elements to a
scala.collection.mutable.Buffer, there's a method in scala "+=" which
is emitted into java bytecode as "$plus$eq".
So my grammar has chunks like this:
importDeclaration
: ^('import' name=qualifiedType)
{ $SourceFile::file.imports().$plus$eq($name.text); }
;
The problem is that antlr gets upset about the "$plus" and "$eq" and
prints errors:
error(114): /Users/alexeagle/IdeaProjects/noop/src/main/antlr/NoopAST.g:72:2:
attribute is not a token, parameter, or return value: eq
error(114): /Users/alexeagle/IdeaProjects/noop/src/main/antlr/NoopAST.g:77:2:
attribute is not a token, parameter, or return value: plus
But, the grammar is still generated and works fine. So it's just annoying.
I've tried to find a way to escape those dollar signs, but no luck. Any ideas?
Thanks!
-Alex
More information about the antlr-interest
mailing list