Просмотр исходного кода

Initial commit: frontend.java-1.1exp

Mathias Landhäußer 11 лет назад
Родитель
Сommit
abbd1de46b

+ 117 - 0
jplag.frontend.java-1.1exp/pom.xml

@@ -0,0 +1,117 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+	<modelVersion>4.0.0</modelVersion>
+	<artifactId>java-1.1exp</artifactId>
+	<version>0.0.1-SNAPSHOT</version>
+
+	<repositories>
+		<repository>
+			<id>ipdNexus</id>
+			<name>Recaa Repository</name>
+			<url>http://bob.ipd.kit.edu/nexus/content/repositories/public/</url>
+		</repository>
+	</repositories>
+
+	<build>
+		<plugins>
+			<plugin>
+				<groupId>org.codehaus.mojo</groupId>
+				<artifactId>build-helper-maven-plugin</artifactId>
+				<version>1.7</version>
+				<configuration>
+					<sources>
+						<source>target/generated-sources/javacc</source>
+					</sources>
+				</configuration>
+				<executions>
+					<execution>
+						<id>add-javacc-source</id>
+						<phase>generate-sources</phase>
+						<goals>
+							<goal>add-source</goal>
+						</goals>
+
+					</execution>
+				</executions>
+			</plugin>
+			<plugin>
+				<groupId>org.codehaus.mojo</groupId>
+				<artifactId>javacc-maven-plugin</artifactId>
+				<version>2.6</version>
+				<configuration>
+					<isStatic>false</isStatic>
+				</configuration>
+				<executions>
+					<execution>
+						<id>javacc</id>
+						<goals>
+							<goal>javacc</goal>
+						</goals>
+					</execution>
+				</executions>
+			</plugin>
+
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-jar-plugin</artifactId>
+				<configuration>
+					<archive>
+						<manifest>
+							<mainClass>jplag.javax.Parser</mainClass>
+							<packageName>jplag.javax</packageName>
+						</manifest>
+					</archive>
+				</configuration>
+			</plugin>
+		</plugins>
+		<pluginManagement>
+			<plugins>
+				<!--This plugin's configuration is used to store Eclipse m2e settings
+					only. It has no influence on the Maven build itself. -->
+				<plugin>
+					<groupId>org.eclipse.m2e</groupId>
+					<artifactId>lifecycle-mapping</artifactId>
+					<version>1.0.0</version>
+					<configuration>
+						<lifecycleMappingMetadata>
+							<pluginExecutions>
+								<pluginExecution>
+									<pluginExecutionFilter>
+										<groupId>
+											org.codehaus.mojo
+										</groupId>
+										<artifactId>
+											javacc-maven-plugin
+										</artifactId>
+										<versionRange>
+											[2.6,)
+										</versionRange>
+										<goals>
+											<goal>javacc</goal>
+										</goals>
+									</pluginExecutionFilter>
+									<action>
+										<ignore></ignore>
+									</action>
+								</pluginExecution>
+							</pluginExecutions>
+						</lifecycleMappingMetadata>
+					</configuration>
+				</plugin>
+			</plugins>
+		</pluginManagement>
+	</build>
+
+	<dependencies>
+		<dependency>
+			<groupId>edu.kit.ipd.jplag</groupId>
+			<artifactId>frontend-utils</artifactId>
+			<version>0.0.3-SNAPSHOT</version>
+		</dependency>
+	</dependencies>
+	<parent>
+		<groupId>edu.kit.ipd.jplag.frontend</groupId>
+		<artifactId>frontend-parent</artifactId>
+		<version>0.3-SNAPSHOT</version>
+	</parent>
+</project>

+ 128 - 0
jplag.frontend.java-1.1exp/src/main/java/jplag/javax/JavaToken.java

@@ -0,0 +1,128 @@
+package jplag.javax;
+
+public class JavaToken extends jplag.Token implements JavaTokenConstants {
+	private static final long serialVersionUID = 8090049637477580276L;
+	private int line;
+
+	public JavaToken(int type, String file, int zeile) {
+		super(type, file, zeile);
+	}
+
+	public int getLine() {
+		return line;
+	}
+
+	public void setLine(int line) {
+		this.line = line;
+	}
+
+	public int getColumn() {
+		return 0;
+	}
+
+	public int getLength() {
+		return 0;
+	}
+
+	public static String type2string(int type) {
+		switch (type) {
+	    case JavaTokenConstants.FILE_END:
+	                            return "FILE_END";
+	    case J_PACKAGE:         return "J_PACKAGE";
+	    case J_IMPORT:          return "J_IMPORT";
+	    case J_CLASS_BEGIN:     return "J_CLASS_BEGIN";
+	    case J_CLASS_END:       return "J_CLASS_END";
+	    case J_METHOD_BEGIN:    return "J_METHOD_BEGIN";
+	    case J_METHOD_END:      return "J_METHOD_END";
+	    case J_VARDEF:          return "J_VARDEF";
+	    case J_SYNC_BEGIN:      return "J_SYNC_BEGIN";
+	    case J_SYNC_END:        return "J_SYNC_END";
+	    case J_DO_BEGIN:        return "J_DO_BEGIN";
+	    case J_DO_END:          return "J_DO_END";
+	    case J_WHILE_BEGIN:     return "J_WHILE_BEGIN";
+	    case J_WHILE_END:       return "J_WHILE_END";
+	    case J_FOR_BEGIN:       return "J_FOR_BEGIN";
+	    case J_FOR_END:         return "J_FOR_END";
+	    case J_SWITCH_BEGIN:    return "J_SWITCH_BEGIN";
+	    case J_SWITCH_END:      return "J_SWITCH_END";
+	    case J_CASE:            return "J_CASE";
+	    case J_TRY_BEGIN:       return "J_TRY_BEGIN";
+	    case J_CATCH_BEGIN:     return "J_CATCH_BEGIN";
+	    case J_CATCH_END:       return "J_CATCH_END";
+	    case J_FINALLY:         return "J_FINALLY";
+	    case J_IF_BEGIN:        return "J_IF_BEGIN";
+	    case J_ELSE:            return "J_ELSE";
+	    case J_IF_END:          return "J_IF_END";
+	    case J_COND:            return "J_COND";
+	    case J_BREAK:           return "J_BREAK";
+	    case J_CONTINUE:        return "J_CONTINUE";
+	    case J_RETURN:          return "J_RETURN";
+	    case J_THROW:           return "J_THROW";
+	    case J_IN_CLASS_BEGIN:  return "J_IN_CLASS_BEGIN";
+	    case J_IN_CLASS_END:    return "J_IN_CLASS_END";
+	    case J_APPLY:           return "J_APPLY";
+	    case J_NEWCLASS:        return "J_NEWCLASS";
+	    case J_NEWARRAY:        return "J_NEWARRAY";
+	    case J_ASSIGN:          return "J_ASSIGN";
+	    case J_INTERFACE_BEGIN: return "J_INTERFACE_BEGIN";
+	    case J_INTERFACE_END:   return "J_INTERFACE_END";
+	    case J_CONSTR_BEGIN:    return "J_CONSTR_BEGIN";
+	    case J_CONSTR_END:      return "J_CONSTR_END";
+	    case J_INIT_BEGIN:      return "J_INIT_BEGIN";
+	    case J_INIT_END:        return "J_INIT_END";
+	    case J_VOID:            return "J_VOID";
+	    case J_ABSTRACT:        return "J_ABSTRACT";
+	    case J_FINAL:           return "J_FINAL";
+	    case J_PUBLIC:          return "J_PUBLIC";
+	    case J_STATIC:          return "J_STATIC";
+	    case J_PROTECTED:       return "J_PROTECTED";
+	    case J_PRIVATE:         return "J_PRIVATE";
+	    case J_EXTENDS:         return "J_EXTENDS";
+	    case J_TRANSIENT:       return "J_TRANSIENT";
+	    case J_VOLANTILE:       return "J_VOLANTILE";
+	    case J_ARRAY_INIT:      return "J_ARRAY_INIT";
+	    case J_NATIVE:          return "J_NATIVE";
+	    case J_SYNCHRONIZED:    return "J_SYNCHRONIZED";
+	    case J_THROWS:          return "J_THROWS";
+	    case J_THIS:            return "J_THIS";
+	    case J_BOOLEAN_TYPE:    return "J_BOOLEAN_TYPE";
+	    case J_CHAR_TYPE:       return "J_CHAR_TYPE";
+	    case J_BYTE_TYPE:       return "J_BYTE_TYPE";
+	    case J_SHORT_TYPE:      return "J_SHORT_TYPE";
+	    case J_INT_TYPE:        return "J_INT_TYPE";
+	    case J_LONG_TYPE:       return "J_LONG_TYPE";
+	    case J_FLOAT_TYPE:      return "J_FLOAT_TYPE";
+	    case J_DOUBLE_TYPE:     return "J_DOUBLE_TYPE";
+	    case J_ASSIGNOP:        return "J_ASSIGNOP";
+	    case J_ASSIGNBITOP:     return "J_ASSIGNBITOP";
+	    case J_COND_OR:         return "J_COND_OR";
+	    case J_COND_AND:        return "J_COND_AND";
+	    case J_COND_IOR:        return "J_COND_IOR";
+	    case J_COND_XOR:        return "J_COND_XOR";
+	    case J_AND:             return "J_AND";
+	    case J_EQUALITY:        return "J_EQUALITY";
+	    case J_INSTANCEOF:      return "J_INSTANCEOF";
+	    case J_SHIFT:           return "J_SHIFT";
+	    case J_RELATIONAL:      return "J_RELATIONAL";
+	    case J_ADD:             return "J_ADD";
+	    case J_MULT:            return "J_MULT";
+	    case J_DECINC:          return "J_DECINC";
+	    case J_CAST:            return "J_CAST";
+	    case J_SUPER:           return "J_SUPER";
+	      //case J_LITERAL:         return "J_LITERAL";
+	    case J_NULL:            return "J_NULL";
+	    case J_LABEL:           return "J_LABEL";
+	    case J_INT:             return "J_INT";
+	    case J_FLOAT:           return "J_FLOAT";
+	    case J_CHAR:            return "J_CHAR";
+	    case J_STRING:          return "J_STRING";
+	    case J_BOOLEAN:         return "J_BOOLEAN";
+	
+	    default:           return "<UNBEKANNT>";
+		}
+	}
+
+	public static int numberOfTokens() {
+		return NUM_DIFF_TOKENS;
+	}
+}

+ 100 - 0
jplag.frontend.java-1.1exp/src/main/java/jplag/javax/JavaTokenConstants.java

@@ -0,0 +1,100 @@
+package jplag.javax;
+
+//import java.io.*;
+
+public interface JavaTokenConstants extends jplag.TokenConstants {
+  final static int FILE_END = 0;
+
+  final static int J_PACKAGE =          1;  
+  final static int J_IMPORT =           2;  
+  final static int J_CLASS_BEGIN =      3;  
+  final static int J_CLASS_END =        4;  
+  final static int J_METHOD_BEGIN =     5;  
+  final static int J_METHOD_END =       6;  
+  final static int J_VARDEF =           7;  
+  final static int J_SYNC_BEGIN =       8;  
+  final static int J_SYNC_END =         9;  
+  final static int J_DO_BEGIN =        10;  
+  final static int J_DO_END =          11;  
+  final static int J_WHILE_BEGIN =     12;  
+  final static int J_WHILE_END =       13;  
+  final static int J_FOR_BEGIN =       14;  
+  final static int J_FOR_END =         15;  
+  final static int J_SWITCH_BEGIN =    16;  
+  final static int J_SWITCH_END =      17;  
+  final static int J_CASE =            18;  
+  final static int J_TRY_BEGIN =       19;  
+  final static int J_CATCH_BEGIN =     20;  
+  final static int J_CATCH_END =       21;  
+  final static int J_FINALLY =         22;  
+  final static int J_IF_BEGIN =        23;  
+  final static int J_ELSE =            24;  
+  final static int J_IF_END =          25;  
+  final static int J_COND =            26;  
+  final static int J_BREAK =           27;  
+  final static int J_CONTINUE =        28;  
+  final static int J_RETURN =          29;  
+  final static int J_THROW =           30;  
+  final static int J_IN_CLASS_BEGIN=   31;  
+  final static int J_IN_CLASS_END =    32;  
+  final static int J_APPLY =           33;  
+  final static int J_NEWCLASS =        34;  
+  final static int J_NEWARRAY =        35;  
+  final static int J_ASSIGN =          36;  
+  final static int J_INTERFACE_BEGIN=  37;  
+  final static int J_INTERFACE_END =   38;  
+  final static int J_CONSTR_BEGIN =    39;  
+  final static int J_CONSTR_END =      40;  
+  final static int J_INIT_BEGIN =      41;  
+  final static int J_INIT_END =        42;  
+  final static int J_VOID =            43;  
+  // new tokens:
+  final static int J_ABSTRACT =        44;
+  final static int J_FINAL =           45;
+  final static int J_PUBLIC =          46;
+  final static int J_STATIC =          47;
+  final static int J_PROTECTED =       48;
+  final static int J_PRIVATE =         49;
+  final static int J_EXTENDS =         50;
+  final static int J_TRANSIENT =       51;
+  final static int J_VOLANTILE =       52;
+  final static int J_ARRAY_INIT =      53;
+  final static int J_NATIVE =          54;
+  final static int J_SYNCHRONIZED =    55;
+  final static int J_THROWS =          56;
+  final static int J_THIS =            57;
+  final static int J_BOOLEAN_TYPE =    58;
+  final static int J_CHAR_TYPE =       59;
+  final static int J_BYTE_TYPE =       60;
+  final static int J_SHORT_TYPE =      61;
+  final static int J_INT_TYPE =        62;
+  final static int J_LONG_TYPE =       63;
+  final static int J_FLOAT_TYPE =      64;
+  final static int J_DOUBLE_TYPE =     65;
+  final static int J_ASSIGNOP =        66;
+  final static int J_ASSIGNBITOP =     67;
+  final static int J_COND_OR =         68;
+  final static int J_COND_AND =        69;
+  final static int J_COND_IOR =        70;
+  final static int J_COND_XOR =        71;
+  final static int J_AND =             72;
+  final static int J_EQUALITY =        73;
+  final static int J_INSTANCEOF =      74;
+  final static int J_SHIFT =           75;
+  final static int J_RELATIONAL =      76;
+  final static int J_ADD =             77;
+  final static int J_MULT =            78;
+  final static int J_DECINC =          79;
+  final static int J_CAST =            80;
+  final static int J_SUPER =           81;
+  //  final static int J_LITERAL =         82;
+  final static int J_NULL =            83;
+  final static int J_LABEL =           84;
+  final static int J_INT =             85;
+  final static int J_FLOAT =           86;
+  final static int J_CHAR =            87;
+  final static int J_STRING =          88;
+  final static int J_BOOLEAN =         89;
+
+  final static int NUM_DIFF_TOKENS =   90;
+}

+ 65 - 0
jplag.frontend.java-1.1exp/src/main/java/jplag/javax/Language.java

@@ -0,0 +1,65 @@
+package jplag.javax;
+
+import java.io.*;
+
+import jplag.ProgramI;
+import jplag.javax.Parser;
+
+public class Language implements jplag.Language {
+	private Parser parser;
+
+	public Language(ProgramI program) {
+		this.parser = new Parser();
+		this.parser.setProgram(program);
+
+	}
+
+	public int errorsCount() {
+		return this.parser.errorsCount();
+	}
+
+	public String[] suffixes() {
+		String[] res = { ".java", ".jav", ".JAVA", ".JAV" };
+		return res;
+	}
+
+	public String name() {
+		return "experimental Java1.1";
+	}
+
+	public String getShortName() {
+		return "Java1.1(exp)";
+	}
+
+	public int min_token_match() {
+		return 15;
+	}
+
+	public boolean supportsColumns() {
+		return false;
+	}
+
+	public boolean isPreformated() {
+		return true;
+	}
+
+	public boolean usesIndex() {
+		return false;
+	}
+
+	public jplag.Structure parse(File dir, String[] files) {
+		return this.parser.parse(dir, files);
+	}
+
+	public boolean errors() {
+		return this.parser.getErrors();
+	}
+
+	public int noOfTokens() {
+		return jplag.javax.JavaToken.numberOfTokens();
+	}
+
+	public String type2string(int type) {
+		return jplag.javax.JavaToken.type2string(type);
+	}
+}

+ 43 - 0
jplag.frontend.java-1.1exp/src/main/java/jplag/javax/Parser.java

@@ -0,0 +1,43 @@
+package jplag.javax;
+
+import java.io.*;
+
+public class Parser extends jplag.Parser implements JavaTokenConstants {
+	private String actFile;
+
+	private jplag.Structure struct;
+
+	public void main(String args[]) {
+		System.out.println(parse(new File("."), args).toString());
+	}
+
+	public jplag.Structure parse(File dir, String files[]) {
+		struct = new jplag.Structure();
+		errors = 0;
+		JavaParser parser = null;// no worry it will be reinitialized
+		// in method parseFile(...)
+		for (int i = 0; i < files.length; i++) {
+			actFile = files[i];
+			getProgram().print(null, "Parsing file " + files[i] + "\n");
+			if (!JavaParser.parseFile(dir, files[i], parser, this))
+				errors++;
+			struct.addToken(new JavaToken(FILE_END, actFile, 0));
+		}
+		// System.err.println(struct.toString());
+		if (errors == 0)
+			program.print(null, "OK\n");
+		else
+			program.print(null, errors + " ERRORS\n");
+		this.parseEnd();
+		return struct;
+	}
+
+	public void add(int type, Token token) {
+		struct.addToken(new JavaToken(type, actFile, token.beginLine));
+		/*
+		 * System.out.println(token.beginLine+"\t"+ (new
+		 * JavaToken(0,null,0)).type2string(type)+"\t"+ token.image);
+		 */
+	}
+
+}

+ 1186 - 0
jplag.frontend.java-1.1exp/src/main/javacc/Java1.1.jj

@@ -0,0 +1,1186 @@
+/* Hey Emacs, this is -*- mode: java; page-delimiter: "^%%$"; -*- */
+
+/**
+ *
+ * Copyright (C) 1996, 1997 Sun Microsystems Inc.
+ *
+ * Use of this file and the system it is part of is constrained by the
+ * file COPYRIGHT in the root directory of this system.  You may, however,
+ * make any modifications you wish to this file.
+ *
+ * Java files generated by running JavaCC on this file (or modified versions
+ * of this file) may be used in exactly the same manner as Java files
+ * generated from any grammar developed by you.
+ *
+ * Author: Sriram Sankar     (sriram@metamata.com)
+ * Date: 3/5/97
+ *
+ * This file contains a Java grammar and actions that implement a front-end.
+ *
+ */
+
+options {
+  JAVA_UNICODE_ESCAPE = true;
+}
+
+PARSER_BEGIN(JavaParser)
+package jplag.javax;
+import java.io.*;
+
+public class JavaParser implements JavaTokenConstants {
+  //static JavaParser parser = null;
+ private   jplag.javax.Parser parser2 ;
+  public static boolean parseFile(File dir, String fileName,jplag.javax.JavaParser parser,jplag.javax.Parser parserX) {
+    File file=null;
+    try {
+      FileInputStream in = new FileInputStream(file=new File(dir,fileName));
+      if (parser==null) {
+	parser = new JavaParser(in);
+      } else {
+	parser.ReInit(in);
+      }
+       parser.parser2=parserX;
+    } catch (FileNotFoundException e) {
+      System.out.println("Java EXPERIMENTAL Parser Version 1.1:  File "+
+			 fileName +" not found.");
+      return false;
+    }
+    try {
+      parser.CompilationUnit();
+    } catch (ParseException e) {
+      parserX.getProgram().addError("  Parsing Error in '" + fileName + "':\n  "
+                + e.getMessage() + "\n");
+      return false;
+    } catch (TokenMgrError e) {
+      parserX.getProgram().addError("  Scanning Error in '" + fileName
+      		+ "':\n  " + e.getMessage() + "\n");
+      return true; //false;		// TODO: Why has this been manually set to true?
+    }
+    return true;
+  }
+
+ /* public static void main(String args[]) {
+    parseFile(new File("."),args[0]);
+  }
+  */
+
+}
+
+PARSER_END(JavaParser)
+
+
+/* WHITE SPACE */
+
+SKIP :
+{
+  " "
+| "\t"
+| "\n"
+| "\r"
+| "\f"
+| "\u001a"
+
+}
+
+/* COMMENTS */
+
+MORE :
+{
+  "//" : IN_SINGLE_LINE_COMMENT
+|
+  <"/**" ~["/"]> { input_stream.backup(1); } : IN_FORMAL_COMMENT
+|
+  "/*" : IN_MULTI_LINE_COMMENT
+}
+
+<IN_SINGLE_LINE_COMMENT>
+SPECIAL_TOKEN :
+{
+  <SINGLE_LINE_COMMENT: "\n" | "\r" | "\r\n"> : DEFAULT
+}
+
+<IN_FORMAL_COMMENT>
+SPECIAL_TOKEN :
+{
+  <FORMAL_COMMENT: "*/" > : DEFAULT
+}
+
+<IN_MULTI_LINE_COMMENT>
+SPECIAL_TOKEN :
+{
+  <MULTI_LINE_COMMENT: "*/" > : DEFAULT
+}
+
+<IN_SINGLE_LINE_COMMENT,IN_FORMAL_COMMENT,IN_MULTI_LINE_COMMENT>
+MORE :
+{
+  < ~[] >
+}
+
+/* RESERVED WORDS AND LITERALS */
+
+TOKEN :
+{
+  < ABSTRACT: "abstract" >
+| < BOOLEAN: "boolean" >
+| < BREAK: "break" >
+| < BYTE: "byte" >
+| < CASE: "case" >
+| < CATCH: "catch" >
+| < CHAR: "char" >
+| < CLASS: "class" >
+| < CONST: "const" >
+| < CONTINUE: "continue" >
+| < _DEFAULT: "default" >
+| < DO: "do" >
+| < DOUBLE: "double" >
+| < ELSE: "else" >
+| < EXTENDS: "extends" >
+| < FALSE: "false" >
+| < FINAL: "final" >
+| < FINALLY: "finally" >
+| < FLOAT: "float" >
+| < FOR: "for" >
+| < GOTO: "goto" >
+| < IF: "if" >
+| < IMPLEMENTS: "implements" >
+| < IMPORT: "import" >
+| < INSTANCEOF: "instanceof" >
+| < INT: "int" >
+| < INTERFACE: "interface" >
+| < LONG: "long" >
+| < NATIVE: "native" >
+| < NEW: "new" >
+| < NULL: "null" >
+| < PACKAGE: "package">
+| < PRIVATE: "private" >
+| < PROTECTED: "protected" >
+| < PUBLIC: "public" >
+| < RETURN: "return" >
+| < SHORT: "short" >
+| < STATIC: "static" >
+| < SUPER: "super" >
+| < SWITCH: "switch" >
+| < SYNCHRONIZED: "synchronized" >
+| < THIS: "this" >
+| < THROW: "throw" >
+| < THROWS: "throws" >
+| < TRANSIENT: "transient" >
+| < TRUE: "true" >
+| < TRY: "try" >
+| < VOID: "void" >
+| < VOLATILE: "volatile" >
+| < WHILE: "while" >
+}
+
+/* LITERALS */
+
+TOKEN :
+{
+  < INTEGER_LITERAL:
+        <DECIMAL_LITERAL> (["l","L"])?
+      | <HEX_LITERAL> (["l","L"])?
+      | <OCTAL_LITERAL> (["l","L"])?
+  >
+|
+  < #DECIMAL_LITERAL: ["1"-"9"] (["0"-"9"])* >
+|
+  < #HEX_LITERAL: "0" ["x","X"] (["0"-"9","a"-"f","A"-"F"])+ >
+|
+  < #OCTAL_LITERAL: "0" (["0"-"7"])* >
+|
+  < FLOATING_POINT_LITERAL:
+        (["0"-"9"])+ "." (["0"-"9"])* (<EXPONENT>)? (["f","F","d","D"])?
+      | "." (["0"-"9"])+ (<EXPONENT>)? (["f","F","d","D"])?
+      | (["0"-"9"])+ <EXPONENT> (["f","F","d","D"])?
+      | (["0"-"9"])+ (<EXPONENT>)? ["f","F","d","D"]
+  >
+|
+  < #EXPONENT: ["e","E"] (["+","-"])? (["0"-"9"])+ >
+|
+  < CHARACTER_LITERAL:
+      "'"
+      (   (~["'","\\","\n","\r"])
+        | ("\\"
+            ( ["n","t","b","r","f","\\","'","\""]
+            | ["0"-"7"] ( ["0"-"7"] )?
+            | ["0"-"3"] ["0"-"7"] ["0"-"7"]
+            )
+          )
+      )
+      "'"
+  >
+|
+  < STRING_LITERAL:
+      "\""
+      (   (~["\"","\\","\n","\r"])
+        | ("\\"
+            ( ["n","t","b","r","f","\\","'","\""]
+            | ["0"-"7"] ( ["0"-"7"] )?
+            | ["0"-"3"] ["0"-"7"] ["0"-"7"]
+            )
+          )
+      )*
+      "\""
+  >
+}
+
+/* IDENTIFIERS */
+
+TOKEN :
+{
+  < IDENTIFIER: <LETTER> (<LETTER>|<DIGIT>)* >
+|
+  < #LETTER:
+      [
+       "\u0024",
+       "\u0041"-"\u005a",
+       "\u005f",
+       "\u0061"-"\u007a",
+       "\u00c0"-"\u00d6",
+       "\u00d8"-"\u00f6",
+       "\u00f8"-"\u00ff",
+       "\u0100"-"\u1fff",
+       "\u3040"-"\u318f",
+       "\u3300"-"\u337f",
+       "\u3400"-"\u3d2d",
+       "\u4e00"-"\u9fff",
+       "\uf900"-"\ufaff"
+      ]
+  >
+|
+  < #DIGIT:
+      [
+       "\u0030"-"\u0039",
+       "\u0660"-"\u0669",
+       "\u06f0"-"\u06f9",
+       "\u0966"-"\u096f",
+       "\u09e6"-"\u09ef",
+       "\u0a66"-"\u0a6f",
+       "\u0ae6"-"\u0aef",
+       "\u0b66"-"\u0b6f",
+       "\u0be7"-"\u0bef",
+       "\u0c66"-"\u0c6f",
+       "\u0ce6"-"\u0cef",
+       "\u0d66"-"\u0d6f",
+       "\u0e50"-"\u0e59",
+       "\u0ed0"-"\u0ed9",
+       "\u1040"-"\u1049"
+      ]
+  >
+}
+
+/* SEPARATORS */
+
+TOKEN :
+{
+  < LPAREN: "(" >
+| < RPAREN: ")" >
+| < LBRACE: "{" >
+| < RBRACE: "}" >
+| < LBRACKET: "[" >
+| < RBRACKET: "]" >
+| < SEMICOLON: ";" >
+| < COMMA: "," >
+| < DOT: "." >
+}
+
+/* OPERATORS */
+
+TOKEN :
+{
+  < ASSIGN: "=" >
+| < GT: ">" >
+| < LT: "<" >
+| < BANG: "!" >
+| < TILDE: "~" >
+| < HOOK: "?" >
+| < COLON: ":" >
+| < EQ: "==" >
+| < LE: "<=" >
+| < GE: ">=" >
+| < NE: "!=" >
+| < SC_OR: "||" >
+| < SC_AND: "&&" >
+| < INCR: "++" >
+| < DECR: "--" >
+| < PLUS: "+" >
+| < MINUS: "-" >
+| < STAR: "*" >
+| < SLASH: "/" >
+| < BIT_AND: "&" >
+| < BIT_OR: "|" >
+| < XOR: "^" >
+| < REM: "%" >
+| < LSHIFT: "<<" >
+| < RSIGNEDSHIFT: ">>" >
+| < RUNSIGNEDSHIFT: ">>>" >
+| < PLUSASSIGN: "+=" >
+| < MINUSASSIGN: "-=" >
+| < STARASSIGN: "*=" >
+| < SLASHASSIGN: "/=" >
+| < ANDASSIGN: "&=" >
+| < ORASSIGN: "|=" >
+| < XORASSIGN: "^=" >
+| < REMASSIGN: "%=" >
+| < LSHIFTASSIGN: "<<=" >
+| < RSIGNEDSHIFTASSIGN: ">>=" >
+| < RUNSIGNEDSHIFTASSIGN: ">>>=" >
+}
+
+
+/*****************************************
+ * THE JAVA LANGUAGE GRAMMAR STARTS HERE *
+ *****************************************/
+
+/*
+ * Program structuring syntax follows.
+ */
+
+void CompilationUnit() :
+{}
+{
+  [ PackageDeclaration() ]
+  ( ImportDeclaration() )*
+  ( TypeDeclaration() )*
+  <EOF>
+}
+
+void PackageDeclaration() :
+{}
+{
+  "package" Name() ";"                { parser2.add(J_PACKAGE,token); }
+}
+
+void ImportDeclaration() :
+{}
+{
+  "import" Name() [ "." "*" ] ";"     { parser2.add(J_IMPORT,token); }
+}
+
+void TypeDeclaration() :
+{}
+{
+  LOOKAHEAD( ( "abstract" | "final" | "public" )* "class" )
+  ClassDeclaration()
+|
+  InterfaceDeclaration()
+|
+  ";"
+}
+
+
+/*
+ * Declaration syntax follows.
+ */
+
+void ClassDeclaration() :
+{}
+{
+  ( "abstract" { parser2.add(J_ABSTRACT,token); }
+    | "final"  { parser2.add(J_FINAL,token); }
+    | "public" { parser2.add(J_PUBLIC,token); } )*
+  UnmodifiedClassDeclaration()
+}
+
+void UnmodifiedClassDeclaration() :
+{}
+{
+  "class" <IDENTIFIER>                { parser2.add(J_CLASS_BEGIN,token); }
+  [ "extends" Name() ] [ "implements" NameList() ]
+  ClassBody()                         { parser2.add(J_CLASS_END,token); }
+}
+
+void ClassBody() :
+{}
+{
+  "{" ( ClassBodyDeclaration() )* "}"
+}
+
+void NestedClassDeclaration() :
+{}
+{
+  ( "static"     { parser2.add(J_STATIC,token); }
+    | "abstract" { parser2.add(J_ABSTRACT,token); }
+    | "final"    { parser2.add(J_FINAL,token); }
+    | "public"   { parser2.add(J_PUBLIC,token); }
+    | "protected"{ parser2.add(J_PROTECTED,token); }
+    | "private"  { parser2.add(J_PRIVATE,token); } )*
+  UnmodifiedClassDeclaration()
+}
+
+void ClassBodyDeclaration() :
+{}
+{
+  LOOKAHEAD(2)
+  Initializer()
+|
+  LOOKAHEAD( ( "static" | "abstract" | "final" | "public" | "protected" | "private" )* "class" )
+  NestedClassDeclaration()
+|
+  LOOKAHEAD( ( "static" | "abstract" | "final" | "public" | "protected" | "private" )* "interface" )
+  NestedInterfaceDeclaration()
+|
+  LOOKAHEAD( [ "public" | "protected" | "private" ] Name() "(" )
+  ConstructorDeclaration()
+|
+  LOOKAHEAD( MethodDeclarationLookahead() )
+  MethodDeclaration()
+|
+  FieldDeclaration()
+}
+
+// This production is to determine lookahead only.
+void MethodDeclarationLookahead() :
+{}
+{
+  ( "public" | "protected" | "private" | "static" | "abstract" | "final" | "native" | "synchronized" )*
+  ResultType() <IDENTIFIER> "("
+}
+
+void InterfaceDeclaration() :
+{}
+{
+  ( "abstract" { parser2.add(J_ABSTRACT,token); }
+    | "public" { parser2.add(J_PUBLIC,token); } )*
+  UnmodifiedInterfaceDeclaration()
+}
+
+void NestedInterfaceDeclaration() :
+{}
+{
+  ( "static"     { parser2.add(J_STATIC,token); }
+    | "abstract" { parser2.add(J_ABSTRACT,token); }
+    | "final"    { parser2.add(J_FINAL,token); }
+    | "public"   { parser2.add(J_PUBLIC,token); }
+    | "protected"{ parser2.add(J_PROTECTED,token); }
+    | "private"  { parser2.add(J_PRIVATE,token); } )*
+  UnmodifiedInterfaceDeclaration()
+}
+
+void UnmodifiedInterfaceDeclaration() :
+{}
+{
+  "interface" <IDENTIFIER>             { parser2.add(J_INTERFACE_BEGIN,token); }
+  [ "extends"                          { parser2.add(J_EXTENDS,token); }
+    NameList() ]
+  "{" ( InterfaceMemberDeclaration() )* "}"
+                                       { parser2.add(J_INTERFACE_END,token); }
+}
+
+void InterfaceMemberDeclaration() :
+{}
+{
+  LOOKAHEAD( ( "static" | "abstract" | "final" | "public" | "protected" | "private" )* "class" )
+  NestedClassDeclaration()
+|
+  LOOKAHEAD( ( "static" | "abstract" | "final" | "public" | "protected" | "private" )* "interface" )
+  NestedInterfaceDeclaration()
+|
+  LOOKAHEAD( MethodDeclarationLookahead() )
+  MethodDeclaration()
+|
+  FieldDeclaration()
+}
+
+void FieldDeclaration() :
+{}
+{
+  ( "public"     { parser2.add(J_PUBLIC,token); }
+    | "protected"{ parser2.add(J_PROTECTED,token); }
+    | "private"  { parser2.add(J_PRIVATE,token); }
+    | "static"   { parser2.add(J_STATIC,token); }
+    | "final"    { parser2.add(J_FINAL,token); }
+    | "transient"{ parser2.add(J_TRANSIENT,token); }
+    | "volatile" { parser2.add(J_VOLANTILE,token); } )*
+  Type() VariableDeclarator() ( "," VariableDeclarator() )* (";")+
+}
+
+void VariableDeclarator() :
+{}
+{
+  VariableDeclaratorId()                    { parser2.add(J_VARDEF,token); }
+  [ "="                                     { parser2.add(J_ASSIGN,token); }
+    VariableInitializer() ]
+}
+
+void VariableDeclaratorId() :
+{}
+{
+  <IDENTIFIER> ( "[" "]" )*
+}
+
+void VariableInitializer() :
+{}
+{
+  ArrayInitializer()
+|
+  Expression()
+}
+
+void ArrayInitializer() :
+{}
+{
+  "{"                 { parser2.add(J_ARRAY_INIT,token); }
+    [ VariableInitializer() ( LOOKAHEAD(2) "," VariableInitializer() )* ] [ "," ] "}"
+}
+
+void MethodDeclaration() :
+{}
+{
+  ( "public"        { parser2.add(J_PUBLIC,token); }
+    | "protected"   { parser2.add(J_PROTECTED,token); }
+    | "private"     { parser2.add(J_PRIVATE,token); }
+    | "static"      { parser2.add(J_STATIC,token); }
+    | "abstract"    { parser2.add(J_ABSTRACT,token); }
+    | "final"       { parser2.add(J_FINAL,token); }
+    | "native"      { parser2.add(J_NATIVE,token); }
+    | "synchronized"{ parser2.add(J_SYNCHRONIZED,token); }  )*
+  ResultType() MethodDeclarator()        { parser2.add(J_METHOD_BEGIN,token); }
+  [ "throws" { parser2.add(J_THROWS,token); } NameList() ]
+  ( Block() | ";" ) (";")*               { parser2.add(J_METHOD_END,token); }
+}
+
+void MethodDeclarator() :
+{}
+{
+  <IDENTIFIER> FormalParameters() ( "[" "]" )*
+}
+
+void FormalParameters() :
+{}
+{
+  "(" [ FormalParameter() ( "," FormalParameter() )* ] ")"
+}
+
+void FormalParameter() :
+{}
+{
+  [ "final" { parser2.add(J_FINAL,token); } ] Type() VariableDeclaratorId()
+}
+
+void ConstructorDeclaration() :
+{}
+{
+  [ "public"      { parser2.add(J_PUBLIC,token); }
+    | "protected" { parser2.add(J_PROTECTED,token); }
+    | "private"   { parser2.add(J_PRIVATE,token); } ]
+  <IDENTIFIER>                           { parser2.add(J_CONSTR_BEGIN,token); }
+    FormalParameters() [ "throws" { parser2.add(J_THROWS,token); }
+		         NameList() ] "{"
+    [ LOOKAHEAD(ExplicitConstructorInvocation()) ExplicitConstructorInvocation() ]
+    ( BlockStatement() )*
+  "}" (";")*                             { parser2.add(J_CONSTR_END,token); }
+}
+
+void ExplicitConstructorInvocation() :
+{}
+{
+  LOOKAHEAD("this" Arguments() ";")
+  "this" { parser2.add(J_THIS,token); } Arguments() ";"
+|
+  [ LOOKAHEAD(2) PrimaryExpression() "." ] "super" Arguments() ";"
+}
+
+void Initializer() :
+{}
+{
+  [ "static" ]                
+                                     { parser2.add(J_INIT_BEGIN,token); }
+  Block()                            { parser2.add(J_INIT_END,token); }
+}
+
+
+/*
+ * Type, name and expression syntax follows.
+ */
+
+void Type() :
+{}
+{
+  ( PrimitiveType() | Name() ) ( "[" "]" )*
+}
+
+void PrimitiveType() :
+{}
+{
+  "boolean" { parser2.add(J_BOOLEAN_TYPE,token); }
+|
+  "char"    { parser2.add(J_CHAR_TYPE,token); }
+|
+  "byte"    { parser2.add(J_BYTE_TYPE,token); }
+|
+  "short"   { parser2.add(J_SHORT_TYPE,token); }
+|
+  "int"     { parser2.add(J_INT_TYPE,token); }
+|
+  "long"    { parser2.add(J_LONG_TYPE,token); }
+|
+  "float"   { parser2.add(J_FLOAT_TYPE,token); }
+|
+  "double"  { parser2.add(J_DOUBLE_TYPE,token); }
+}
+
+void ResultType() :
+{}
+{
+  "void"                              { parser2.add(J_VOID,token); }
+|
+  Type()
+}
+
+void Name() :
+/*
+ * A lookahead of 2 is required below since "Name" can be followed
+ * by a ".*" when used in the context of an "ImportDeclaration".
+ */
+{}
+{
+  <IDENTIFIER>
+  ( LOOKAHEAD(2) "." <IDENTIFIER>
+  )*
+}
+
+void NameList() :
+{}
+{
+  Name()
+  ( "," Name()
+  )*
+}
+
+
+/*
+ * Expression syntax follows.
+ */
+
+void Expression() :
+/*
+ * This expansion has been written this way instead of:
+ *   Assignment() | ConditionalExpression()
+ * for performance reasons.
+ * However, it is a weakening of the grammar for it allows the LHS of
+ * assignments to be any conditional expression whereas it can only be
+ * a primary expression.  Consider adding a semantic predicate to work
+ * around this.
+ */
+{}
+{
+  ConditionalExpression()
+  [ 
+    AssignmentOperator() Expression()
+  ]
+}
+
+void AssignmentOperator() :
+{}
+{
+  ("="      { parser2.add(J_ASSIGN,token); }
+   | "*="   { parser2.add(J_ASSIGNOP,token); }
+   | "/="   { parser2.add(J_ASSIGNOP,token); }
+   | "%="   { parser2.add(J_ASSIGNOP,token); }
+   | "+="   { parser2.add(J_ASSIGNOP,token); }
+   | "-="   { parser2.add(J_ASSIGNOP,token); }
+   | "<<="  { parser2.add(J_ASSIGNBITOP,token); }
+   | ">>="  { parser2.add(J_ASSIGNBITOP,token); }
+   | ">>>=" { parser2.add(J_ASSIGNBITOP,token); }
+   | "&="   { parser2.add(J_ASSIGNBITOP,token); }
+   | "^="   { parser2.add(J_ASSIGNBITOP,token); }
+   | "|="   { parser2.add(J_ASSIGNBITOP,token); } )
+}
+
+void ConditionalExpression() :
+{}
+{
+  ConditionalOrExpression()
+  [ { parser2.add(J_COND,token); } "?" Expression() ":" ConditionalExpression() ]
+}
+
+void ConditionalOrExpression() :
+{}
+{
+  ConditionalAndExpression() ( "||" { parser2.add(J_COND_OR,token); }
+  ConditionalAndExpression() )*
+}
+
+void ConditionalAndExpression() :
+{}
+{
+  InclusiveOrExpression() ( "&&" { parser2.add(J_COND_AND,token); }
+  InclusiveOrExpression() )*
+}
+
+void InclusiveOrExpression() :
+{}
+{
+  ExclusiveOrExpression() ( "|" { parser2.add(J_COND_IOR,token); }
+  ExclusiveOrExpression() )*
+}
+
+void ExclusiveOrExpression() :
+{}
+{
+  AndExpression() ( "^" { parser2.add(J_COND_XOR,token); }
+  AndExpression() )*
+}
+
+void AndExpression() :
+{}
+{
+  EqualityExpression() ( "&" { parser2.add(J_AND,token); }
+  EqualityExpression() )*
+}
+
+void EqualityExpression() :
+{}
+{
+  InstanceOfExpression() ( ( "==" | "!=" ) { parser2.add(J_EQUALITY,token); }
+  InstanceOfExpression() )*
+}
+
+void InstanceOfExpression() :
+{}
+{
+  RelationalExpression() [ "instanceof" { parser2.add(J_INSTANCEOF,token); }
+					Type() ]
+}
+
+void RelationalExpression() :
+{}
+{
+  ShiftExpression() ( ( "<" | ">" | "<=" | ">=" ) { parser2.add(J_RELATIONAL,token); }
+  ShiftExpression() )*
+}
+
+void ShiftExpression() :
+{}
+{
+  AdditiveExpression() ( ( "<<" | ">>" | ">>>" ) { parser2.add(J_SHIFT,token); }
+  AdditiveExpression() )*
+}
+
+void AdditiveExpression() :
+{}
+{
+  MultiplicativeExpression() ( ( "+" | "-" ) { parser2.add(J_ADD,token); }
+  MultiplicativeExpression() )*
+}
+
+void MultiplicativeExpression() :
+{}
+{
+  UnaryExpression() ( ( "*" | "/" | "%" ) { parser2.add(J_MULT,token); }
+  UnaryExpression() )*
+}
+
+void UnaryExpression() :
+{}
+{
+  ( "+" | "-" ) UnaryExpression()
+|
+  PreIncrementExpression()
+|
+  PreDecrementExpression()
+|
+  UnaryExpressionNotPlusMinus()
+}
+
+void PreIncrementExpression() :
+{}
+{
+  "++" PrimaryExpression()             { parser2.add(J_DECINC,token); }
+}
+
+void PreDecrementExpression() :
+{}
+{
+  "--" PrimaryExpression()             { parser2.add(J_DECINC,token); }
+}
+
+void UnaryExpressionNotPlusMinus() :
+{}
+{
+  ( "~" | "!" ) UnaryExpression()
+|
+  LOOKAHEAD( CastLookahead() )
+  CastExpression()
+|
+  PostfixExpression()
+}
+
+// This production is to determine lookahead only.  The LOOKAHEAD specifications
+// below are not used, but they are there just to indicate that we know about
+// this.
+void CastLookahead() :
+{}
+{
+  LOOKAHEAD(2)
+  "(" PrimitiveType()
+|
+  LOOKAHEAD("(" Name() "[")
+  "(" Name() "[" "]"
+|
+  "(" Name() ")" ( "~" | "!" | "(" | <IDENTIFIER> | "this" | "super" | "new" | Literal() )
+}
+
+void PostfixExpression() :
+{}
+{
+  PrimaryExpression() [ ("++" | "--")         { parser2.add(J_DECINC,token); } ]
+}
+
+void CastExpression() :
+{}
+{
+  (LOOKAHEAD("(" PrimitiveType())
+      "(" Type() ")" UnaryExpression()
+       |
+       "(" Type() ")" UnaryExpressionNotPlusMinus()
+    ) { parser2.add(J_CAST,token); }
+}
+
+void PrimaryExpression() :
+{}
+{
+  PrimaryPrefix() ( LOOKAHEAD(2) PrimarySuffix() )*
+}
+
+void PrimaryPrefix() :
+{}
+{
+  Literal()
+|
+  "this"      { parser2.add(J_THIS,token); }
+|
+  "super"     { parser2.add(J_SUPER,token); }
+  "." <IDENTIFIER>
+|
+  "(" Expression() ")"
+|
+  AllocationExpression()
+|
+  LOOKAHEAD( ResultType() "." "class" )
+  ResultType() "." "class"
+|
+  Name()                                  { /*parser2.add(J_NAME,token);*/ }
+}
+
+void PrimarySuffix() :
+{}
+{
+  LOOKAHEAD(2)
+  "." "this"         { parser2.add(J_THIS,token); }
+|
+  LOOKAHEAD(2)
+  "." AllocationExpression()
+|
+  "[" Expression() "]"
+|
+  "." <IDENTIFIER>
+|
+  Arguments()                             { parser2.add(J_APPLY,token); }
+}
+
+void Literal() :
+{}
+{
+  <INTEGER_LITERAL>          { parser2.add(J_INT,token); }
+|
+  <FLOATING_POINT_LITERAL>   { parser2.add(J_FLOAT,token); }
+|
+  <CHARACTER_LITERAL>        { parser2.add(J_CHAR,token); }
+|
+  <STRING_LITERAL>           { parser2.add(J_STRING,token); }
+|
+  BooleanLiteral()           { parser2.add(J_BOOLEAN,token); }
+|
+  NullLiteral()
+}
+
+void BooleanLiteral() :
+{}
+{
+  "true"
+|
+  "false"
+}
+
+void NullLiteral() :
+{}
+{
+  "null"                          { parser2.add(J_NULL,token); }
+}
+
+void Arguments() :
+{}
+{
+  "(" [ ArgumentList() ] ")"
+}
+
+void ArgumentList() :
+{}
+{
+  Expression() ( "," Expression() )*
+}
+
+void AllocationExpression() :
+{}
+{
+  LOOKAHEAD(2)
+  "new"                                      { parser2.add(J_NEWARRAY,token); }
+    PrimitiveType() ArrayDimsAndInits()
+|
+  "new"                                      { parser2.add(J_NEWCLASS,token); }
+    Name() (
+      ArrayDimsAndInits()                    { parser2.add(J_NEWARRAY,token); }
+    |
+      Arguments()
+      [ { parser2.add(J_IN_CLASS_BEGIN,token); }
+	ClassBody()
+	{ parser2.add(J_IN_CLASS_END,token); } ]
+    )
+}
+
+/*
+ * The third LOOKAHEAD specification below is to parse to PrimarySuffix
+ * if there is an expression between the "[...]".
+ */
+void ArrayDimsAndInits() :
+{}
+{
+  LOOKAHEAD(2)
+  ( LOOKAHEAD(2) "[" Expression() "]" )+ ( LOOKAHEAD(2) "[" "]" )*
+|
+  ( "[" "]" )+ ArrayInitializer()
+}
+
+
+/*
+ * Statement syntax follows.
+ */
+
+void Statement() :
+{}
+{
+  LOOKAHEAD(2)
+  LabeledStatement()
+|
+  Block()
+|
+  EmptyStatement()
+|
+  StatementExpression()                      { /*parser2.add(J_APPLY,token);*/ }
+  ";"
+|
+  SwitchStatement()
+|
+  IfStatement()
+|
+  WhileStatement()
+|
+  DoStatement()
+|
+  ForStatement()
+|
+  BreakStatement()
+|
+  ContinueStatement()
+|
+  ReturnStatement()
+|
+  ThrowStatement()
+|
+  SynchronizedStatement()
+|
+  TryStatement()
+}
+
+void LabeledStatement() :
+{}
+{
+  <IDENTIFIER> ":" Statement()   { parser2.add(J_LABEL,token); }
+}
+
+void Block() :
+{}
+{
+  "{" ( BlockStatement() )* "}"
+}
+
+void BlockStatement() :
+{}
+{
+  LOOKAHEAD([ "final" ] Type() <IDENTIFIER>)
+  LocalVariableDeclaration() ";"
+|
+  Statement()
+|
+  UnmodifiedClassDeclaration()
+|
+  UnmodifiedInterfaceDeclaration()
+}
+
+void LocalVariableDeclaration() :
+{}
+{
+  [ "final" { parser2.add(J_FINAL,token); } ]
+    Type() VariableDeclarator() ( "," VariableDeclarator() )*
+}
+
+void EmptyStatement() :
+{}
+{
+  ";"
+}
+
+void StatementExpression() :
+/*
+ * The last expansion of this production accepts more than the legal
+ * Java expansions for StatementExpression.  This expansion does not
+ * use PostfixExpression for performance reasons.
+ */
+{}
+{
+  PreIncrementExpression()
+|
+  PreDecrementExpression()
+|
+  PrimaryExpression()
+  [
+    "++"                                 { parser2.add(J_DECINC,token); }
+  |
+    "--"                                 { parser2.add(J_DECINC,token); }
+  |
+    AssignmentOperator() Expression()
+  ]
+}
+
+void SwitchStatement() :
+{}
+{
+  "switch"                          { parser2.add(J_SWITCH_BEGIN,token); }
+  "(" Expression() ")" "{"
+    ( SwitchLabel()                 { parser2.add(J_CASE,token); }
+      ( BlockStatement() )* )*
+  "}"                               { parser2.add(J_SWITCH_END,token); }
+}
+
+void SwitchLabel() :
+{}
+{
+  "case" Expression() ":"
+|
+  "default" ":"
+}
+
+void IfStatement() :
+/*
+ * The disambiguating algorithm of JavaCC automatically binds dangling
+ * else's to the innermost if statement.  The LOOKAHEAD specification
+ * is to tell JavaCC that we know what we are doing.
+ */
+{}
+{
+  "if"                              { parser2.add(J_IF_BEGIN,token); }
+     "(" Expression() ")" Statement()
+  [ LOOKAHEAD(1) "else"             { parser2.add(J_ELSE,token); }
+	     Statement() ]
+                                    { parser2.add(J_IF_END,token); }
+}
+
+void WhileStatement() :
+{}
+{
+  "while"                           { parser2.add(J_WHILE_BEGIN,token); }
+   "(" Expression() ")"Statement()  { parser2.add(J_WHILE_END,token); }
+}
+
+void DoStatement() :
+{}
+{
+  "do"                              { parser2.add(J_DO_BEGIN,token); }
+  Statement() "while" "(" Expression() ")" ";"
+                                    { parser2.add(J_DO_END,token); }
+}
+
+void ForStatement() :
+{}
+{
+  "for"                             { parser2.add(J_FOR_BEGIN,token); }
+    "(" [ ForInit() ] ";" [ Expression() ] ";" [ ForUpdate() ] ")" Statement()
+                                    { parser2.add(J_FOR_END,token); }
+}
+
+void ForInit() :
+{}
+{
+  LOOKAHEAD( [ "final" ] Type() <IDENTIFIER> )
+  LocalVariableDeclaration()
+|
+  StatementExpressionList()
+}
+
+void StatementExpressionList() :
+{}
+{
+  StatementExpression() ( "," StatementExpression() )*
+}
+
+void ForUpdate() :
+{}
+{
+  StatementExpressionList()
+}
+
+void BreakStatement() :
+{}
+{
+  "break"                           { parser2.add(J_BREAK,token); }
+  [ <IDENTIFIER> ] ";"
+}
+
+void ContinueStatement() :
+{}
+{
+  "continue"                        { parser2.add(J_CONTINUE,token); }
+  [ <IDENTIFIER> ] ";"
+}
+
+void ReturnStatement() :
+{}
+{
+  "return"                          { parser2.add(J_RETURN,token); }
+  [ Expression() ] ";"
+}
+
+void ThrowStatement() :
+{}
+{
+  "throw"                           { parser2.add(J_THROW,token); }
+  Expression() ";"
+}
+
+void SynchronizedStatement() :
+{}
+{
+  "synchronized"                    { parser2.add(J_SYNC_BEGIN,token); }
+  "(" Expression() ")" Block()      { parser2.add(J_SYNC_END,token); }
+}
+
+void TryStatement() :
+/*
+ * Semantic check required here to make sure that at least one
+ * finally/catch is present.
+ */
+{}
+{
+  "try"                             { parser2.add(J_TRY_BEGIN,token); }
+  Block()
+  ( "catch"                         { parser2.add(J_CATCH_BEGIN,token); }
+    "(" FormalParameter() ")" Block() )*
+  [ "finally"                       { parser2.add(J_FINALLY,token); }
+   Block() ]                        { parser2.add(J_CATCH_END,token); }
+}
+
+
+