[antlr-interest] Calling scala methods from ANTLR grammar - lots of warnings!

Alex Eagle alexeagle at google.com
Fri Sep 11 15:51:09 PDT 2009


Doh... I'm pretty sure I tried that first, but yeah, backslash works fine.

Thanks!
-Alex

On Fri, Sep 11, 2009 at 3:34 PM, Terence Parr <parrt at cs.usfca.edu> wrote:
> try \$eq :)
> Ter
> On Sep 11, 2009, at 11:12 AM, Alex Eagle wrote:
>
>> 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
>>
>> List: http://www.antlr.org/mailman/listinfo/antlr-interest
>> Unsubscribe:
>> http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>
>


More information about the antlr-interest mailing list