[antlr-interest] Java.g4 bug? Attrib refs in lexer action
Graham Wideman
gwlist at grahamwideman.com
Wed Oct 3 17:02:12 PDT 2012
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
More information about the antlr-interest
mailing list