[antlr-interest] ANTLR Java.g and ver.jar
Zachary Palmer
zep_antlr at bahj.com
Tue Jun 16 09:52:45 PDT 2009
Hello, all! I have just downloaded the Java 1.6 grammar from the ANTLR
site in hopes of performing some modifications for research purposes. I
am new to ANTLR, so the customary apologies for any silly queries
applies. :) My issue is that the Java.g file provided on antlr.org
contains the following comment:
/*
This is a merged file, containing two versions of the Java.g grammar.
To extract a version from the file, run the ver.jar with the command
provided below.
Version 1 - tree building version, with all source level support,
error recovery etc.
This is the version for compiler grammar workspace.
This version can be extracted by invoking:
java -cp ver.jar Main 1 true true true true true Java.g
Version 2 - clean version, with no source leve support, no error
recovery, no predicts,
assumes 1.6 level, works in Antlrworks.
This is the version for Alex.
This version can be extracted by invoking:
java -cp ver.jar Main 2 false false false false false
Java.g
*/
It appears that this grammar file is used in a branch of the OpenJDK
project, but the version I located on their site did not contain this
comment; therefore, I am left to believe that it was inserted by the
most recent author, Yang Jiang. My trouble is that I have searched the
OpenJDK project, ANTLR, and ANTLRWorks for a file named ver.jar to no avail.
When I try to load the grammar as-is into ANTLRWorks, I get a host of
warnings of the following form:
[10:50:11] warning(209): Java.g:1771:1: Multiple token rules can match
input such as "'*'": STAR, STAREQ
As a result, token(s) STAREQ were disabled for that input
[10:50:11] warning(209): Java.g:1811:1: Multiple token rules can match
input such as "'i'": IF, IMPLEMENTS, IMPORT, INSTANCEOF, INT, INTERFACE,
IDENTIFIER
As a result, token(s)
IMPLEMENTS,IMPORT,INSTANCEOF,INT,INTERFACE,IDENTIFIER were disabled for
that input
This eventually culminates in the following error:
[10:50:15] error(208): /home/zpalmer/research/Java.g:1799:1: The
following token definitions can never be matched because prior tokens
match the same input:
INTLITERAL,DOUBLELITERAL,LINE_COMMENT,ASSERT,BREAK,BYTE,CATCH,CHAR,CLASS,CONST,CONTINUE,DO,DOUBLE,ENUM,EXTENDS,FINALLY,FLOAT,FOR,IMPLEMENTS,IMPORT,INSTANCEOF,INT,INTERFACE,NEW,PRIVATE,PROTECTED,PUBLIC,STATIC,STRICTFP,SUPER,SWITCH,SYNCHRONIZED,THROW,THROWS,TRANSIENT,TRY,VOLATILE,TRUE,FALSE,NULL,DOT,ELLIPSIS,EQEQ,PLUS,SUB,SLASH,AMP,BAR,PLUSEQ,SUBEQ,STAREQ,SLASHEQ,AMPEQ,BAREQ,CARETEQ,PERCENTEQ,BANGEQ
I'm at a loss as to how to proceed. I would use the unmodified version
of Java.g from the OpenJDK site, but it appears that the version hosted
on the ANTLR website contains some valuable bug fixes. Can anyone
suggest a course of action or point me to a resource that might explain
the above-described behavior?
Cheers,
Zachary Palmer
More information about the antlr-interest
mailing list