[antlr-interest] Java.g4 bug? Attrib refs in lexer action
Terence Parr
parrt at cs.usfca.edu
Thu Oct 4 13:49:04 PDT 2012
I believe I updated the example to work with 4.0b2. There is no $foo in the lexer actions anymore. setType(), setChannel etc…
Ter
On Oct 3, 2012, at 5:02 PM, Graham Wideman wrote:
> Hi Ter and all:
>
> I'm working through the examples in the ANTLR 4 book, and have hit a problem using the Java.g4 grammar in example 3.3 ExtractInterfaceTool.
>
> Attempting to generate parser code...
> $ antlr4 Java.g4
>
> ... results in ...
> error(128): Java.g4:670:37: attribute references not allowed in lexer actions: $type
> error(128): Java.g4:674:41: attribute references not allowed in lexer actions: $type
>
> In Java.g4 there are rules:
>
> ENUM: 'enum' {if (!enumIsKeyword) $type=Identifier;}
> ;
>
> ASSERT
> : 'assert' {if (!assertIsKeyword) $type=Identifier;}
>
> ... which reference $type.
>
> Is there some option that needs to be used for this to work?
>
> I note that only a few days ago there was discussion thread "Bug in antlr4" discussing the skip vs channel(HIDDEN) issue, but no mention that other users were hitting the problem I report here.
>
> Windows 7
> Java 1.7.0_04
> ANTLR version: antlr-4.0b2-complete.jar
> Java.g4 version dated 2012-09-18, downloaded with example code tpantlr2-code.zip 2012-10-01 16:53
>
> Thanks,
>
> -- Graham
>
>
>
> 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