diff --git a/.bzrignore b/.bzrignore
new file mode 100644
index 0000000000000000000000000000000000000000..67c0a9aac07867d11d9326636ef89dbba832dae0
--- /dev/null
+++ b/.bzrignore
@@ -0,0 +1,2 @@
+
+parser/semantic.cache
diff --git a/build.xml b/build.xml
index 1dd7ec36b09026d526fd874ac92e9fe2224b4e48..7d9c1d65d9ae9bb11581d936e12348d74d171f15 100644
--- a/build.xml
+++ b/build.xml
@@ -13,11 +13,13 @@
 
   <!-- "tools" is the directory where generators and libraries are located. -->
   <property name="tools" value="tools"/>
+
+  <property name="javacc.home" value="tools/javacc-4.0"/>
   
   <!-- "jflex" is an ant task class for the scanner generator in JFlex.jar -->
-  <taskdef name="jflex" classname="JFlex.anttask.JFlexTask" classpath="tools/JFlex.jar"/>
+<!--   <taskdef name="jflex" classname="JFlex.anttask.JFlexTask" classpath="tools/JFlex.jar"/> -->
   <!-- "beaver" is an ant task class for the parser generator in beaver.jar -->
-  <taskdef name="beaver" classname="beaver.comp.run.AntTask" classpath="tools/beaver.jar"/>
+<!--   <taskdef name="beaver" classname="beaver.comp.run.AntTask" classpath="tools/beaver.jar"/> -->
   <!-- "jastadd" is an ant task class in jastadd2.jar -->
   <taskdef name="jastadd" classname="jastadd.JastAddTask" classpath="tools/jastadd2.jar"/>
 
@@ -27,34 +29,38 @@
   </target>
   
   <!-- generate compiler source files -->
-  <target name="gen">
+  <target name="gen" description="Generate compiler source files">
     <!-- create AST node types and weave aspect modules -->
     <echo message = "Running JastAdd"/>
-    <jastadd package="${package}" rewrite="true" beaver="true" novisitcheck="true">
+<!--     <jastadd package="${package}" rewrite="true" beaver="true" novisitcheck="true"> -->
+    <jastadd package="${package}" rewrite="true" beaver="false" novisitcheck="true">
       <fileset dir=".">
 	<include name="**/*.ast"/>
 	<include name="**/*.jrag"/>
 	<include name="**/*.jadd"/>
       </fileset>
     </jastadd>
+    <jjtree target="owl.jjt" outputdirectory="${package}" javacchome="${javacc.home}"/>
+    <javacc target="${package}/owl.jj" outputdirectory="${package}" javacchome="${javacc.home}"/>
+
     <!-- generate the scanner -->
-    <echo message = "Running jflex"/>
-    <jflex file="parser/java14.flex" outdir="parser" nobak="yes"/>
+<!--     <echo message = "Running jflex"/> -->
+<!--     <jflex file="parser/java14.flex" outdir="parser" nobak="yes"/> -->
     <!-- generate the scanner -->
-    <jflex file="parser/unicode.flex" outdir="parser" nobak="yes"/>
+<!--     <jflex file="parser/unicode.flex" outdir="parser" nobak="yes"/> -->
     <!-- generate the parser phase 1, create a full .lalr specification from fragments-->
-    <echo message = "Running parser phase 1"/>
-    <concat destfile="parser/JavaParser.all" binary="true">
-      <fileset dir=".">
-	<include name="parser/java14.parser"/>
-      </fileset>
-    </concat>
+<!--     <echo message = "Running parser phase 1"/> -->
+<!--     <concat destfile="parser/JavaParser.all" binary="true"> -->
+<!--       <fileset dir="."> -->
+<!-- 	<include name="parser/java14.parser"/> -->
+<!--       </fileset> -->
+<!--     </concat> -->
     <!-- generate the parser phase 2, translating .lalr to .beaver -->
-    <java classpath="${tools}/proj.jar:${tools}/beaver-rt.jar" classname="Main">
-      <arg line="parser/JavaParser.all parser/JavaParser.beaver"/>
-    </java>
+<!--     <java classpath="${tools}/proj.jar:${tools}/beaver-rt.jar" classname="Main"> -->
+<!--       <arg line="parser/JavaParser.all parser/JavaParser.beaver"/> -->
+<!--     </java> -->
     <!-- generate the parser phase 3, translating .beaver to .java -->
-    <beaver file="parser/JavaParser.beaver" terminalNames="yes" compress="no" useSwitch="yes"/>
+<!--     <beaver file="parser/JavaParser.beaver" terminalNames="yes" compress="no" useSwitch="yes"/> -->
   </target>
 
   <!-- remove generated source files and .class files -->
diff --git a/owl.jjt b/owl.jjt
new file mode 100644
index 0000000000000000000000000000000000000000..cecbf1a1cfde6149f7ae743d624a21f0ae8396a8
--- /dev/null
+++ b/owl.jjt
@@ -0,0 +1,246 @@
+options {
+    MULTI                       = true;
+    VISITOR                     = true;
+    NODE_DEFAULT_VOID           = true;
+    NODE_SCOPE_HOOK             = false;
+    JAVA_UNICODE_ESCAPE         = true;
+    STATIC                      = false;
+} // options
+
+
+PARSER_BEGIN(OwlParser)
+package AST;
+public class OwlParser {
+}
+PARSER_END(OwlParser)
+
+
+//--------------------------------------------------------------------//
+//                           LEXICAL TOKENS                           //
+//--------------------------------------------------------------------//
+
+<DEFAULT, BOUNDS> SKIP : /* WHITE SPACE */
+{
+    " "
+    |
+    "\t"
+    |
+    "\n"
+    |
+    "\r"
+    |
+    "\f"
+}// WHITE SPACE
+
+
+// <DEFAULT,BOUNDS> SPECIAL_TOKEN : /* COMMENTS */
+// {
+//     <SLASH_SLASH_COMMENT :  "//" (~["\n","\r"])* >
+// }
+
+SPECIAL_TOKEN : /* COMMENTS */
+{
+//     <SLASH_STAR_COMMENT  :  "/*" (~["*"])* "*" ("*" | (~["*","/"] (~["*"])* "*"))* "/"  >
+    <XML_COMMENT  :  "<!--" (~["-","-",">"])* "-->"  >
+}// COMMENTS
+
+
+<BOUNDS> TOKEN: {
+    < BEGINCOMMENT : "<!--"     >
+  | < ENDCOMMENT   : "-->"     >
+}
+
+<DEFAULT, BOUNDS> TOKEN : /* RESERVED WORDS AND LITERALS */
+{
+    < XML                : "xml"          >
+  | < XML_BASE           : "xml:base" >
+  | < XMLNS              : "xmlns" >	 
+  | < XMLNS_RDF          : "xmlns:rdf" >	 
+  | < XMLNS_XSD          : "xmlns:xsd" >	 
+  | < XMLNS_RDFS         : "xmlns:rdfs" >	 
+  | < XMLNS_OWL          : "xmlns:owl" >	 
+  | < RDF_RDF            : "rdf:RDF"      >
+  | < RDF_ABOUT          : "rdf:about" >
+  | < RDF_ID             : "rdf:ID" >
+  | < RDF_RESOURCE       : "rdf:resource" >
+  | < RDFS_SUBCLASSOF    : "rdfs:subClassOf" >
+  | < OWL_ONTOLOGY       : "owl:Ontology" >
+  | < OWL_CLASS          : "owl:Class" >
+  | < OWL_DISJOINTWITH   : "owl:DisjointWith" >
+  | < OWL_RESTRICTION    : "owl:Restriction" >
+  | < OWL_ONPROPERTY     : "owl:onProperty" >
+  | < OWL_OBJECTPROPERTY : "owl:ObjectProperty" >
+  | < OWL_SOMEVALUESFROM : "owl:someValuesFrom" >
+
+}// RESERVED WORDS AND LITERALS
+
+<DEFAULT, BOUNDS> TOKEN : /* LITERALS */
+{
+    < 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"]
+                )
+            )
+        )*
+        "\""
+    >
+}// LITERALS
+
+<DEFAULT, BOUNDS> TOKEN : /* IDENTIFIERS */
+{
+    < 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"
+        ]
+    >
+}// IDENTIFIERS
+
+<DEFAULT,BOUNDS> TOKEN : /* SEPARATORS */
+{
+      < LPAREN               : "("    >
+    | < RPAREN               : ")"    >
+    | < LBRACE               : "{"    >
+    | < RBRACE               : "}"    >
+    | < LBRACKET             : "["    >
+    | < RBRACKET             : "]"    >
+    | < SEMICOLON            : ";"    >
+    | < COMMA                : ","    >
+    | < DOT                  : "."    >
+}// SEPARATORS
+
+
+// <DEFAULT,BOUNDS> TOKEN : /* OPERATORS */
+// {
+//       < 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 : ">>>=" >
+// }// OPERATORS
+
+
+//--------------------------------------------------------------------//
+//                      THE OWL LANGUAGE GRAMMAR                     //
+//--------------------------------------------------------------------//
+
+Specification Specification() #Specification : {}
+{
+  "<?" <XML> AttributeList() "?>"
+  { return jjtThis; }
+}
+
diff --git a/tools/javacc-4.0/LICENSE b/tools/javacc-4.0/LICENSE
new file mode 100644
index 0000000000000000000000000000000000000000..5e51a411e71f6df45aeec77e2c64a8f38e8e79ff
--- /dev/null
+++ b/tools/javacc-4.0/LICENSE
@@ -0,0 +1,18 @@
+Copyright (c) 2003 Sun Microsystems, Inc. All  Rights Reserved.
+
+Redistribution and use in source and binary forms, with or without modification, 
+are permitted provided that the following conditions are met:
+
+-Redistribution of source code must retain the above copyright notice, this  list of conditions and the following disclaimer.
+
+-Redistribution in binary form must reproduce the above copyright notice, 
+this list of conditions and the following disclaimer in the documentation and/or 
+other materials provided with the distribution.
+
+Neither the name of Sun Microsystems, Inc. or the names of contributors may 
+be used to endorse or promote products derived from this software without 
+specific prior written permission.
+
+This software is provided "AS IS," without a warranty of any kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MIDROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+You acknowledge that  this software is not designed, licensed or intended for use in the design, construction, operation or maintenance of any nuclear facility.
diff --git a/tools/javacc-4.0/bin/javacc b/tools/javacc-4.0/bin/javacc
new file mode 100755
index 0000000000000000000000000000000000000000..1b302fc610bf2d4f7de53f6e72de3e3a3a6702ee
--- /dev/null
+++ b/tools/javacc-4.0/bin/javacc
@@ -0,0 +1,9 @@
+#!/bin/sh
+JAR="`dirname $0`/lib/javacc.jar"
+
+case "`uname`" in
+     CYGWIN*) JAR="`cygpath --windows -- "$JAR"`" ;;
+esac
+
+java -classpath "$JAR" javacc "$@"
+
diff --git a/tools/javacc-4.0/bin/javacc.bat b/tools/javacc-4.0/bin/javacc.bat
new file mode 100644
index 0000000000000000000000000000000000000000..c16e6130573fbb0914c4a4b2a0679dbaf0fd9722
--- /dev/null
+++ b/tools/javacc-4.0/bin/javacc.bat
@@ -0,0 +1,4 @@
+
+@echo off
+
+java -classpath "%~f0\..\lib\javacc.jar" javacc %1 %2 %3 %4 %5 %6 %7 %8 %9
diff --git a/tools/javacc-4.0/bin/jjdoc b/tools/javacc-4.0/bin/jjdoc
new file mode 100755
index 0000000000000000000000000000000000000000..4203400c29e691ae017b7f91cdb60af9a31ad3e7
--- /dev/null
+++ b/tools/javacc-4.0/bin/jjdoc
@@ -0,0 +1,9 @@
+#!/bin/sh
+JAR="`dirname $0`/lib/javacc.jar"
+
+case "`uname`" in
+     CYGWIN*) JAR="`cygpath --windows -- "$JAR"`" ;;
+esac
+
+java -classpath "$JAR" jjdoc "$@"
+
diff --git a/tools/javacc-4.0/bin/jjdoc.bat b/tools/javacc-4.0/bin/jjdoc.bat
new file mode 100644
index 0000000000000000000000000000000000000000..667edda00efcfb23b204984dffad10866c03a581
--- /dev/null
+++ b/tools/javacc-4.0/bin/jjdoc.bat
@@ -0,0 +1,4 @@
+
+@echo off
+
+java -classpath "%~f0\..\lib\javacc.jar" jjdoc %1 %2 %3 %4 %5 %6 %7 %8 %9
diff --git a/tools/javacc-4.0/bin/jjtree b/tools/javacc-4.0/bin/jjtree
new file mode 100755
index 0000000000000000000000000000000000000000..500cb25033ff80c7bfb792c24066777098a6b501
--- /dev/null
+++ b/tools/javacc-4.0/bin/jjtree
@@ -0,0 +1,9 @@
+#!/bin/sh
+JAR="`dirname $0`/lib/javacc.jar"
+
+case "`uname`" in
+     CYGWIN*) JAR="`cygpath --windows -- "$JAR"`" ;;
+esac
+
+java -classpath "$JAR" jjtree "$@"
+
diff --git a/tools/javacc-4.0/bin/jjtree.bat b/tools/javacc-4.0/bin/jjtree.bat
new file mode 100644
index 0000000000000000000000000000000000000000..aadda3351717893c98a162a0a498f15447e97fe8
--- /dev/null
+++ b/tools/javacc-4.0/bin/jjtree.bat
@@ -0,0 +1,4 @@
+
+@echo off
+
+java -classpath "%~f0\..\lib\javacc.jar" jjtree %1 %2 %3 %4 %5 %6 %7 %8 %9
diff --git a/tools/javacc-4.0/bin/lib/javacc.jar b/tools/javacc-4.0/bin/lib/javacc.jar
new file mode 100644
index 0000000000000000000000000000000000000000..38f8426d546c30cea1469c09c08c23a11ff58b0c
Binary files /dev/null and b/tools/javacc-4.0/bin/lib/javacc.jar differ
diff --git a/tools/javacc-4.0/doc/CharStream.html b/tools/javacc-4.0/doc/CharStream.html
new file mode 100644
index 0000000000000000000000000000000000000000..fc3c3a4061fb6fe7d137db1dab0fa3ec777d99cc
--- /dev/null
+++ b/tools/javacc-4.0/doc/CharStream.html
@@ -0,0 +1,278 @@
+<!--
+
+Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+intellectual property rights relating to technology embodied in the product
+that is described in this document. In particular, and without limitation,
+these intellectual property rights may include one or more of the U.S.
+patents listed at http://www.sun.com/patents and one or more additional
+patents or pending patent applications in the U.S. and in other countries.
+U.S. Government Rights - Commercial software. Government users are subject
+to the Sun Microsystems, Inc. standard license agreement and applicable
+provisions of the FAR and its supplements.  Use is subject to license terms.
+Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+product is covered and controlled by U.S. Export Control laws and may be
+subject to the export or import laws in other countries.  Nuclear, missile,
+chemical biological weapons or nuclear maritime end uses or end users, whether
+direct or indirect, are strictly prohibited.  Export or reexport to countries
+subject to U.S. embargo or to entities identified on U.S. export exclusion
+lists, including, but not limited to, the denied persons and specially
+designated nationals lists is strictly prohibited.
+
+-->
+<HTML>
+<HEAD>
+ <title>JavaCC: CharStream Classes MiniTutorial</title>
+<!-- Changed by: Michael Van De Vanter, 14-Jan-2003 -->
+</HEAD>
+<BODY bgcolor="#FFFFFF" >
+
+<H1>JavaCC [tm]: CharStream Classes MiniTutorial</H1>
+
+This document describes in some detail the methods of the CharStream
+classes. Note that some of the details may not be relevant for the
+CharStream interface (to be used with USER_CHAR_STREAM).
+
+<P>
+
+There are 4 different kinds of char stream classes that are generated 
+based on combinations of various options.
+
+<UL>
+
+  <LI> <H3>ASCII_CharStream</H3>
+
+       Generated when neither of the two options - <TT>UNICODE_INPUT</TT>
+       or <TT>JAVA_UNICODE_ESCAPE</TT> is set. 
+
+<P>
+
+       This class treats the input as a stream of 1-byte (ISO-LATIN1)
+       characters. Note that this class can also be used to parse
+       binary files. It just reads a byte and returns it as a 16 bit
+       quantity to the lexical analyzer. So any character returned by
+       this class will be in the range <TT>'\u0000'-'\u00ff'</TT>.
+
+<P>
+
+  <LI> <H3>ASCII_UCodeESC_CharStream</H3>
+
+       Generated when the option <TT>JAVA_UNICODE_ESCAPE</TT> is set
+       and the <TT>UNICODE_INPUT</TT> option is not set.
+
+<P>
+
+       This class treats the input as a stream of 1-byte characters.
+       However, the special escape sequence
+<UL>
+<BR>
+             <TT>("\\\\")* "\\" ("u")+</TT> - (<I>odd number of backslahes followed
+       by one or more 'u's.</I>)
+</UL>
+<BR>
+
+       is treated as a tag indicating that the next 4 bytes following
+       the tag will be hexadecimal digits forming a 4-digit hex number
+       whose value will be treated as the value of the character at the
+       position indicated by the first backslash. Note that this value
+       can be anything in the range <TT>0x0-0xffff</TT>.
+<P>
+
+  <LI> <H3>UCode_CharStream</H3>
+
+       Generated when the option <TT>UNICODE_INPUT</TT> is set and 
+       the option <TT>JAVA_UNICODE_ESCAPE</TT> is not set.
+
+<P>
+
+       This class treats the input as a stream of 2-byte characters. So
+       it reads 2 bytes <TT>b1</TT> and <TT>b2</TT> and returns them as 
+       a single character using the expression <TT> b1 << 8 | b2 </TT>
+       assuming bigendian order. So in particular all the characters in
+       the range <TT>0x00-0xff</TT> are assumed to be stored as 2 bytes
+       with the first (higher-order) byte being 0.
+
+<P>
+
+  <LI> <H3>UCode_UCodeESC_CharStream</H3>
+
+       Generated when both the options <TT>UNICODE_INPUT</TT> and 
+       <TT>JAVA_UNICODE_ESCAPE</TT> are set.
+<P>
+
+       This class input is a stream of 2-byte characters (just
+       like the UCode_CharStream class) and the special escape sequence
+<UL>
+<BR>
+             <TT>("\\\\")* "\\" ("u")+</TT> - (<I>odd number of backslahes followed
+       by one or more 'u's.</I>)
+</UL>
+<BR>
+
+       is treated as a tag indicating that the next 4 2-byte characters
+       following the tag will be hexadecimal digits forming a 4-digit hex
+       number whose value will be treated as the value of the character at the
+       position indicated by the first backslash. Note that this value
+       can be any value in the range <TT>0x0-0xffff</TT>. Also note that
+       the backslash(es) and u(s) are all assumed to be given as 2-byte
+       characters (with the higher order byte value being 0).
+
+<P>
+</UL>
+
+<H4>
+Note : None of the above classes can be used to read characters in a
+       mixed mode, i.e., some characters given as 1-byte characters and others
+       as 2-byte characters. To do this, you need to set USER_CHAR_STREAM
+       option to true and define your own char stream.
+</H4>
+
+<HR>
+
+(Throughout the following, we use the notation XXXCharStream that stands
+ for any of the above described 4 classes.)
+
+<h3>Constructors</h3>
+<UL>
+
+<TT>
+  <LI> public XXXCharStream(java.io.InputStream dstream,
+                                        int startline, int startcolumn)
+</TT>
+
+<P>
+  Takes an input stream, starting line and column numbers and constructs a
+  CharStream object. It also creates buffers of initial size 4K for buffering the
+  characters and also for line and column numbers for each of those characters.
+
+<P>
+
+<TT>
+  <LI> public XXXCharStream(java.io.InputStream dstream,
+                                        int startline, int startcolumn, int buffersize)
+</TT>
+
+<P>
+  Takes an input stream, starting line and column numbers and constructs a
+  CharStream object. It also creates buffers of initial size <TT>buffsize</TT> for buffering the
+  characters and also for line and column numbers for each of those characters.
+
+<P>
+  So when you have an estimate on the maximum size of any token that can occur,
+  you can use that size to optimize the buffer sizes. Note, however, that 
+  these sizes are only initial sizes and they will be expanded as and when
+  needed (in 2K steps).
+</UL>
+
+<P>
+<HR>
+<h3>Methods</h3>
+
+All the following methods will be static or nonstatic depending on
+whether the STATIC option is true or false at the generation time. Also only
+those methods that users can use in their lexical actions (using the
+<TT>input_stream</TT> variable of the lexical analyzer) are documented
+here. Rest of the (public) methods are very tightly coupled with the
+implementation of the lexical analyzer and thus <B> should not </B> be
+used in lexical actions. In the future when we adopt version 1.1 of the Java [tm] programming language, we will
+streamline this by making that part of the interface an innerclass to
+the lexical analyzer.
+
+<P>
+
+<UL>
+
+  <LI> <TT>public final char readChar() throws java.io.IOException</TT>
+<P>
+
+       This method returns the next "character" in the input according
+       to the rules of the CharStream class as described above. It will
+       throw <TT>java.io.IOException</TT> if it reaches EOF during the
+       process of "constructing" the character. It also updates the line
+       and column number and buffers the character for any possible
+       backtracking that may be required later. It also stores the line
+       and column numbers for the same purpose.
+<P>
+
+  <LI> <TT> public final int getBeginLine() </TT>
+
+<P>
+       This method returns the line number for the beginning of the
+       current match.
+<P>
+
+  <LI> <TT> public final int getBeginColumn() </TT>
+
+<P>
+       This method returns the column number for the beginning of the
+       current match.
+<P>
+
+  <LI> <TT> public final int getEndLine() </TT>
+
+<P>
+       This method returns the line number for the ending of the
+       current match.
+
+<P>
+  <LI> <TT> public final int getEndColumn() </TT>
+
+<P>
+       This method returns the column number for the ending of the
+       current match.
+<P>
+
+  <LI> <TT> public final void backup(int amount) </TT>
+
+<P>
+       This method puts back <TT>amount</TT> number of characters
+       into the stream. Note that the amount indicates the number
+       of characters as constructed by <TT>readChar</TT>. Since the
+       buffers used are circular buffers, it cannot check for
+       illegal <TT>amount</TT> values, it just wraps around. So it
+       is the user's responsibility to make sure that those many
+       characters are really produced before a call to this method.
+<P>
+
+  <LI><TT> public final String GetImage()</TT>
+
+<P>
+       Returns the image of the current match. As far as the XXXCharStream
+       is concerned, all characters after the last call to the private method
+       <TT>BeginToken</TT> are considered a part of the current match.
+<P>
+
+  <LI><TT> public void ReInit(java.io.InputStream dstream,
+                                        int startline, int startcolumn)</TT>
+
+<P>
+
+       This method reinitializes the XXXCharStream classes with a (possibly
+       new) input stream and starting line and column numbers.
+<P>
+
+  <LI><TT> public void ReInit(java.io.InputStream dstream,
+                 int startline, int startcolumn, int buffersize)</TT>
+
+<P>
+
+       This method reinitializes the XXXCharStream classes with a (possibly
+       new) input stream and starting line and column numbers and adjusts
+       the size of the buffers to <TT>buffersize</TT>, by extending them.
+       Note that if the value of <TT>buffersize</TT> is less than the current
+       buffer sizes, they remain unchanged.
+<P>
+
+   <LI><TT> public void adjustBeginLineColumn(int newLine, int newCol)</TT>
+<P>
+
+       This method adjusts the line and column number of the beginning of
+       the current match to <TT>newLine</TT> and </TT>newCol</TT> and 
+       also adjusts the line and column numbers for all the characters
+       in the lookahead buffer.
+
+</UL>
+
+</BODY>
+</HTML>
diff --git a/tools/javacc-4.0/doc/JJDoc.html b/tools/javacc-4.0/doc/JJDoc.html
new file mode 100644
index 0000000000000000000000000000000000000000..bb47a98a3bdd4735a7c278dc0a3982e063581dc4
--- /dev/null
+++ b/tools/javacc-4.0/doc/JJDoc.html
@@ -0,0 +1,77 @@
+<HTML>
+<!--
+
+Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+intellectual property rights relating to technology embodied in the product
+that is described in this document. In particular, and without limitation,
+these intellectual property rights may include one or more of the U.S.
+patents listed at http://www.sun.com/patents and one or more additional
+patents or pending patent applications in the U.S. and in other countries.
+U.S. Government Rights - Commercial software. Government users are subject
+to the Sun Microsystems, Inc. standard license agreement and applicable
+provisions of the FAR and its supplements.  Use is subject to license terms.
+Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+product is covered and controlled by U.S. Export Control laws and may be
+subject to the export or import laws in other countries.  Nuclear, missile,
+chemical biological weapons or nuclear maritime end uses or end users, whether
+direct or indirect, are strictly prohibited.  Export or reexport to countries
+subject to U.S. embargo or to entities identified on U.S. export exclusion
+lists, including, but not limited to, the denied persons and specially
+designated nationals lists is strictly prohibited.
+
+-->
+<HEAD>
+ <title>JavaCC: JJDoc Documentation</title>
+<!-- Changed by: Michael Van De Vanter, 14-Jan-2003 -->
+</HEAD>
+<BODY bgcolor="#FFFFFF" >
+
+<H1>JavaCC [tm]: JJDoc Documentation</H1>
+
+JJDoc takes a JavaCC [tm] parser specification and produces documentation
+for the BNF grammar.  It can operate in three modes, determined by
+command line options.</p>
+
+    <dl>
+      <dt><code>TEXT</code></dt>
+
+      <dd>(default false)
+
+	<p>Setting <code>TEXT</code> to true causes JJDoc to generate
+	a plain text format description of the BNF.  Some formatting
+	is done via tab characters, but the intention is to leave it
+	as plain as possible.</p>
+
+	<p>The default value of <code>TEXT</code> causes JJDoc to
+	  generate a hyperlinked HTML document.</p>
+      </dd>
+
+      <dt><code>ONE_TABLE</code></dt>
+
+      <dd>(default true)
+
+	<p>The default value of <code>ONE_TABLE</code> is used to
+	  generate a single HTML table for the BNF.  Setting it to
+	  false will produce one table for every production in the
+	  grammar.</p>
+      </dd>
+
+      <dt><code>OUTPUT_FILE</code></dt>
+
+      <dd>The default behavior is to put the JJDoc output into a file
+	with either .html or .txt added as a suffix to the input
+	file's base name.  You can supply a different file name with
+	this option.
+      </dd>
+    </dl>
+
+    <p>When in <code>TEXT</code> mode, or when <code>ONE_TABLE</code>
+    is false, comments in the JavaCC source that immediately precede a
+    production are passed through to the generated documentation.</p>
+
+<HR>
+
+</BODY>
+</HTML>
diff --git a/tools/javacc-4.0/doc/JJTree.html b/tools/javacc-4.0/doc/JJTree.html
new file mode 100644
index 0000000000000000000000000000000000000000..21d6b7753fecf95127d7950fa8f69945190aa73a
--- /dev/null
+++ b/tools/javacc-4.0/doc/JJTree.html
@@ -0,0 +1,568 @@
+<HTML>
+<!--
+
+Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+intellectual property rights relating to technology embodied in the product
+that is described in this document. In particular, and without limitation,
+these intellectual property rights may include one or more of the U.S.
+patents listed at http://www.sun.com/patents and one or more additional
+patents or pending patent applications in the U.S. and in other countries.
+U.S. Government Rights - Commercial software. Government users are subject
+to the Sun Microsystems, Inc. standard license agreement and applicable
+provisions of the FAR and its supplements.  Use is subject to license terms.
+Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+product is covered and controlled by U.S. Export Control laws and may be
+subject to the export or import laws in other countries.  Nuclear, missile,
+chemical biological weapons or nuclear maritime end uses or end users, whether
+direct or indirect, are strictly prohibited.  Export or reexport to countries
+subject to U.S. embargo or to entities identified on U.S. export exclusion
+lists, including, but not limited to, the denied persons and specially
+designated nationals lists is strictly prohibited.
+
+-->
+<HEAD>
+<title>JavaCC:  JJTree Reference</title>
+<!-- Changed by: Michael Van De Vanter, 14-Jan-2003 -->
+</HEAD>
+<BODY bgcolor="#FFFFFF">
+
+<H1>JavaCC [tm]: JJTree Reference Documentation</H1>
+
+    <h3>Introduction</h3>
+
+    <p>JJTree is a preprocessor for JavaCC [tm] that inserts parse tree
+      building actions at various places in the JavaCC source.  The
+      output of JJTree is run through JavaCC to create the parser.
+      This document describes how to use JJTree, and how you can
+      interface your parser to it.</p>
+
+    <p>By default JJTree generates code to construct parse tree nodes
+      for each nonterminal in the language.  This behavior can be
+      modified so that some nonterminals do not have nodes generated,
+      or so that a node is generated for a part of a production's
+      expansion.</p>
+
+    <p>JJTree defines a Java interface Node that all parse tree nodes
+      must implement.  The interface provides methods for operations
+      such as setting the parent of the node, and for adding children
+      and retrieving them.</p>
+
+    <p>JJTree operates in one of two modes, simple and multi (for want
+      of better terms).  In simple mode each parse tree node is of
+      concrete type SimpleNode; in multi mode the type of the parse
+      tree node is derived from the name of the node.  If you don't
+      provide implementations for the node classes JJTree will
+      generate sample implementations based on SimpleNode for you.
+      You can then modify the implementations to suit.</p>
+
+    <p>Although JavaCC is a top-down parser, JJTree constructs the
+      parse tree from the bottom up.  To do this it uses a stack where
+      it pushes nodes after they have been created.  When it finds a
+      parent for them, it pops the children from the stack and adds
+      them to the parent, and finally pushes the new parent node
+      itself.  The stack is open, which means that you have access to
+      it from within grammar actions: you can push, pop and otherwise
+      manipulate its contents however you feel appropriate.  See <a
+      href="#scopes">Node Scopes and User Actions</a> below for more
+      important information.</p>
+
+    <p>JJTree provides decorations for two basic varieties of nodes,
+      and some syntactic shorthand to make their use convenient.</p>
+
+    <ol>
+      <li>
+	<p>A definite node is constructed with a specific number of
+	  children.  That many nodes are popped from the stack and
+	  made the children of the new node, which is then pushed on
+	  the stack itself.  You notate a definite node like this:</p>
+	<p><code>#ADefiniteNode(INTEGER EXPRESSION)</code></p> <p>A
+	  definite node descriptor expression can be any integer
+	  expression, although literal integer constants are by far
+	  the most common expressions.</p>
+      </li>
+
+      <li>
+	<p>A conditional node is constructed with all of the children
+	  that were pushed on the stack within its node scope if and
+	  only if its condition evaluates to true.  If it evaluates to
+	  false, the node is not constructed, and all of the children
+	  remain on the node stack.  You notate a conditional node
+	  like this:</p> <p><code>#ConditionalNode(BOOLEAN
+	    EXPRESSION)</code></p> <p>A conditional node descriptor
+	  expression can be any boolean expression.  There are two
+	  common shorthands for conditional nodes:</p>
+
+	<ol>
+	  <li>
+	    <p>Indefinite nodes</p> <p><code>#IndefiniteNode</code> is
+	      short for <code>#IndefiniteNode(true)</code></p>
+	  </li>
+	  
+	  <li>
+	    <p>Greater-than nodes</p> <p><code>#GTNode(>1)</code> is
+	      short for <code>#GTNode(jjtree.arity() > 1)</code></p>
+	  </li>
+	  
+	</ol> <p>The indefinite node shorthand (1) can lead to
+	  ambiguities in the JJTree source when it is followed by a
+	  parenthesized expansion.  In those cases the shorthand must
+	  be replaced by the full expression.  For example:</p> <pre>
+	  ( ... ) #N ( a() ) </pre>	 <p>is ambiguous; you have to
+	  use the explicit condition:</p> <pre> ( ... ) #N(true) ( a()
+	  ) </pre>
+
+	    </li>
+    </ol>
+
+    <p>WARNING: node descriptor expression should not have
+      side-effects.  JJTree doesn't specify how many times the
+      expression will be evaluated.</p>
+
+    <p>By default JJTree treats each nonterminal as an indefinite node
+      and derives the name of the node from the name of its
+      production.  You can give it a different name with the following
+      syntax:</p>
+	  <pre>
+    void P1() #MyNode : { ... } { ... }
+	  </pre>
+
+    <p>When the parser recognizes a <code>P1</code> nonterminal it
+      begins an indefinite node.  It marks the stack, so that any
+      parse tree nodes created and pushed on the stack by nonterminals
+      in the expansion for <code>P1</code> will be popped off and made
+      children of the node <code>MyNode</code>.</p>
+
+    <p>If you want to suppress the creation of a node for a production
+      you can use the following syntax:</p>
+	  <pre>
+    void P2() #void : { ... } { ... }
+	  </pre>
+
+    <p>Now any parse tree nodes pushed by nonterminals in the
+      expansion of <code>P2</code> will remain on the stack, to be
+      popped and made children of a production further up the tree.
+      You can make this the default behavior for non-decorated nodes
+      by using the <code>NODE_DEFAULT_VOID</code> option.</p>
+
+
+    <pre>    
+    void P3() : {}
+    {
+        P4() ( P5() )+ P6()
+    }
+    </pre>
+
+    <p>In this example, an indefinite node <code>P3</code> is begun,
+      marking the stack, and then a <code>P4</code> node, one or more
+      <code>P5</code> nodes and a <code>P6</code> node are parsed.
+      Any nodes that they push are popped and made the children of
+      <code>P3</code>.  You can further customize the generated
+      tree:</p>
+
+    <pre>
+    void P3() : {}
+    {
+        P4() ( P5() )+ #ListOfP5s P6()
+    }
+    </pre>
+
+    <p>Now the <code>P3</code> node will have a <code>P4</code> node,
+      a <code>ListOfP5s</code> node and a <code>P6</code> node as
+      children.  The <code>#Name</code> construct acts as a postfix
+      operator, and its scope is the immediately preceding expansion
+      unit.</p>
+
+
+    <h3><a name="scopes">Node Scopes and User Actions</a></h3>
+
+    <p>Each node is associated with a node scope.  User actions within
+      this scope can access the node under construction by using the
+      special identifier <code>jjtThis</code> to refer to the node.
+      This identifier is implicitly declared to be of the correct type
+      for the node, so any fields and methods that the node has can be
+      easily accessed.</p>
+
+    <p>A scope is the expansion unit immediately preceding the node
+      decoration.  This can be a parenthesized expression.  When the
+      production signature is decorated (perhaps implicitly with the
+      default node), the scope is the entire right hand side of the
+      production including its declaration block.</p>
+
+    <p>You can also use an expression involving <code>jjtThis</code>
+      on the left hand side of an expansion reference.  For
+      example:</p>
+	  <pre>
+    ... ( jjtThis.my_foo = foo() ) #Baz ...
+	  </pre>
+
+    <p>Here <code>jjtThis</code> refers to a <code>Baz</code> node,
+      which has a field called <code>my_foo</code>.  The result of
+      parsing the production <code>foo()</code> is assigned to that
+      <code>my_foo</code>.</p>
+
+    <p>The final user action in a node scope is different from all the
+      others.  When the code within it executes, the node's children
+      have already been popped from the stack and added to the node,
+      which has itself been pushed onto the stack.  The children can
+      now be accessed via the node's methods such as
+      <code>jjtGetChild()</code>.</p>
+
+    <p>User actions other than the final one can only access the
+      children on the stack.  They have not yet been added to the
+      node, so they aren't available via the node's methods.</p>
+
+    <p>A conditional node that has a node descriptor expression that
+      evaluates to false will not get added to the stack, nor have
+      children added to it.  The final user action within a
+      conditional node scope can determine whether the node was
+      created or not by calling the <code>nodeCreated()</code> method.
+      This returns true if the node's condition was satisfied and the
+      node was created and pushed on the node stack, and false
+      otherwise.</p>
+
+    <h3>Exception handling</h3>
+
+    <p>An exception thrown by an expansion within a node scope that is
+      not caught within the node scope is caught by JJTree itself.
+      When this occurs, any nodes that have been pushed on to the node
+      stack within the node scope are popped and thrown away.  Then
+      the exception is rethrown.</p>
+
+    <p>The intention is to make it possible for parsers to implement
+      error recovery and continue with the node stack in a known
+      state.</p>
+
+    <p>WARNING: JJTree currently cannot detect whether exceptions are
+      thrown from user actions within a node scope.  Such an exception
+      will probably be handled incorrectly.</p>
+
+
+    <h3><a name="hooks">Node Scope Hooks</a></h3>
+
+    <p>If the <code>NODE_SCOPE_HOOK</code> option is set to true,
+      JJTree generates calls to two user-defined parser methods on the
+      entry and exit of every node scope.  The methods must have the
+      following signatures:</p>
+
+    <pre>
+    void jjtreeOpenNodeScope(Node n)
+    void jjtreeCloseNodeScope(Node n)
+    </pre>
+
+    <p>If the parser is <code>STATIC</code> then these methods will
+      have to be declared as static as well.  They are both called
+      with the current node as a parameter.</p>
+
+    <p>One use for these functions is to store the node's first and
+      last tokens so that the input can be easily reproduced again.
+      For example:</p>
+
+    
+    <pre>
+    void jjtreeOpenNodeScope(Node n)
+    {
+      ((MySimpleNode)n).first_token = getToken(1);
+    }
+
+    void jjtreeCloseNodeScope(Node n)
+    {
+      ((MySimpleNode)n).last_token = getToken(0);
+    }
+    </pre>
+
+    <p>where <code>MySimpleNode</code> is based on
+      <code>SimpleNode</code> and has the following additional
+      fields:</p>
+
+    <pre>
+    Token first_token, last_token;
+    </pre>
+
+    <p>Another use might be to store the parser object itself in the
+      node so that state that should be shared by all nodes produced
+      by that parser can be provided.  For example, the parser might
+      maintain a symbol table.</p>
+
+    <h3>The Life Cycle of a Node</h3>
+
+    <p>A node goes through a well determined sequence of steps as it
+      is built.  This is that sequence viewed from the perspective of
+      the node itself:</p>
+
+    <ol>
+      <li>the node's constructor is called with a unique integer
+	parameter.  This parameter identifies the kind of node and is
+	especially useful in simple mode.  JJTree automatically
+	generates a file called <i>parser</i>TreeConstants.java that 
+	declares valid constants.  The names of constants are derived
+	by prepending JJT to the uppercase names of nodes, with dot 
+	symbols (&quot;.&quot;) replaced by underscore symbols 
+	(&quot;_&quot;).  For convenience, an array of <code>String</code>s 
+	called <code>jjtNodeName[]</code> that maps the constants to the 
+	unmodified names of nodes is maintained in the same file.</li>
+
+      <li>the node's <code>jjtOpen()</code> method is called.</li>
+
+      <li>if the option <code>NODE_SCOPE_HOOK</code> is set, the
+	user-defined parser method <code>openNodeScope()</code> is
+	called and passed the node as its parameter.  This method can
+	initialize fields in the node or call its methods.  For
+	example, it might store the node's first token in the
+	node.</li>
+
+      <li>if an unhandled exception is thrown while the node is being
+	parsed then the node is abandoned.  JJTree will never refer to
+	it again.  It will not be closed, and the user-defined node
+	scope hook <code>closeNodeHook()</code> will not be called
+	with it as a parameter.</li>
+
+      <li>otherwise, if the node is conditional and its conditional
+	expression evaluates to false then the node is abandoned.  It
+	will not be closed, although the user-defined node scope hook
+	<code>closeNodeHook()</code> might be called with it as a
+	parameter.</li>
+
+      <li>otherwise, all of the children of the node as specified by
+	the integer expression of a definite node, or all the nodes
+	that were pushed on the stack within a conditional node scope
+	are added to the node.  The order they are added is not
+	specified.</li>
+
+      <li>the node's <code>jjtClose()</code> method is called.</li>
+
+      <li>the node is pushed on the stack.</li>
+
+      <li>if the option <code>NODE_SCOPE_HOOK</code> is set, the
+	user-defined parser method <code>closenNodeScope()</code> is
+	called and passed the node as its parameter.</li>
+
+      <li>if the node is not the root node, it is added as a child of
+	another node and its <code>jjtSetParent()</code> method is
+	called.</li>
+    </ol>
+
+    <h3>Visitor Support</h3>
+
+    <p>JJTree provides some basic support for the visitor design
+      pattern.  If the <code>VISITOR</code> option is set to true
+      JJTree will insert an <code>jjtAccept()</code> method into all
+      of the node classes it generates, and also generate a visitor
+      interface that can be implemented and passed to the nodes to
+      accept.</p>
+
+    <p>The name of the visitor interface is constructed by appending
+      <code>Visitor</code> to the name of the parser.  The interface
+      is regenerated every time that JJTree is run, so that it
+      accurately represents the set of nodes used by the parser.  This
+      will cause compile time errors if the implementation class has
+      not been updated for the new nodes.  This is a feature.</p>
+
+
+    <h3>Options</h3>
+
+    <p>JJTree supports the following options on the command
+      line and in the JavaCC options statement:</p>
+
+    <dl>
+      <dt><code>BUILD_NODE_FILES</code> (default:
+	<code>true</code>)</dt>
+      <dd>Generate sample implementations for SimpleNode and any other
+	nodes used in the grammar.</dd>
+
+      <dt><code>MULTI</code> (default: <code>false</code>)</dt>
+      <dd> Generate a multi mode parse tree.  The default for this is
+	false, generating a simple mode parse tree.</dd>
+
+      <dt><code>NODE_DEFAULT_VOID</code> (default:
+	<code>false</code>)</dt>
+      <dd>Instead of making each non-decorated production an
+	indefinite node, make it void instead.</dd>
+
+      <dt><code>NODE_FACTORY</code> (default: <code>false</code>)</dt>
+
+      <dd>Use a factory method with following signature to construct
+	nodes:
+
+	<br><code>public static Node jjtCreate(int id)</code>
+      </dd>
+
+      <dt><code>NODE_PACKAGE</code> (default: <code>""</code>)</dt>
+
+      <dd> The package to generate the node classes into.  The default
+	for this is the parser package.</dd>
+
+      <dt><code>NODE_PREFIX</code> (default: <code>"AST"</code>)</dt>
+
+      <dd>The prefix used to construct node class names from node
+	identifiers in multi mode.  The default for this is AST.</dd>
+
+      <dt><code>NODE_SCOPE_HOOK</code> (default:
+	<code>false</code>)</dt>
+
+      <dd>Insert calls to user-defined parser methods on entry and
+	exit of every node scope.  See <a href="#hooks">Node Scope
+	  Hooks above</a>.</dd>
+      
+      <dt><code>NODE_USES_PARSER</code> (default:
+	<code>false</code>)</dt>
+
+      <dd>JJTree will use an alternate form of the node construction
+	routines where it passes the parser object in.  For example,
+	<pre> public static Node MyNode.jjtCreate(MyParser p, int id);
+	  MyNode(MyParser p, int id); </pre>
+      </dd>
+
+      <dt><code>STATIC</code> (default: <code>true</code>)</dt>
+
+      <dd>Generate code for a static parser.  The default for this is
+	true.  This must be used consistently with the equivalent
+	JavaCC options.  The value of this option is emitted in the
+	JavaCC source.</dd>
+
+      <dt><code>VISITOR</code> (default: <code>false</code>)</dt>
+
+      <dd>Insert a <code>jjtAccept()</code> method in the node
+	classes, and generate a visitor implementation with an entry
+	for every node type used in the grammar.</dd>
+
+      <dt><code>VISITOR_EXCEPTION</code> (default:
+	<code>""</code>)</dt>
+
+      <dd>If this option is set, it is used in the signature of the
+	generated <code>jjtAccept()</code> methods and the visit()
+	methods.  <em>Note:</em> this option will be removed in a
+	later version of JJTree.  Don't use it if that bothers
+	you.</dd>
+
+      <dt><code>JJTREE_OUTPUT_DIRECTORY</code> (default:
+	use value of <code>OUTPUT_DIRECTORY</code>)</dt>
+
+      <dd>By default, JJTree generates its output in the directory
+      specified in the global <code>OUTPUT_DIRECTORY</code> setting.
+      Explicitly setting this option allows the user to separate the
+      parser from the tree files.</dd>
+    </dl>
+
+
+    <h3>JJTree state</h3>
+
+    <p>JJTree keeps its state in a parser class field called
+      <code>jjtree</code>.  You can use methods in this member to
+      manipulate the node stack.</p>
+    
+    <pre>
+    final class JJTreeState {
+      /* Call this to reinitialize the node stack.  */
+      void reset();
+
+      /* Return the root node of the AST. */
+      Node rootNode();
+
+      /* Determine whether the current node was actually closed and
+	 pushed */
+      boolean nodeCreated();
+
+      /* Return the number of nodes currently pushed on the node
+         stack in the current node scope. */
+      int arity();
+
+      /* Push a node on to the stack. */
+      void pushNode(Node n);
+
+      /* Return the node on the top of the stack, and remove it from the
+	 stack.  */
+      Node popNode();
+
+      /* Return the node currently on the top of the stack. */
+      Node peekNode();
+    }
+    </pre>
+
+
+    <h3>Node Objects</h3>
+
+    <pre>
+    /* All AST nodes must implement this interface.  It provides basic
+       machinery for constructing the parent and child relationships
+       between nodes. */
+
+    public interface Node {
+      /** This method is called after the node has been made the current
+	node.  It indicates that child nodes can now be added to it. */
+      public void jjtOpen();
+
+      /** This method is called after all the child nodes have been
+	added. */
+      public void jjtClose();
+
+      /** This pair of methods are used to inform the node of its
+	parent. */
+      public void jjtSetParent(Node n);
+      public Node jjtGetParent();
+
+      /** This method tells the node to add its argument to the node's
+	list of children.  */
+      public void jjtAddChild(Node n, int i);
+
+      /** This method returns a child node.  The children are numbered
+	 from zero, left to right. */
+      public Node jjtGetChild(int i);
+
+      /** Return the number of children the node has. */
+      int jjtGetNumChildren();
+    }
+    </pre>
+
+    <p>The class <code>SimpleNode</code> implements the
+      <code>Node</code> interface, and is automatically generated by
+      JJTree if it doesn't already exist.  You can use this class as a
+      template or superclass for your node implementations, or you can
+      modify it to suit.  <code>SimpleNode</code> additionally
+      provides a rudimentary mechanism for recursively dumping the
+      node and its children.  You might use this is in action like
+      this:</p>
+
+    <pre>    
+    {
+        ((SimpleNode)jjtree.rootNode()).dump(">");
+    }
+
+    </pre>
+
+    <p>The <code>String</code> parameter to <code>dump()</code> is
+      used as padding to indicate the tree hierarchy.</p>
+
+    <p>Another utility method is generated if the VISITOR options is set:</p>
+    <pre>
+    {
+        public void childrenAccept(MyParserVisitor visitor);
+    }
+    </pre>
+
+    <p>This walks over the node's children in turn, asking them to
+      accept the visitor.  This can be useful when implementing
+      preorder and postorder traversals.</p>
+
+    <h3>Examples</h3>
+
+    <p>JJTree is distributed with some simple examples
+      containing a grammar that parses arithmetic expressions.  See
+      the file <code>examples/JJTreeExamples/README</code> for further
+      details.</p>
+
+    <p>There is also an interpreter for a simple language that uses
+      JJTree to build the program representation.  See the file
+      <code>examples/Interpreter/README</code> for more
+      information.</p>
+
+    <p>A grammar for HTML 3.2 is also included in the distribution.
+      See <code>examples/HTMLGrammars/RobsHTML/README</code> to find
+      out more.</p>
+
+    <p>Information about an example using the visitor support is in
+      <code>examples/VTransformer/README</code>.</p>
+
+</BODY>
+</HTML>
diff --git a/tools/javacc-4.0/doc/apiroutines.html b/tools/javacc-4.0/doc/apiroutines.html
new file mode 100644
index 0000000000000000000000000000000000000000..49313d7365f5c73b2a5957a887433a11b3043f00
--- /dev/null
+++ b/tools/javacc-4.0/doc/apiroutines.html
@@ -0,0 +1,568 @@
+<HTML>
+<!--
+
+Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+intellectual property rights relating to technology embodied in the product
+that is described in this document. In particular, and without limitation,
+these intellectual property rights may include one or more of the U.S.
+patents listed at http://www.sun.com/patents and one or more additional
+patents or pending patent applications in the U.S. and in other countries.
+U.S. Government Rights - Commercial software. Government users are subject
+to the Sun Microsystems, Inc. standard license agreement and applicable
+provisions of the FAR and its supplements.  Use is subject to license terms.
+Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+product is covered and controlled by U.S. Export Control laws and may be
+subject to the export or import laws in other countries.  Nuclear, missile,
+chemical biological weapons or nuclear maritime end uses or end users, whether
+direct or indirect, are strictly prohibited.  Export or reexport to countries
+subject to U.S. embargo or to entities identified on U.S. export exclusion
+lists, including, but not limited to, the denied persons and specially
+designated nationals lists is strictly prohibited.
+
+-->
+<HEAD>
+ <title>JavaCC API Documentation</title>
+<!-- Changed by: Michael Van De Vanter, 14-Jan-2003 -->
+</HEAD>
+<BODY bgcolor="#FFFFFF" >
+
+<H1>JavaCC [tm]: API Routines</H1>
+
+This web page is a comprehensive list of all classes, methods,
+and variables available for use by a JavaCC [tm] user.  These classes,
+methods, and variables are typically used from the actions that
+are embedded in a JavaCC grammar.  In the sample code used below,
+it is assumed that the name of the generated parser is "TheParser".
+
+<P>
+<HR>
+<P>
+<CENTER>
+<H3>Non-Terminals in the Input Grammar</H3>
+</CENTER>
+<P>
+<HR>
+<P>
+
+For each non-terminal NT in the input grammar file, the following method
+is generated into the parser class:
+<P>
+<UL>
+<LI>
+<STRONG><EM>returntype</EM> NT(<EM>parameters</EM>) throws ParseError;</STRONG>
+</UL>
+
+Here, <EM>returntype</EM> and <EM>parameters</EM> are what were specified
+in the JavaCC input file in the definition of NT (where NT occurred on the
+left-hand side).
+<P>
+When this method is called, the input stream is parsed to match this non-terminal.
+On a successful parse, this method returns normally.  On detection of a parse
+error, an error message is displayed and the method returns by throwing the
+exception ParseError.
+<P>
+<EM>Note that all non-terminals in a JavaCC input grammar have equal status;
+it is possible to parse to any non-terminal by calling the  non-terminal's method.
+</EM>
+
+<P>
+<HR>
+<P>
+<CENTER>
+<H3>API for Parser Actions</H3>
+</CENTER>
+<P>
+<HR>
+<P>
+
+<UL>
+  <LI><STRONG> Token token;</STRONG>
+<BR>
+This variable holds the last token consumed by the parser and can be used
+in parser actions. This is <EM>exactly</EM> the same as the token returned by
+<EM>getToken(0)</EM>.
+
+</UL>
+
+In addition, the two methods - <EM><A href="#getToken">getToken(int i)</A></EM> and
+<EM><A href="#getNextToken">getNextToken()</A></EM> can also be used in
+actions to traverse the token list.
+
+<P>
+<HR>
+<P>
+<CENTER>
+<H3>The Token Manager Interface</H3>
+</CENTER>
+<P>
+<HR>
+<P>
+
+Typically, the token manager interface is not to be used.  Instead all access
+must be made through the parser interface.  However, in certain situations -
+such as if you are not building a parser and building only the token manager -
+the token manager interface is useful.
+The token manager provides the following routine:
+<UL>
+<LI>
+<STRONG>Token getNextToken() throws ParseError;</STRONG>
+</UL>
+
+Each call to this method returns the next token in the input stream. This
+method throws a ParseError exception when there is a lexical error, i.e.,
+it could not find a match for any of the specified tokens from the input
+stream.  The type Token is described later.
+
+<P>
+<HR>
+<P>
+<CENTER>
+<H3>Constructors and Other Initialization Routines</H3>
+</CENTER>
+<P>
+<HR>
+<P>
+
+<UL>
+<LI>
+<STRONG>TheParser.TheParser(java.io.InputStream stream)</STRONG>
+<BR>
+This creates a new parser object, which in turn creates a new token manager object
+that reads its tokens from "stream".  This constructor is available only
+when both the options USER_TOKEN_MANAGER and USER_CHAR_STREAM are false.
+If the option STATIC is true, this constructor (along with other constructors)
+can be called exactly once to create a single parser object.
+
+<P>
+<LI>
+<STRONG>TheParser.TheParser(CharStream stream)</STRONG>
+<BR>
+Similar to the previous constructor, except that this one is available only
+when the option USER_TOKEN_MANAGER is false and USER_CHAR_STREAM is true.
+
+<P>
+<LI>
+<STRONG>void TheParser.ReInit(java.io.InputStream stream)</STRONG>
+<BR>
+This reinitializes an existing parser object.  In addition, it also reinitializes
+the existing token manager object that corresponds to this parser object.  The result
+is a parser object with the exact same functionality as one that was created
+with the constructor above.  The only difference is that new objects are not
+created.  This method is available only
+when both the options USER_TOKEN_MANAGER and USER_CHAR_STREAM are false.
+If the option STATIC is true, this (along with the other ReInit methods)
+is the only way to restart a parse operation
+for there is only one parser and all one can do is reinitialize it.
+
+<P>
+<LI>
+<STRONG>void TheParser.ReInit(CharStream stream)</STRONG>
+<BR>
+Similar to the previous method, except that this one is available only
+when the option USER_TOKEN_MANAGER is false and USER_CHAR_STREAM is true.
+
+<P>
+<LI>
+<STRONG>TheParser(TheParserTokenManager tm)</STRONG>
+This creates a new parser object which uses an already created token manager object "tm" as
+its token manager.  This constructor is only available if option USER_TOKEN_MANAGER is
+false.  If the option STATIC is true, this constructor (along with other constructors)
+can be called exactly once to create a single parser object.
+
+<P>
+<LI>
+<STRONG>TheParser(TokenManager tm)</STRONG>
+<BR>
+Similar to the previous constructor, except that this one is available only
+when the option USER_TOKEN_MANAGER is true.
+
+<P>
+<LI>
+<STRONG>void TheParser.ReInit(TheParserTokenManager tm)</STRONG>
+<BR>
+This reinitializes an existing parser object with the token manager object "tm" as its
+new token manager.  This method is only available if option USER_TOKEN_MANAGER is
+false.  If the option STATIC is true, this (along with the other ReInit methods)
+is the only way to restart a parse operation
+for there is only one parser and all one can do is reinitialize it.
+
+<P>
+<LI>
+<STRONG>void TheParser.ReInit(TokenManager tm)</STRONG>
+<BR>
+Similar to the previous method, except that this one is available only
+when the option USER_TOKEN_MANAGER is true.
+
+<P>
+<LI>
+<STRONG>TheParserTokenManager.TheParserTokenManager(CharStream stream)</STRONG>
+<BR>
+Creates a new token manager object initialized to read input from "stream".  When
+the option STATIC is true, this constructor may be called only once.
+This is available only when USER_TOKEN_MANAGER is false and USER_CHAR_STREAM
+is true.  When USER_TOKEN_MANAGER is false and USER_CHAR_STREAM is false (the default situation),
+a constructor similar to the one above is available with the type CharStream
+replaced as follows:
+<UL>
+<LI>
+When JAVA_UNICODE_ESCAPE is false and UNICODE_INPUT is false, CharStream is
+replaced by ASCII_CharStream.
+<LI>
+When JAVA_UNICODE_ESCAPE is false and UNICODE_INPUT is true, CharStream is
+replaced by UCode_CharStream.
+<LI>
+When JAVA_UNICODE_ESCAPE is true and UNICODE_INPUT is false, CharStream is
+replaced by ASCII_UCodeESC_CharStream.
+<LI>
+When JAVA_UNICODE_ESCAPE is true and UNICODE_INPUT is true, CharStream is
+replaced by UCode_UCodeESC_CharStream.
+</UL>
+
+<P>
+<LI>
+<STRONG>void TheParserTokenManager.ReInit(CharStream stream)</STRONG>
+<BR>
+Reinitializes the current token manager object to read input from "stream".  When
+the option STATIC is true, this is the only way to restart a token manager operation.
+This is available only when USER_TOKEN_MANAGER is false and USER_CHAR_STREAM
+is true.  When USER_TOKEN_MANAGER is false and USER_CHAR_STREAM is false (the default situation),
+a constructor similar to the one above is available with the type CharStream
+replaced as follows:
+<UL>
+<LI>
+When JAVA_UNICODE_ESCAPE is false and UNICODE_INPUT is false, CharStream is
+replaced by ASCII_CharStream.
+<LI>
+When JAVA_UNICODE_ESCAPE is false and UNICODE_INPUT is true, CharStream is
+replaced by UCode_CharStream.
+<LI>
+When JAVA_UNICODE_ESCAPE is true and UNICODE_INPUT is false, CharStream is
+replaced by ASCII_UCodeESC_CharStream.
+<LI>
+When JAVA_UNICODE_ESCAPE is true and UNICODE_INPUT is true, CharStream is
+replaced by UCode_UCodeESC_CharStream.
+</UL>
+</UL>
+
+<P>
+<HR>
+<P>
+<CENTER>
+<H3>The Token Class</H3>
+</CENTER>
+<P>
+<HR>
+<P>
+
+The Token class is the type of token objects that are created by the token manager
+after a successful scanning of the token stream.  These token objects are then
+passed to the parser and are accessible to the actions in a JavaCC grammar usually
+by grabbing the return value of a token.  The methods getToken and getNextToken
+described below also give access to objects of this type.
+<P>
+Each Token object has the following fields:
+<UL>
+<LI>
+<STRONG>int kind;</STRONG>
+<BR>
+This is the index for this kind of token in the internal representation scheme
+of JavaCC.  When tokens in the JavaCC input file are given labels, these labels
+are used to generate "int" constants that can be used in actions.
+The value 0 is always used to represent the predefined token &lt;EOF&gt;.  A
+constant "EOF" is generated for convenience in the ...Constants file.
+<P>
+<LI>
+<STRONG>int beginLine, beginColumn, endLine, endColumn;</STRONG>
+<BR>
+These indicate the beginning and ending positions of the token as it appeared
+in the input stream.
+<P>
+<LI>
+<STRONG>String image;</STRONG>
+<BR>
+This represents the image of the token as it appeared in the input stream.
+<P>
+<LI>
+<STRONG>Token next;</STRONG>
+<BR>
+A reference to the next regular (non-special) token from the input
+stream.  If this is the last token from the input stream, or if the
+token manager has not read tokens beyond this one, this field is
+set to null.
+<P>
+The description in the above paragraph holds only if this token is also a regular
+token.  Otherwise, see below for a description of the contents of
+this field.
+<P>
+Note: There are two kinds of tokens - regular and special.  Regular tokens are
+the normal tokens that are fed to the parser.  Special tokens are other useful
+tokens (like comments) that are not discarded (like white space).  For more
+information on the different kinds of tokens
+<a href="tokenmanager.html">please see the minitutorial on the token manager</a>.
+<P>
+<LI>
+<STRONG>Token specialToken;</STRONG>
+<BR>
+This field is used to access special tokens that occur prior to this
+token, but after the immediately preceding regular (non-special) token.
+If there are no such special tokens, this field is set to null.
+When there are more than one such special token, this field refers
+to the last of these special tokens, which in turn refers to the next
+previous special token through its specialToken field, and so on
+until the first special token (whose specialToken field is null).
+The next fields of special tokens refer to other special tokens that
+immediately follow it (without an intervening regular token).  If there
+is no such token, this field is null.
+<P>
+<LI>
+<STRONG>static final Token newToken(int ofKind);</STRONG>
+<BR>
+Returns a new token object as its default behavior.  If you wish to
+perform special actions when a token is constructed or create subclasses
+of class Token and instantiate them instead, you can redefine this method
+appropriately.  The only constraint is that this method returns a <EM>new</EM>
+object of type Token (or a subclass of Token).
+</UL>
+
+<P>
+<HR>
+<P>
+<CENTER>
+<H3>Reading Tokens from the Input Stream</H3>
+</CENTER>
+<P>
+<HR>
+<P>
+
+There are two methods available for this purpose:
+<UL>
+<LI>
+<STRONG><A name="getNextToken">Token TheParser.getNextToken() throws ParseError</a></STRONG>
+<BR>
+This method returns the next available token in the input stream and moves
+the token pointer one step in the input stream (i.e., this changes the state
+of the input stream).  If there are no more tokens available in the input
+stream, the exception ParseError is thrown.  Care must be taken when calling
+this method since it can interfere with the parser's knowledge of the state
+of the input stream, current token, etc.
+<P>
+<LI>
+<STRONG><A name="getToken">Token TheParser.getToken(int index) throws ParseError</a></STRONG>
+<BR>
+This method returns the index-th token from the current token ahead in the
+token stream.  If index is 0, it returns the current token (the last token
+returned by getNextToken or consumed by the parser); if index is 1, it returns
+the next token (the next token that will be returned by getNextToken of consumed
+by the parser) and so on.  The index parameter cannot be negative.  This method
+does not change the input stream pointer (i.e., it does not change the
+state of the input stream).  If an attempt is made to access a token beyond the
+last available token, the exception ParseError is thrown.
+If this method is called from a semantic lookahead specification, which in turn
+is called during a lookahead determination process, the current token is temporarily
+adjusted to be the token currently being inspected by the lookahead process.
+For more details,
+<a href="lookahead.html">please see the minitutorial on using lookahead</a>.
+</UL>
+
+<P>
+<HR>
+<P>
+<CENTER>
+<H3>Working with Debugger Tracing</H3>
+</CENTER>
+<P>
+<HR>
+<P>
+
+When you generate parsers with the options DEBUG_PARSER or DEBUG_LOOKAHEAD, these
+parsers produce a trace of their activity which is printed to the user console.
+You can insert calls to the following methods to control this tracing activity:
+<P>
+<UL>
+<LI>
+<STRONG>void TheParser.enable_tracing()</STRONG>
+<P>
+<LI>
+<STRONG>void TheParser.disable_tracing()</STRONG>
+<P>
+</UL>
+<P>
+For convenience, these methods are available even when you build parsers without
+the debug options.  In this case, these methods are no-ops.  Hence you can
+permanently leave these methods in your code and they automatically kick in when
+you use the debug options.
+<P>
+<HR>
+<P>
+<CENTER>
+<H3>Customizing Error Messages</H3>
+</CENTER>
+<P>
+<HR>
+<P>
+To help the user in customizing error messages generated by the parser and lexer, the
+user is offered the facilities described in this section.  In the case of the
+parser, these facilities are only available if the option ERROR_REPORTING is
+true, while in the case of the lexer, these facilities are always available.
+<P>
+The parser contains the following method definition:
+<UL>
+<LI>
+<STRONG>protected void token_error() { ... }</STRONG>
+</UL>
+<P>
+To customize error reporting by the parser, the parser class must be subclassed
+and this method redefined in the subclass.  To help with creating your
+error reporting scheme, the following variables are available:
+<P>
+<UL>
+<LI>
+<STRONG>protected int error_line, error_column;</STRONG>
+<BR>
+The line and column where the error was detected.
+<P>
+<LI>
+<STRONG>protected String error_string;</STRONG>
+<BR>
+The image of the offending token or set of tokens.  When a lookahead of more
+than 1 is used, more than one token may be present here.
+<P>
+<LI>
+<STRONG>protected String[] expected_tokens;</STRONG>
+<BR>
+An array of images of legitimate token sequences.  Here again, each legitimate
+token sequence may be more than just one token when a lookahead of more than
+1 is used.
+</UL>
+<P>
+The lexer contains the following method definition:
+<UL>
+<LI>
+<STRONG>protected void LexicalError() { ... }</STRONG>
+</UL>
+<P>
+To customize error reporting by the lexer, the lexer class must be subclassed
+and this method redefined in the subclass.  To help with creating your
+error reporting scheme, the following variables are available:
+<P>
+<UL>
+<LI>
+<STRONG>protected int error_line, error_column;</STRONG>
+<BR>
+The line and column where the error was detected.
+<P>
+<LI>
+<STRONG>protected String error_after;</STRONG>
+<BR>
+The partial string that has been read since the last successful token
+match was performed.
+<P>
+<LI>
+<STRONG>protected char curChar;</STRONG>
+<BR>
+The offending character.
+</UL>
+
+<hr>
+<h1>JavaCC [tm]: JJTree</h1>
+<hr>
+
+<p>JJTree has two APIs: it adds some <a href="#jjtree-state">parser
+methods</a>; and it requires all node objects to implement the <a
+href="#jjtree-node">Node</a> interface.</p>
+
+<h2><a name="jjtree-state">JJTree parser methods</a></h2>
+
+<p>JJTree maintains some state in the parser object itself.  It
+encapsulates all this state with an object that can be referred to via
+the <code>jjtree</code> field.</p>
+
+<p>The parser state implements an open stack where nodes are held
+until they can be added to their parent node.  The <code>jjtree</code>
+state object provides methods for you to manipulate the contents of
+the stack in your actions if the basic JJTree mechanisms are not
+sufficient.</p>
+
+<dl>
+      <dt><strong><code>void reset()</code></strong></dt>
+      
+      <dd>Call this to reinitialize the node stack.  All nodes
+      currently on the stack are thrown away.  Don't call this from
+      within a node scope, or terrible things will surely happen.</dd>
+
+      <dt><strong><code>Node rootNode();</code></strong></dt>
+
+      <dd>Returns the root node of the AST.  Since JJTree operates
+      bottom-up, the root node is only defined after the parse has
+      finished.</dd>
+
+      <dt><strong><code>boolean nodeCreated();</code></strong></dt>
+
+      <dd>Determines whether the current node was actually closed and
+      pushed.  Call this in the final action within a conditional node
+      scope.</dd>
+
+      <dt><strong><code>int arity();</code></strong></dt>
+
+      <dd>Returns the number of nodes currently pushed on the node
+      stack in the current node scope.</dd>
+
+      <dt><strong><code>void pushNode(Node n);</code></strong></dt>
+
+      <dd>Pushes a node on to the stack.</dd>
+
+      <dt><strong><code>Node popNode();</code></strong></dt>
+
+      <dd>Returns the node on the top of the stack, and removes it from
+      the stack.</dd>
+
+      <dt><strong><code>Node peekNode();</code></strong></dt>
+
+      <dd>Returns the node currently on the top of the stack.</dd>
+    </dl>
+
+<hr>
+
+<h2>The <strong><code><a name="jjtree-node">Node</a></code></strong> interface</h2>
+
+<p>All AST nodes must implement this interface.  It provides basic
+machinery for constructing the parent and child relationships between
+nodes.</p>
+
+<dl>
+      <dt><strong><code>public void jjtOpen();</code></strong></dt>
+
+      <dd>This method is called after the node has been made the
+      current node.  It indicates that child nodes can now be added to
+      it.</dd>
+
+      <dt><strong><code>public void jjtClose();</code></strong></dt>
+
+      <dd>This method is called after all the child nodes have been
+	added.</dd>
+
+      <dt><strong><code>public void jjtSetParent(Node n);</code><br><code>public Node jjtGetParent();</code></strong></dt>
+
+      <dd>This pair of methods is used to inform the node of its
+      parent.</dd>
+
+      <dt><strong><code>public void jjtAddChild(Node n, int i);</code></strong></dt>
+
+      <dd>This method tells the node to add its argument to the node's
+	list of children.</dd>
+
+      <dt><strong><code>public Node jjtGetChild(int i);</code></strong></dt>
+
+      <dd>This method returns a child node.  The children are numbered
+	 from zero, left to right.</dd>
+
+      <dt><strong><code>int jjtGetNumChildren();</code></strong></dt>
+
+      <dd>Return the number of children the node has.</dd>
+
+</dl>
+
+</BODY>
+</HTML>
diff --git a/tools/javacc-4.0/doc/commandline.html b/tools/javacc-4.0/doc/commandline.html
new file mode 100644
index 0000000000000000000000000000000000000000..1f27d528193f55c57201a818021bd7d64d09f5e1
--- /dev/null
+++ b/tools/javacc-4.0/doc/commandline.html
@@ -0,0 +1,114 @@
+<HTML>
+<!--
+
+Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+intellectual property rights relating to technology embodied in the product
+that is described in this document. In particular, and without limitation,
+these intellectual property rights may include one or more of the U.S.
+patents listed at http://www.sun.com/patents and one or more additional
+patents or pending patent applications in the U.S. and in other countries.
+U.S. Government Rights - Commercial software. Government users are subject
+to the Sun Microsystems, Inc. standard license agreement and applicable
+provisions of the FAR and its supplements.  Use is subject to license terms.
+Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+product is covered and controlled by U.S. Export Control laws and may be
+subject to the export or import laws in other countries.  Nuclear, missile,
+chemical biological weapons or nuclear maritime end uses or end users, whether
+direct or indirect, are strictly prohibited.  Export or reexport to countries
+subject to U.S. embargo or to entities identified on U.S. export exclusion
+lists, including, but not limited to, the denied persons and specially
+designated nationals lists is strictly prohibited.
+
+-->
+<HEAD>
+ <title>JavaCC Command Line Syntax</title>
+<!-- Changed by: Michael Van De Vanter, 14-Jan-2003 -->
+</HEAD>
+<BODY bgcolor="#FFFFFF" >
+
+<H1>JavaCC [tm]: Command Line Syntax</H1>
+
+First, you can obtain a synopsis of the command line syntax by simply
+typing "javacc".  This is what you get:
+<P>
+<PRE>
+% javacc
+<<< Version and copyright info>>>
+
+Usage:
+    javacc option-settings inputfile
+
+"option-settings" is a sequence of settings separated by spaces.
+Each option setting must be of one of the following forms:
+
+    -optionname=value (e.g., -STATIC=false)
+    -optionname:value (e.g., -STATIC:false)
+    -optionname       (equivalent to -optionname=true.  e.g., -STATIC)
+    -NOoptionname     (equivalent to -optionname=false. e.g., -NOSTATIC)
+
+Option settings are not case-sensitive, so one can say "-nOsTaTiC" instead
+of "-NOSTATIC".  Option values must be appropriate for the corresponding
+option, and must be either an integer, a boolean, or a string value.
+
+The integer valued options are:
+
+    LOOKAHEAD              (default 1)
+    CHOICE_AMBIGUITY_CHECK (default 2)
+    OTHER_AMBIGUITY_CHECK  (default 1)
+
+The boolean valued options are:
+
+    STATIC                 (default true)
+    DEBUG_PARSER           (default false)
+    DEBUG_LOOKAHEAD        (default false)
+    DEBUG_TOKEN_MANAGER    (default false)
+    OPTIMIZE_TOKEN_MANAGER (default true)
+    ERROR_REPORTING        (default true)
+    JAVA_UNICODE_ESCAPE    (default false)
+    UNICODE_INPUT          (default false)
+    IGNORE_CASE            (default false)
+    COMMON_TOKEN_ACTION    (default false)
+    USER_TOKEN_MANAGER     (default false)
+    USER_CHAR_STREAM       (default false)
+    BUILD_PARSER           (default true)
+    BUILD_TOKEN_MANAGER    (default true)
+    TOKEN_MANAGER_USES_PARSER (default false)
+    SANITY_CHECK           (default true)
+    FORCE_LA_CHECK         (default false)
+    CACHE_TOKENS           (default false)
+    KEEP_LINE_COLUMN       (default true)
+
+The string valued options are:
+
+    OUTPUT_DIRECTORY       (default Current Directory)
+
+EXAMPLE:
+    javacc -STATIC=false -LOOKAHEAD:2 -debug_parser mygrammar.jj
+
+ABOUT JavaCC:
+
+    JavaCC is a parser generator for the Java [tm] programming
+    language originally built by
+    Sriram Sankar (http://www.cs.stanford.edu/~sankar) and
+    Sreeni Viswanadha (http://www.cs.albany.edu/~sreeni).
+
+%
+</PRE>
+<P>
+The above help message pretty much explains everything.  The options are
+explained in detail in
+<A HREF="javaccgrm.html#prod2">the description of the JavaCC
+input syntax (click here)</A>.
+<P>
+Any option may be set either on the command line as shown in the help message
+above, or in the grammar file as describe in
+<A HREF="javaccgrm.html">the JavaCC input file syntax document</A>.
+The effect is exactly the same.  If the same option is set in both the
+command line and the grammar file, then the option setting in the command
+line takes precedence.
+<P>
+
+</BODY>
+</HTML>
diff --git a/tools/javacc-4.0/doc/docindex.html b/tools/javacc-4.0/doc/docindex.html
new file mode 100644
index 0000000000000000000000000000000000000000..bd5dbd89db140dd6eee5b87fd4de93559d7a04fe
--- /dev/null
+++ b/tools/javacc-4.0/doc/docindex.html
@@ -0,0 +1,105 @@
+<HTML>
+<!--
+
+Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+intellectual property rights relating to technology embodied in the product
+that is described in this document. In particular, and without limitation,
+these intellectual property rights may include one or more of the U.S.
+patents listed at http://www.sun.com/patents and one or more additional
+patents or pending patent applications in the U.S. and in other countries.
+U.S. Government Rights - Commercial software. Government users are subject
+to the Sun Microsystems, Inc. standard license agreement and applicable
+provisions of the FAR and its supplements.  Use is subject to license terms.
+Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+product is covered and controlled by U.S. Export Control laws and may be
+subject to the export or import laws in other countries.  Nuclear, missile,
+chemical biological weapons or nuclear maritime end uses or end users, whether
+direct or indirect, are strictly prohibited.  Export or reexport to countries
+subject to U.S. embargo or to entities identified on U.S. export exclusion
+lists, including, but not limited to, the denied persons and specially
+designated nationals lists is strictly prohibited.
+
+-->
+<HEAD>
+ <title>JavaCC Documentation Index</title>
+<!-- Changed by: Michael Van De Vanter, 14-Jan-2003 -->
+</HEAD>
+<BODY bgcolor="#FFFFFF" >
+
+<H1>JavaCC [tm]: Documentation Index</H1>
+
+By following the links from this page you should be able to obtain all
+necessary documentation on JavaCC [tm].
+
+<P>
+If you have further questions, please do not hesitate to
+<a href="mailinglist.html">contact us</a>.
+We recommend the following step-by-step process to learning JavaCC:
+<UL>
+<LI>
+Go through the simple examples that are available as part of the Java Compiler
+Compiler [tm] release.  This is located under the <code>examples</code> directory in a
+directory called <code>SimpleExamples</code>.  Read the file
+<A HREF="simpleREADME.html"><code>README</code></A>
+in this directory for complete instructions.
+<P>
+<LI>
+Go through the tree building examples (that use JJTree) that are also available
+as part of the JavaCC release.  This is located under the <code>examples</code> directory in a
+directory called <code>JJTreeExamples</code>.  Read the file
+<A HREF="jjtreeREADME.html"><code>README</code></A>
+in this directory for complete instructions.
+<P>
+<LI>
+Study the description of
+<A HREF="javaccgrm.html">the JavaCC grammar file</A>.
+This provides the complete syntax of the grammar file along with a detailed
+description of these constructs.  There are also many examples in the <a href="http://javacc.dev.java.net/servlets/ProjectDocumentList?folderID=110">grammar repository</a>.
+<P>
+<LI>
+<A HREF="commandline.html">Click here</A> to see the document that describes the
+command line input syntax.
+<P>
+<LI>
+The <A HREF="apiroutines.html">JavaCC API routines</A> are a bunch of classes,
+methods, and variables which may be accessed from user code (typically from
+<A NAME="javaccgrm.html#prod22">actions - the <EM>java_block</EM> in the syntax</A>).
+<P>
+<LI>
+<A HREF="JJTree.html">Click here</A> to get to the JJTree documentation.
+<P>
+<LI>
+<A HREF="JJDoc.html">Click here</A> to get to the JJDoc documentation.
+<P>
+<LI>
+Detailed JavaCC documentation is organized as a set
+of <em>minitutorials</em>, each on a separate topic.  The following
+minitutorials are currently available:
+<P>
+<UL>
+<LI>
+<A HREF="lookahead.html">Lookahead MiniTutorial</A>:
+This is a complete guide to how lookahead processing is performed and provides
+tips on how to insert local lookahead specifications.
+<P>
+<LI>
+<A HREF="tokenmanager.html">Token Manager MiniTutorial</A>:
+This is a description to how the token manager works.
+<P>
+<LI>
+<A HREF="errorrecovery.html">Customizing Error Messages and Recovering From Errors</A>:
+This document describes how you can customize error messages and also recover
+from errors during parsing.
+<P>
+<LI>
+<A HREF="CharStream.html">Using the Default Character Stream Readers</A>:
+This document describes the various ways in which you can use the default
+character stream reader classes that are generated by JavaCC.
+</UL>
+<P>
+</UL>
+
+</BODY>
+</HTML>
diff --git a/tools/javacc-4.0/doc/errorrecovery.html b/tools/javacc-4.0/doc/errorrecovery.html
new file mode 100644
index 0000000000000000000000000000000000000000..5394c5494ffc58caf116ab2cd95584b194370e4f
--- /dev/null
+++ b/tools/javacc-4.0/doc/errorrecovery.html
@@ -0,0 +1,270 @@
+<HTML>
+<!--
+
+Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+intellectual property rights relating to technology embodied in the product
+that is described in this document. In particular, and without limitation,
+these intellectual property rights may include one or more of the U.S.
+patents listed at http://www.sun.com/patents and one or more additional
+patents or pending patent applications in the U.S. and in other countries.
+U.S. Government Rights - Commercial software. Government users are subject
+to the Sun Microsystems, Inc. standard license agreement and applicable
+provisions of the FAR and its supplements.  Use is subject to license terms.
+Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+product is covered and controlled by U.S. Export Control laws and may be
+subject to the export or import laws in other countries.  Nuclear, missile,
+chemical biological weapons or nuclear maritime end uses or end users, whether
+direct or indirect, are strictly prohibited.  Export or reexport to countries
+subject to U.S. embargo or to entities identified on U.S. export exclusion
+lists, including, but not limited to, the denied persons and specially
+designated nationals lists is strictly prohibited.
+
+-->
+<HEAD>
+ <title>JavaCC: Error Reporting and Recovery</title>
+<!-- Changed by: Michael Van De Vanter, 14-Jan-2003 -->
+</HEAD>
+<BODY bgcolor="#FFFFFF" >
+
+<H1>JavaCC [tm]: Error Reporting and Recovery</H1>
+
+<PRE>
+This is a rough document describing the new error recovery features in
+Version 0.7.1.  This document also describes how features have changed
+since Version 0.6.
+
+The first change (from 0.6) is that we have two new exceptions:
+
+    . ParseException
+    . TokenMgrError
+
+Whenever the token manager detects a problem, it throws the exception
+TokenMgrError.  Previously, it used to print the message:
+
+  Lexical Error ...
+
+following which it use to throw the exception ParseError.
+
+Whenever the parser detects a problem, it throws the exception
+ParseException.  Previously, it used to print the message:
+
+  Encountered ... Was expecting one of ...
+
+following which it use to throw the exception ParseError.
+
+In Version 0.7.1, error messages are never printed explicitly,
+rather this information is stored inside the exception objects that
+are thrown.  Please see the classes ParseException.java and
+TokenMgrError.java (that get generated by JavaCC [tm] during parser
+generation) for more details.
+
+If the thrown exceptions are never caught, then a standard action is
+taken by the virtual machine which normally includes printing the
+stack trace and also the result of the "toString" method in the
+exception.  So if you do not catch the JavaCC exceptions, a message
+quite similar to the ones in Version 0.6.
+
+But if you catch the exception, you must print the message yourself.
+
+Exceptions in the Java [tm] programming language are all subclasses of
+type Throwable.  Furthermore, exceptions are divided into two broad
+categories - ERRORS and other exceptions.
+
+Errors are exceptions that one is not expected to recover from -
+examples of these are ThreadDeath or OutOfMemoryError.  Errors are
+indicated by subclassing the exception "Error".  Exceptions subclassed
+from Error need not be specified in the "throws" clause of method
+declarations.
+
+Exceptions other than errors are typically defined by subclassing the
+exception "Exception".  These exceptions are typically handled by the
+user program and must be declared in throws clauses of method
+declarations (if it is possible for the method to throw that
+exception).
+
+The exception TokenMgrError is a subclass of Error, while the
+exception ParseException is a subclass of Exception.  The reasoning
+here is that the token manager is never expected to throw an exception
+- you must be careful in defining your token specifications such that
+you cover all cases.  Hence the suffix "Error" in TokenMgrError.  You
+do not have to worry about this exception - if you have designed your
+tokens well, it should never get thrown.  Whereas it is typical to
+attempt recovery from Parser errors - hence the name "ParseException".
+(Although if you still want to recover from token manager errors, you
+can do it - it's just that you are not forced to catch them.)
+
+In Version 0.7.1, we have added a syntax to specify additional exceptions
+that may be thrown by methods corresponding to non-terminals.  This
+syntax is identical to the Java "throws ..." syntax.  Here's an
+example of how you use this:
+
+  void VariableDeclaration() throws SymbolTableException, IOException :
+  {...}
+  {
+    ...
+  }
+
+Here, VariableDeclaration is defined to throw exceptions
+SymbolTableException and IOException in addition to ParseException.
+
+Error Reporting:
+
+The scheme for error reporting is simpler in Version 0.7.1 (as compared
+to Version 0.6) - simply modify the file ParseException.java to do
+what you want it to do.  Typically, you would modify the getMessage
+method to do your own customized error reporting.  All information
+regarding these methods can be obtained from the comments in the
+generated files ParseException.java and TokenMgrError.java.  It will
+also help to understand the functionality of the class Throwable (read
+a Java book for this).
+
+There is a method in the generated parser called
+"generateParseException".  You can call this method anytime you wish
+to generate an object of type ParseException.  This object will
+contain all the choices that the parser has attempted since the last
+successfully consumed token.
+
+Error Recovery:
+
+JavaCC offers two kinds of error recovery - shallow recovery and deep
+recovery.  Shallow recovery recovers if none of the current choices
+have succeeded in being selected, while deep recovery is when a choice
+is selected, but then an error happens sometime during the parsing of
+this choice.
+
+Shallow Error Recovery:
+
+We shall explain shallow error recovery using the following example:
+
+void Stm() :
+{}
+{
+  IfStm()
+|
+  WhileStm()
+}
+
+Let's assume that IfStm starts with the reserved word "if" and WhileStm
+starts with the reserved word "while".  Suppose you want to recover by
+skipping all the way to the next semicolon when neither IfStm nor WhileStm
+can be matched by the next input token (assuming a lookahead of 1).  That
+is the next token is neither "if" nor "while".
+
+What you do is write the following:
+
+void Stm() :
+{}
+{
+  IfStm()
+|
+  WhileStm()
+|
+  error_skipto(SEMICOLON)
+}
+
+But you have to define "error_skipto" first.  So far as JavaCC is concerned,
+"error_skipto" is just like any other non-terminal.  The following is one
+way to define "error_skipto" (here we use the standard JAVACODE production):
+
+JAVACODE
+void error_skipto(int kind) {
+  ParseException e = generateParseException();  // generate the exception object.
+  System.out.println(e.toString());  // print the error message
+  Token t;
+  do {
+    t = getNextToken();
+  } while (t.kind != kind);
+    // The above loop consumes tokens all the way up to a token of
+    // "kind".  We use a do-while loop rather than a while because the
+    // current token is the one immediately before the erroneous token
+    // (in our case the token immediately before what should have been
+    // "if"/"while".
+}
+
+That's it for shallow error recovery.  In a future version of JavaCC
+we will have support for modular composition of grammars.  When this
+happens, one can place all these error recovery routines into a
+separate module that can be "imported" into the main grammar module.
+We intend to supply a library of useful routines (for error recovery
+and otherwise) when we implement this capability.
+
+Deep Error Recovery:
+
+Let's use the same example that we did for shallow recovery:
+
+void Stm() :
+{}
+{
+  IfStm()
+|
+  WhileStm()
+}
+
+In this case we wish to recover in the same way.  However, we wish to
+recover even when there is an error deeper into the parse.  For
+example, suppose the next token was "while" - therefore the choice
+"WhileStm" was taken.  But suppose that during the parse of WhileStm
+some error is encountered - say one has "while (foo { stm; }" - i.e., the
+closing parentheses has been missed.  Shallow recovery will not work
+for this situation.  You need deep recovery to achieve this.  For this,
+we offer a new syntactic entity in JavaCC - the try-catch-finally block.
+
+First, let us rewrite the above example for deep error recovery and then
+explain the try-catch-finally block in more detail:
+
+void Stm() :
+{}
+{
+  try {
+    (
+      IfStm()
+    |
+      WhileStm()
+    )
+  catch (ParseException e) {
+    error_skipto(SEMICOLON);
+  }
+}
+
+That's all you need to do.  If there is any unrecovered error during the
+parse of IfStm or WhileStm, then the catch block takes over.  You can
+have any number of catch blocks and also optionally a finally block
+(just as with Java errors).  What goes into the catch blocks is *Java code*,
+not JavaCC expansions.  For example, the above example could have been
+rewritten as:
+
+void Stm() :
+{}
+{
+  try {
+    (
+      IfStm()
+    |
+      WhileStm()
+    )
+  catch (ParseException e) {
+    System.out.println(e.toString());
+    Token t;
+    do {
+      t = getNextToken();
+    } while (t.kind != SEMICOLON);
+  }
+}
+
+Our belief is that it's best to avoid placing too much Java code in the
+catch and finally blocks since it overwhelms the grammar reader.  Its best
+to define methods that you can then call from the catch blocks.
+
+Note that in the second writing of the example, we essentially copied
+the code out of the implementation of error_skipto.  But we left out the
+first statement - the call to generateParseException.  That's because in
+this case, the catch block already provides us with the exception.  But
+even if you did call this method, you will get back an identical object.
+
+</PRE>
+<P>
+
+</BODY>
+</HTML>
diff --git a/tools/javacc-4.0/doc/features.html b/tools/javacc-4.0/doc/features.html
new file mode 100644
index 0000000000000000000000000000000000000000..df45b1893514660fc35392c02660add7d02c3e99
--- /dev/null
+++ b/tools/javacc-4.0/doc/features.html
@@ -0,0 +1,148 @@
+<HTML>
+<!--
+
+Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+intellectual property rights relating to technology embodied in the product
+that is described in this document. In particular, and without limitation,
+these intellectual property rights may include one or more of the U.S.
+patents listed at http://www.sun.com/patents and one or more additional
+patents or pending patent applications in the U.S. and in other countries.
+U.S. Government Rights - Commercial software. Government users are subject
+to the Sun Microsystems, Inc. standard license agreement and applicable
+provisions of the FAR and its supplements.  Use is subject to license terms.
+Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+product is covered and controlled by U.S. Export Control laws and may be
+subject to the export or import laws in other countries.  Nuclear, missile,
+chemical biological weapons or nuclear maritime end uses or end users, whether
+direct or indirect, are strictly prohibited.  Export or reexport to countries
+subject to U.S. embargo or to entities identified on U.S. export exclusion
+lists, including, but not limited to, the denied persons and specially
+designated nationals lists is strictly prohibited.
+
+-->
+<HEAD>
+ <title>JavaCC Features</title>
+<!-- Changed by: Michael Van De Vanter, 14-Jan-2003 -->
+</HEAD>
+<BODY bgcolor="#FFFFFF" >
+
+<H1>JavaCC [tm]: Features</H1>
+
+JavaCC [tm] is a Java parser generator written in the Java programming language.  It produces pure
+Java code.  Both JavaCC and the parsers generated by JavaCC have been
+run on a variety of Java platforms.  JavaCC comes with a bunch of
+grammars including Java 1.0.2, Java 1.1, and Java 2 as well as a couple
+of HTML grammars.
+<P>
+Specific features of JavaCC are listed below:
+<UL>
+<LI>
+TOP-DOWN: JavaCC generates top-down (recursive descent) parsers as
+opposed to bottom-up parsers generated by YACC-like tools.  This
+allows the use of more general grammars (although left-recursion is
+disallowed).  Top-down parsers have a bunch of other advantages
+(besides more general grammars) such as being easier to debug,
+having the ability to parse to any non-terminal in the grammar, and also having the
+ability to pass values (attributes) both up and down the parse
+tree during parsing.
+<P>
+<LI>
+LARGE USER COMMUNITY: JavaCC is by far the most popular parser
+generator used with Java applications.  We've had over hundreds of
+thousands of downloads and estimate serious users in the many thousands
+(maybe even tens of thousands).  Our <a href="mailinglist.html">mailing
+list</a> and newsgroups together have a few thousand participants.
+<P>
+<LI>
+LEXICAL AND GRAMMAR SPECIFICATIONS IN ONE FILE: The lexical
+specifications such as regular expressions, strings, etc. and the
+grammar specifications (the BNF) are both written together in the same
+file.  It makes grammars easier to read (since it is possible to use
+regular expressions inline in the grammar specification) and also
+easier to maintain.
+<P>
+<LI>
+TREE BUILDING PREPROCESSOR:  JavaCC comes with JJTree, an extremely
+powerful tree building preprocessor.
+<P>
+<LI>
+EXTREMELY CUSTOMIZABLE: JavaCC offers many different options to
+customize its behavior and the behavior of the generated parsers.
+Examples of such options are the kinds of Unicode processing to
+perform on the input stream, the number of tokens of ambiguity
+checking to perform, etc. etc.
+<P>
+<LI>
+CERTIFIED TO BE 100% PURE JAVA:  JavaCC runs on all Java compliant
+platforms Version 1.1 or later.  It has been used on countless different
+machines with no special porting effort - a testimonial to the
+"Write Once, Run Everywhere" aspect of the Java [tm] programming language.
+<P>
+<LI>
+DOCUMENT GENERATION: JavaCC includes a tool called JJDoc that
+converts grammar files to documentation files (optionally in html).
+<P>
+<LI>
+MANY MANY EXAMPLES:  The JavaCC release includes a wide range of
+examples including Java and HTML grammars.  The examples, along with
+their documentation, are a great way to get acquainted with JavaCC.
+<P>
+<LI>
+INTERNATIONALIZED: The lexical analyzer of JavaCC can handle full
+Unicode input, and lexical specifications may also include any
+Unicode character.  This facilitates descriptions of language elements
+such as Java identifiers that allow certain Unicode characters (that are
+not ASCII), but not others.
+<P>
+<LI>
+SYNTACTIC AND SEMANTIC LOOKAHEAD SPECIFICATIONS: By default, JavaCC
+generates an LL(1) parser.  However, there may be portions of the grammar
+that are not LL(1).  JavaCC offers the capabilities of syntactic and
+semantic lookahead to resolve shift-shift ambiguities locally at these
+points.  For example, the parser is LL(k) only at such points, but remains LL(1)
+everywhere else for better performance.  Shift-reduce and reduce-reduce
+conflicts are not an issue for top-down parsers.
+<P>
+<LI>
+PERMITS EXTENDED BNF SPECIFICATIONS: JavaCC allows extended BNF
+specifications - such as <code>(A)*</code>, <code>(A)+</code>, etc. - within the lexical and
+the grammar specifications.  Extended BNF relieves the need for
+left-recursion to some extent.  In fact, extended BNF is often easier
+to read as in <code>A ::= y(x)*</code> versus <code>A ::= Ax|y</code>.
+<P>
+<LI>
+LEXICAL STATES AND LEXICAL ACTIONS:  JavaCC offers <I>lex</I>-like lexical
+state and lexical action capabilities.  Specific aspects in JavaCC
+that are superior to other tools are the first class status it offers
+concepts such as TOKEN, MORE, SKIP, state changes, etc.  This allows
+cleaner specifications as well as better error and warning messages
+from JavaCC.
+<P>
+<LI>
+CASE-INSENSITIVE LEXICAL ANALYSIS:  Lexical specifications can define
+tokens not to be case sensitive either at the global level for the
+entire lexical specification, or on an individual lexical specification
+basis.
+<P>
+<LI>
+EXTENSIVE DEBUGGING CAPABILITIES:  Using options DEBUG_PARSER,
+DEBUG_LOOKAHEAD, and DEBUG_TOKEN_MANAGER, one can get in-depth analysis
+of the parsing and the token processing steps.
+<P>
+<LI>
+SPECIAL TOKENS: Tokens that are defined as special tokens in the
+lexical specification are ignored during parsing, but these tokens
+are available for processing by the tools.  A useful application of
+this is in the processing of comments.
+<P>
+<LI>
+VERY GOOD ERROR REPORTING:  JavaCC error reporting is among the best in
+parser generators.  JavaCC generated parsers are able to clearly point
+out the location of parse errors with complete diagnostic information.
+<P>
+</UL>
+
+</BODY>
+</HTML>
diff --git a/tools/javacc-4.0/doc/index.html b/tools/javacc-4.0/doc/index.html
new file mode 100644
index 0000000000000000000000000000000000000000..d37bf266c5b14e66a00ddbccb440d00c5c25626c
--- /dev/null
+++ b/tools/javacc-4.0/doc/index.html
@@ -0,0 +1,98 @@
+<HTML>
+<!--
+
+Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+intellectual property rights relating to technology embodied in the product
+that is described in this document. In particular, and without limitation,
+these intellectual property rights may include one or more of the U.S.
+patents listed at http://www.sun.com/patents and one or more additional
+patents or pending patent applications in the U.S. and in other countries.
+U.S. Government Rights - Commercial software. Government users are subject
+to the Sun Microsystems, Inc. standard license agreement and applicable
+provisions of the FAR and its supplements.  Use is subject to license terms.
+Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+product is covered and controlled by U.S. Export Control laws and may be
+subject to the export or import laws in other countries.  Nuclear, missile,
+chemical biological weapons or nuclear maritime end uses or end users, whether
+direct or indirect, are strictly prohibited.  Export or reexport to countries
+subject to U.S. embargo or to entities identified on U.S. export exclusion
+lists, including, but not limited to, the denied persons and specially
+designated nationals lists is strictly prohibited.
+
+-->
+<HEAD>
+<meta name=download content=yes>
+<meta name=download.javacc content=download.html>
+<title>JavaCC Home</title>
+<!-- Changed by: Michael Van De Vanter, 15-Jan-2003 -->
+</HEAD>
+<BODY bgcolor="#FFFFFF" >
+
+<H1>Java Compiler Compiler [tm] (JavaCC [tm]) -
+<br>The Java Parser Generator</H1>
+
+<p><hr><p>
+
+<h3>Description:</h3>
+<P>
+Java Compiler Compiler [tm] (JavaCC [tm]) is the most popular parser
+generator for use with Java [tm] applications.  A parser generator is a
+tool that reads a grammar specification and converts it to a Java
+program that can recognize matches to the grammar.  In addition to
+the parser generator itself, JavaCC provides other standard capabilities
+related to parser generation such as tree building (via a tool
+called JJTree included with JavaCC), actions,
+debugging, etc. <p>
+
+Our latest release of JavaCC is Version 3.2.
+<p>
+
+We've had hundreds of thousands of downloads and estimate serious
+users in the many thousands (and maybe even tens of thousands).  Our
+newsgroup <strong>comp.compilers.tools.javacc</strong> and our <a
+href="mailinglist.html">mailing list</a> together have a few thousand
+participants. <p>
+
+JavaCC works with any Java VM version 1.2 or greater.  It has been
+certified to be 100% Pure Java.  JavaCC has been tested on countless
+different platforms without any special porting requirements.  Given
+that we have seen JavaCC run on only around 5 or 6 platforms, we think
+this is a great testimonial to the "Write Once Run Anywhere" aspect of
+the Java programming language.  We say this as engineers who have personally experienced the
+benefits of writing Java applications. <p>
+
+<h3>Third party contributions:</h3>
+
+<P>An excellent <a
+href="http://www.engr.mun.ca/~theo/JavaCC-FAQ/">FAQ</A> is maintained
+by Theo Norvell at Memorial University of Newfoundland.</P>
+
+<P>A <a href="https://javacc.dev.java.net/servlets/ProjectDocumentList?folderID=110">repository of
+JavaCC grammars</a> is being maintained on the JavaCC home page.  We
+urge you to contribute your grammars to this repository or to the
+JavaCC authors for the benefit of others.</P>
+
+<HR>
+<P>
+
+<a href="features.html">Feature Highlights</a>:
+A short description of the features of JavaCC.
+<P>
+
+<a href="installhelp.html">Installation and Getting Started</a>:
+This page contains a bunch of tips that should aid you through the installation
+process.
+<P>
+
+<a href="docindex.html">Documentation</a>:
+The complete documentation for JavaCC.
+<P>
+
+<a href="mailinglist.html">Getting Support and Keeping In Touch</a>:
+Here's how you can contact us and keep in touch with what's happening.
+<P>
+
+</BODY>
+</HTML>
diff --git a/tools/javacc-4.0/doc/installhelp.html b/tools/javacc-4.0/doc/installhelp.html
new file mode 100644
index 0000000000000000000000000000000000000000..867ae1aecdc84e59b2ed2a23757c828f7d9c92a1
--- /dev/null
+++ b/tools/javacc-4.0/doc/installhelp.html
@@ -0,0 +1,71 @@
+<HTML>
+<!--
+
+Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+intellectual property rights relating to technology embodied in the product
+that is described in this document. In particular, and without limitation,
+these intellectual property rights may include one or more of the U.S.
+patents listed at http://www.sun.com/patents and one or more additional
+patents or pending patent applications in the U.S. and in other countries.
+U.S. Government Rights - Commercial software. Government users are subject
+to the Sun Microsystems, Inc. standard license agreement and applicable
+provisions of the FAR and its supplements.  Use is subject to license terms.
+Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+product is covered and controlled by U.S. Export Control laws and may be
+subject to the export or import laws in other countries.  Nuclear, missile,
+chemical biological weapons or nuclear maritime end uses or end users, whether
+direct or indirect, are strictly prohibited.  Export or reexport to countries
+subject to U.S. embargo or to entities identified on U.S. export exclusion
+lists, including, but not limited to, the denied persons and specially
+designated nationals lists is strictly prohibited.
+
+-->
+<HEAD>
+ <title>JavaCC Installation</title>
+<!-- Changed by: Michael Van De Vanter, 15-Jan-2003 -->
+</HEAD>
+<BODY bgcolor="#FFFFFF" >
+
+<H1>JavaCC [tm]: Installation Notes</H1>
+
+
+<P>The download should have placed into your file system either a ZIP
+or GZIP file containing the JavaCC software.</P>
+
+<P>Depending on which you downloaded, you should go to the directory
+where the file was installed and type something like:</P>
+
+<blockquote>
+<code>unzip javacc-3.2.zip</code> <p>
+<P>
+<B>or</b>
+<P>
+<code>gunzip javacc-3.2.tar.gz</code> <br>
+<code>tar xvf javacc-3.2.tar</code> <p>
+</blockquote>
+<P>
+That completes your installation.</P>
+<P>
+Once you have completed installation, add the <code>bin</code> directory
+within the JavaCC installation to your path.
+The <code>javacc</code>,
+<code>jjtree</code>, and <code>jjdoc</code> invocation scripts/executables
+reside in this directory.</P>
+<P>
+You can get started quickly by looking at the examples and the associated
+README files in the <code>examples</code> directory under the installation
+directory.  For additional information consult the 
+<a href="docindex.html">documentation index</a> and the following release notes:
+<ul>
+<li><a href="javaccreleasenotes.html">JavaCC release notes</a></li>
+<li><a href="jjtreereleasenotes.html">JJTree release notes</a></li>
+<li><a href="jjdocreleasenotes.html">JJDoc release notes</a></li>
+</ul>
+Additional help is available on the JavaCC 
+<a href="mailinglist.html">mailing list</a>.
+
+
+</BODY>
+</HTML>
diff --git a/tools/javacc-4.0/doc/javaccgrm.html b/tools/javacc-4.0/doc/javaccgrm.html
new file mode 100644
index 0000000000000000000000000000000000000000..3a11f29ad0236c73babecfd7bb6436b4556eaa80
--- /dev/null
+++ b/tools/javacc-4.0/doc/javaccgrm.html
@@ -0,0 +1,1386 @@
+<HTML>
+<!--
+
+Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+intellectual property rights relating to technology embodied in the product
+that is described in this document. In particular, and without limitation,
+these intellectual property rights may include one or more of the U.S.
+patents listed at http://www.sun.com/patents and one or more additional
+patents or pending patent applications in the U.S. and in other countries.
+U.S. Government Rights - Commercial software. Government users are subject
+to the Sun Microsystems, Inc. standard license agreement and applicable
+provisions of the FAR and its supplements.  Use is subject to license terms.
+Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+product is covered and controlled by U.S. Export Control laws and may be
+subject to the export or import laws in other countries.  Nuclear, missile,
+chemical biological weapons or nuclear maritime end uses or end users, whether
+direct or indirect, are strictly prohibited.  Export or reexport to countries
+subject to U.S. embargo or to entities identified on U.S. export exclusion
+lists, including, but not limited to, the denied persons and specially
+designated nationals lists is strictly prohibited.
+
+-->
+<HEAD>
+<title>JavaCC Grammar Files</title>
+<!-- Changed by: Michael Van De Vanter, 14-Jan-2003 -->
+</HEAD>
+<BODY bgcolor="#FFFFFF" >
+
+<H1>JavaCC [tm]: Grammar Files</H1>
+
+This page contains the complete syntax of Java Compiler Compiler [tm]
+grammar files with detailed explanations of each construct.
+<P>
+Tokens in the grammar files follow the same conventions as for the Java programming language.
+Hence identifiers, strings, characters, etc. used in the grammars are
+the same as Java identifiers, Java strings, Java characters, etc.
+<P>
+<em>White space</em> in the grammar files also follows the same conventions as
+for the Java programming language.  This includes the syntax for comments.  Most comments present in
+the grammar files are generated into the generated parser/lexical analyzer.
+<P>
+Grammar files are preprocessed for Unicode escapes just as Java files
+are (i.e., occurrences of strings such as <code>\uxxxx</code> - where <code>xxxx</code> is a hex value -
+are converted the the corresponding Unicode character before lexical analysis).
+<P>
+<em>Exceptions to the above rules:</em>
+The Java operators "<code>&lt;&lt;</code>", "<code>&gt;&gt;</code>", "<code>&gt;&gt;&gt;</code>", "<code>&lt;&lt;=</code>",
+"<code>&gt;&gt;=</code>", and "<code>&gt;&gt;&gt;=</code>" are left out of JavaCC's input token list
+in order to allow convenient nested use of token specifications.
+Finally, the following are the additional reserved words in the Java Compiler
+Compiler [tm] grammar files.
+<P>
+
+<TABLE CELLPADDING="3">
+<TR>
+<TD ALIGN=LEFT><strong>EOF</strong></TD>
+<TD ALIGN=LEFT><strong><A HREF="#IGNORE_CASE">IGNORE_CASE</A></strong></TD>
+<TD ALIGN=LEFT><strong><A HREF="#JAVACODE">JAVACODE</A></strong></TD>
+<TD ALIGN=LEFT><strong><A HREF="#LOOKAHEAD">LOOKAHEAD</A></strong></TD>
+</TR>
+<TR>
+<TD ALIGN=LEFT><strong><A HREF="#MORE">MORE</A></strong></TD>
+<TD ALIGN=LEFT><strong><A HREF="#options">options</A></strong></TD>
+<TD ALIGN=LEFT><strong><A HREF="#PARSER_BEGIN">PARSER_BEGIN</A></strong></TD>
+<TD ALIGN=LEFT><strong><A HREF="#PARSER_END">PARSER_END</A></strong></TD>
+</TR>
+<TR>
+<TD ALIGN=LEFT><strong><A HREF="#SKIP">SKIP</A></strong></TD>
+<TD ALIGN=LEFT><strong><A HREF="#SPECIAL_TOKEN">SPECIAL_TOKEN</A></strong></TD>
+<TD ALIGN=LEFT><strong><A HREF="#TOKEN">TOKEN</A></strong></TD>
+<TD ALIGN=LEFT><strong><A HREF="#TOKEN_MGR_DECLS">TOKEN_MGR_DECLS</A></strong></TD>
+</TR>
+</TABLE>
+
+<P>
+Any Java entities used in the grammar rules that follow appear italicized
+with the prefix <EM>java_</EM> (<EM>e.g.</EM>, <EM>java_compilation_unit</EM>).
+
+<P>
+<HR>
+<P>
+
+<A NAME="PARSER_BEGIN"></A><A NAME="PARSER_END"></A>
+<TABLE>
+<TR>
+<TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="prod1">javacc_input</A></TD>
+<TD ALIGN=CENTER VALIGN=BASELINE>::=</TD>
+<TD ALIGN=LEFT VALIGN=BASELINE><A HREF="#prod2">javacc_options</A></TD>
+</TR>
+<TR>
+<TD></TD><TD></TD>
+<TD ALIGN=LEFT VALIGN=BASELINE>"PARSER_BEGIN" "(" &lt;IDENTIFIER&gt; ")"</TD>
+</TR>
+<TR>
+<TD></TD><TD></TD>
+<TD ALIGN=LEFT VALIGN=BASELINE><EM>java_compilation_unit</EM></TD>
+</TR>
+<TR>
+<TD></TD><TD></TD>
+<TD ALIGN=LEFT VALIGN=BASELINE>"PARSER_END" "(" &lt;IDENTIFIER&gt; ")"</TD>
+</TR>
+<TR>
+<TD></TD><TD></TD>
+<TD ALIGN=LEFT VALIGN=BASELINE>( <A HREF="#prod5">production</A> )*</TD>
+</TR>
+<TR>
+<TD></TD><TD></TD>
+<TD ALIGN=LEFT VALIGN=BASELINE>&lt;EOF&gt;</TD>
+</TR>
+</TABLE>
+<P>
+
+The grammar file starts with a list of options (which is optional).
+This is then followed by a Java compilation unit enclosed between
+"PARSER_BEGIN(name)" and "PARSER_END(name)".  After this is a list
+of grammar productions.  <A HREF="#prod2">Options</A> and
+<A HREF="#prod5">productions</A> are described later.
+<P>
+The <EM>name</EM> that follows "PARSER_BEGIN" and "PARSER_END" must
+be the same and this identifies the name of the generated parser.
+For example, if <EM>name</EM> is "MyParser", then the following files
+are generated:
+<P>
+<STRONG>MyParser.java:</STRONG>
+The generate parser.
+<BR>
+<STRONG>MyParserTokenManager.java:</STRONG>
+The generated token manager (or scanner/lexical analyzer).
+<BR>
+<STRONG>MyParserConstants.java:</STRONG>
+A bunch of useful constants.
+<P>
+Other files such as "Token.java", "ParseError.java", etc. are also
+generated.  However, these files contain boilerplate code and are
+the same for any grammar and may be reused across grammars.
+<P>
+Between the PARSER_BEGIN and PARSER_END constructs is a regular
+Java compilation unit (a compilation unit in Java lingo is the entire
+contents of a Java file).  This may be any arbitrary
+Java compilation unit so long as it contains a class declaration
+whose name is the same as the name of the generated parser ("MyParser"
+in the above example).  Hence, in general, this part of the grammar
+file looks like:
+<P>
+<PRE>
+    PARSER_BEGIN(parser_name)
+    . . .
+    class parser_name . . . {
+      . . .
+    }
+    . . .
+    PARSER_END(parser_name)
+</PRE>
+<P>
+JavaCC does not perform detailed checks on the compilation unit, so
+it is possible for a grammar file to pass through JavaCC and generate
+Java files that produce errors when they are compiled.
+<P>
+If the compilation unit includes a package declaration, this is
+included in all the generated files.  If the compilation unit includes
+imports declarations, this is included in the generated parser and
+token manager files.
+<P>
+The generated parser file contains everything in the compilation unit
+and, in addition, contains the generated parser code that is included at
+the end of the parser class.  For the above example, the generated
+parser will look like:
+<P>
+<PRE>
+    . . .
+    class parser_name . . . {
+      . . .
+      // generated parser is inserted here.
+    }
+    . . .
+</PRE>
+<P>
+The generated parser includes a public method declaration corresponding
+to each non-terminal (see <A HREF="#prod9">javacode_production</A> and
+<A HREF="#prod11">bnf_production</A>) in the grammar file.  Parsing with
+respect to a non-terminal is achieved by calling the method corresponding
+to that non-terminal.  Unlike yacc, there is no single start symbol in
+JavaCC - one can parse with respect to any non-terminal in the grammar.
+<P>
+The generated token manager provides one public method:
+<P>
+<PRE>
+    Token getNextToken() throws ParseError;
+</PRE>
+<P>
+For more details on how this method may be used, please read
+<A HREF="apiroutines.html">the description of the Java Compiler Compiler
+API</A>.
+
+<P>
+<HR>
+<P>
+
+<TABLE>
+<TR>
+<TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="prod2">javacc_options</A></TD>
+<TD ALIGN=CENTER VALIGN=BASELINE>::=</TD>
+<TD ALIGN=LEFT VALIGN=BASELINE>[ "<A NAME="options">options</A>" "{" ( <A HREF="#prod6">option_binding</A> )* "}" ]</TD>
+</TR>
+</TABLE>
+<P>
+
+The options if present, starts with the reserved word "options" followed
+by a list of one or more option bindings within braces.  Each option
+binding specifies the setting of one option.  The same option may not be
+set multiple times.
+<P>
+Options may be specified either here in the grammar file, or from
+<A HREF="commandline.html">the command line</A>.  If the option is set
+from <A HREF="commandline.html">the command line</A>, that takes precedence.
+<P>
+Option names are not case-sensitive.
+
+<P>
+<HR>
+<P>
+
+<TABLE>
+<TR>
+<TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="prod6">option_binding</A></TD>
+<TD ALIGN=CENTER VALIGN=BASELINE>::=</TD>
+<TD ALIGN=LEFT VALIGN=BASELINE>"LOOKAHEAD" "=" <EM>java_integer_literal</EM> ";"</TD>
+</TR>
+<TR>
+<TD></TD><TD ALIGN=CENTER VALIGN=BASELINE>|</TD>
+<TD ALIGN=LEFT VALIGN=BASELINE>"CHOICE_AMBIGUITY_CHECK" "=" <EM>java_integer_literal</EM> ";"</TD>
+</TR>
+<TR>
+<TD></TD><TD ALIGN=CENTER VALIGN=BASELINE>|</TD>
+<TD ALIGN=LEFT VALIGN=BASELINE>"OTHER_AMBIGUITY_CHECK" "=" <EM>java_integer_literal</EM> ";"</TD>
+</TR>
+<TR>
+<TD></TD><TD ALIGN=CENTER VALIGN=BASELINE>|</TD>
+<TD ALIGN=LEFT VALIGN=BASELINE>"STATIC" "=" <EM>java_boolean_literal</EM> ";"</TD>
+</TR>
+<TR>
+<TD></TD><TD ALIGN=CENTER VALIGN=BASELINE>|</TD>
+<TD ALIGN=LEFT VALIGN=BASELINE>"DEBUG_PARSER" "=" <EM>java_boolean_literal</EM> ";"</TD>
+</TR>
+<TR>
+<TD></TD><TD ALIGN=CENTER VALIGN=BASELINE>|</TD>
+<TD ALIGN=LEFT VALIGN=BASELINE>"DEBUG_LOOKAHEAD" "=" <EM>java_boolean_literal</EM> ";"</TD>
+</TR>
+<TR>
+<TD></TD><TD ALIGN=CENTER VALIGN=BASELINE>|</TD>
+<TD ALIGN=LEFT VALIGN=BASELINE>"DEBUG_TOKEN_MANAGER" "=" <EM>java_boolean_literal</EM> ";"</TD>
+</TR>
+<TR>
+<TD></TD><TD ALIGN=CENTER VALIGN=BASELINE>|</TD>
+<TD ALIGN=LEFT VALIGN=BASELINE>"OPTIMIZE_TOKEN_MANAGER" "=" <EM>java_boolean_literal</EM> ";"</TD>
+</TR>
+<TR>
+<TD></TD><TD ALIGN=CENTER VALIGN=BASELINE>|</TD>
+<TD ALIGN=LEFT VALIGN=BASELINE>"ERROR_REPORTING" "=" <EM>java_boolean_literal</EM> ";"</TD>
+</TR>
+<TR>
+<TD></TD><TD ALIGN=CENTER VALIGN=BASELINE>|</TD>
+<TD ALIGN=LEFT VALIGN=BASELINE>"JAVA_UNICODE_ESCAPE" "=" <EM>java_boolean_literal</EM> ";"</TD>
+</TR>
+<TR>
+<TD></TD><TD ALIGN=CENTER VALIGN=BASELINE>|</TD>
+<TD ALIGN=LEFT VALIGN=BASELINE>"UNICODE_INPUT" "=" <EM>java_boolean_literal</EM> ";"</TD>
+</TR>
+<TR>
+<TD></TD><TD ALIGN=CENTER VALIGN=BASELINE>|</TD>
+<TD ALIGN=LEFT VALIGN=BASELINE>"IGNORE_CASE" "=" <EM>java_boolean_literal</EM> ";"</TD>
+</TR>
+<TR>
+<TD></TD><TD ALIGN=CENTER VALIGN=BASELINE>|</TD>
+<TD ALIGN=LEFT VALIGN=BASELINE>"USER_TOKEN_MANAGER" "=" <EM>java_boolean_literal</EM> ";"</TD>
+</TR>
+<TR>
+<TD></TD><TD ALIGN=CENTER VALIGN=BASELINE>|</TD>
+<TD ALIGN=LEFT VALIGN=BASELINE>"USER_CHAR_STREAM" "=" <EM>java_boolean_literal</EM> ";"</TD>
+</TR>
+<TR>
+<TD></TD><TD ALIGN=CENTER VALIGN=BASELINE>|</TD>
+<TD ALIGN=LEFT VALIGN=BASELINE>"BUILD_PARSER" "=" <EM>java_boolean_literal</EM> ";"</TD>
+</TR>
+<TR>
+<TD></TD><TD ALIGN=CENTER VALIGN=BASELINE>|</TD>
+<TD ALIGN=LEFT VALIGN=BASELINE>"BUILD_TOKEN_MANAGER" "=" <EM>java_boolean_literal</EM> ";"</TD>
+</TR>
+<TR>
+<TD></TD><TD ALIGN=CENTER VALIGN=BASELINE>|</TD>
+<TD ALIGN=LEFT VALIGN=BASELINE>"TOKEN_MANAGER_USES_PARSER" "=" <EM>java_boolean_literal</EM> ";"</TD>
+</TR>
+<TR>
+<TD></TD><TD ALIGN=CENTER VALIGN=BASELINE>|</TD>
+<TD ALIGN=LEFT VALIGN=BASELINE>"SANITY_CHECK" "=" <EM>java_boolean_literal</EM> ";"</TD>
+</TR>
+<TR>
+<TD></TD><TD ALIGN=CENTER VALIGN=BASELINE>|</TD>
+<TD ALIGN=LEFT VALIGN=BASELINE>"FORCE_LA_CHECK" "=" <EM>java_boolean_literal</EM> ";"</TD>
+</TR>
+<TR>
+<TD></TD><TD ALIGN=CENTER VALIGN=BASELINE>|</TD>
+<TD ALIGN=LEFT VALIGN=BASELINE>"COMMON_TOKEN_ACTION" "=" <EM>java_boolean_literal</EM> ";"</TD>
+</TR>
+<TR>
+<TD></TD><TD ALIGN=CENTER VALIGN=BASELINE>|</TD>
+<TD ALIGN=LEFT VALIGN=BASELINE>"CACHE_TOKENS" "=" <EM>java_boolean_literal</EM> ";"</TD>
+</TR>
+<TR>
+<TD></TD><TD ALIGN=CENTER VALIGN=BASELINE>|</TD>
+<TD ALIGN=LEFT VALIGN=BASELINE>"OUTPUT_DIRECTORY" "=" <EM>java_string_literal</EM> ";"</TD>
+</TR>
+</TABLE>
+
+<UL>
+<LI>
+<STRONG><A NAME="LOOKAHEAD">LOOKAHEAD</A>:</STRONG>
+The number of tokens to look ahead before making a
+decision at a choice point during parsing.  The default value is 1.
+The smaller this number, the faster the parser.  This number may be
+overridden for specific productions within the grammar as described
+later.  See the description of
+<A HREF="lookahead.html">the lookahead algorithm</A> for complete
+details on how lookahead works.
+<LI>
+<STRONG>CHOICE_AMBIGUITY_CHECK:</STRONG>
+This is an integer option whose default value is 2.
+This is the number of tokens considered in checking choices of the
+form "A | B | ..." for ambiguity.  For example, if there is a common
+two token prefix for both A and B, but no common three token prefix,
+(assume this option is set to 3) then JavaCC can tell you to use a
+lookahead of 3 for disambiguation purposes.  And if A and B have a
+common three token prefix, then JavaCC only tell you that you need to
+have a lookahead of 3 <EM>or more</EM>.  Increasing this can give you more
+comprehensive ambiguity information at the cost of more processing
+time.  For large grammars such as the Java grammar, increasing this number
+any further causes the checking to take too much time.
+<LI>
+<STRONG>OTHER_AMBIGUITY_CHECK:</STRONG>
+This is an integer option whose default value is 1.
+This is the number of tokens considered in checking all other kinds of
+choices (i.e., of the forms "(A)*", "(A)+", and "(A)?") for ambiguity.
+This takes more time to do than the choice checking, and hence the
+default value is set to 1 rather than 2.
+<LI>
+<STRONG>STATIC:</STRONG>
+This is a boolean option whose default value is true.  If
+true, all methods and class variables are specified as static in the
+generated parser and token manager.  This allows only one parser object to be present,
+but it improves the performance of the parser.  To perform multiple
+parses during one run of your Java program, you will have to call the
+<A HREF="apiroutines.html">ReInit()</A>
+method to reinitialize your parser if it is static.
+If the parser is non-static, you may use the "new" operator to
+construct as many parsers as you wish.  These can all be used
+simultaneously from different threads.
+<LI>
+<STRONG>DEBUG_PARSER:</STRONG>
+This is a boolean option whose default value is false.  This
+option is used to obtain debugging information from the generated
+parser.  Setting this option to true causes the parser to generate
+a trace of its actions.  Tracing may be disabled by
+calling the method <A HREF="apiroutines.html">disable_tracing()</A>
+in the generated parser class.  Tracing may be subsequently enabled
+by calling the method <A HREF="apiroutines.html">enable_tracing()</A>
+in the generated parser class.
+<LI>
+<STRONG>DEBUG_LOOKAHEAD:</STRONG>
+This is a boolean option whose default value is false.  Setting this
+option to true causes the parser to generate all the tracing information
+it does when the option DEBUG_PARSER is true, and in addition, also
+causes it to generated a trace of actions performed during
+<A HREF="lookahead.html">lookahead operation</A>.
+<LI>
+<STRONG>DEBUG_TOKEN_MANAGER:</STRONG>
+This is a boolean option whose default value is false.  This
+option is used to obtain debugging information from the generated
+token manager.  Setting this option to true causes the token manager to generate
+a trace of its actions.  This trace is rather large and should only
+be used when you have a lexical error that has been reported to you
+and you cannot understand why.  Typically, in this situation, you
+can determine the problem by looking at the last few lines of this trace.
+<LI>
+<STRONG>ERROR_REPORTING:</STRONG>
+This is a boolean option whose default value is
+true.  Setting it to false causes errors due to parse errors to be
+reported in somewhat less detail.  The only reason to set this
+option to false is to improve performance.
+<LI>
+<STRONG>JAVA_UNICODE_ESCAPE:</STRONG>
+This is a boolean option whose default value is
+false.  When set to true, the generated parser uses
+an input stream object that processes Java Unicode escapes
+(\u...) before sending characters to the token manager.  By
+default, Java Unicode escapes are not processed.
+<BR>
+This option is ignored if either of options USER_TOKEN_MANAGER,
+USER_CHAR_STREAM is set to true.
+<LI>
+<STRONG>UNICODE_INPUT:</STRONG>
+This is a boolean option whose default value is
+false.  When set to true, the generated parser uses
+uses an input stream object that reads Unicode files.  By default,
+ASCII files are assumed.
+<BR>
+This option is ignored if either of
+options USER_TOKEN_MANAGER, USER_CHAR_STREAM is set to true.
+<LI>
+<STRONG><A NAME="IGNORE_CASE">IGNORE_CASE:</A></STRONG>
+This is a boolean option whose default value is false.
+Setting this option to true causes the generated token manager to ignore
+case in the token specifications and the input files.  This is useful
+for writing grammars for languages such as HTML.  It is also possible
+to localize the effect of IGNORE_CASE by using
+<A HREF="#prod10">an alternate mechanism described later</A>.
+<LI>
+<STRONG>USER_TOKEN_MANAGER:</STRONG>
+This is a boolean option whose default value is
+false.  The default action is to generate a token manager
+that works on the specified grammar tokens.  If this
+option is set to true, then the parser is generated to accept tokens
+from any token manager of type "TokenManager" - this interface
+is generated into the generated parser directory.
+<LI>
+<STRONG>USER_CHAR_STREAM:</STRONG>
+This is a boolean option whose default value is
+false.  The default action is to generate a character stream reader
+as specified by the options JAVA_UNICODE_ESCAPE and UNICODE_INPUT.
+The generated token manager receives characters
+from this stream reader.  If this option is set to true, then the
+token manager is generated to read characters from any character
+stream reader of type "CharStream.java".  This file is generated
+into the generated parser directory.
+<BR>
+This option is ignored if USER_TOKEN_MANAGER is set to true.
+<LI>
+<STRONG>BUILD_PARSER:</STRONG>
+This is a boolean option whose default value is true.
+The default action is to generate the parser file ("MyParser.java"
+in the above example).  When set to false, the parser file is
+not generated.  Typically, this option is set to false when
+you wish to generate only the token manager and use it without
+the associated parser.
+<LI>
+<STRONG>BUILD_TOKEN_MANAGER:</STRONG>
+This is a boolean option whose default value is true.
+The default action is to generate the token manager file
+("MyParserTokenManager.java" in the above example).  When set to
+false the token manager file is not generated.  The only reason
+to set this option to false is to save some time during parser
+generation when you fix problems in the parser part of the grammar
+file and leave the lexical specifications untouched.
+<LI>
+<STRONG>TOKEN_MANAGER_USES_PARSER:</STRONG>
+This is a boolean option whose default value is false.
+When set to true, the generated token manager will include a field 
+called <CODE>parser</CODE> that references the instantiating parser 
+instance (of type <CODE>MyParser</CODE> in the above example).
+The main reason for having a parser in a token manager is using
+some of its logic in lexical actions.
+This option has no effect if the STATIC option is set to true.
+<LI>
+<STRONG>SANITY_CHECK:</STRONG>
+This is a boolean option whose default value is true.
+JavaCC performs many syntactic and semantic checks on the grammar
+file during parser generation.  Some checks such as detection of
+left recursion, detection of ambiguity, and bad usage of empty
+expansions may be suppressed for faster parser generation by
+setting this option to false.  Note that the presence of these
+errors (even if they are not detected and reported by setting this
+option to false) can cause unexpected behavior from the generated
+parser.
+<LI>
+<STRONG>FORCE_LA_CHECK:</STRONG>
+This is a boolean option whose default value is false.
+This option setting controls lookahead ambiguity checking performed
+by JavaCC.  By default (when this option is false), lookahead
+ambiguity checking is performed for all choice points where the
+default lookahead of 1 is used.  Lookahead ambiguity checking is
+not performed at choice points where there is an
+<A HREF="lookahead.html">explicit lookahead specification</A>,
+or if the option LOOKAHEAD is set to something other than 1.
+Setting this option to true performs lookahead ambiguity checking
+at <EM>all</EM> choice points regardless of the lookahead specifications
+in the grammar file.
+<LI>
+<STRONG>COMMON_TOKEN_ACTION:</STRONG>
+This is a boolean option whose default value is false.
+When set to true, every call to the token manager's method
+"getNextToken" (<A HREF="apiroutines.html">see the description of the
+Java Compiler Compiler API</A>) will cause a call to a used defined
+method "CommonTokenAction" after the token has been scanned in by the
+token manager.  The user must define this method within the
+<A HREF="#prod12">TOKEN_MGR_DECLS</A> section.
+The signature of this method is:
+<P>
+<PRE>
+    void CommonTokenAction(Token t)
+</PRE>
+<P>
+<LI>
+<STRONG>CACHE_TOKENS:</STRONG>
+This is a boolean option whose default value is false.
+Setting this option to true causes the generated parser to lookahead for
+extra tokens ahead of time.  This facilitates some performance improvements.
+However, in this case (when the option is true), interactive
+applications may not work since the parser needs to work synchronously
+with the availability of tokens from the input stream.  In such cases,
+it's best to leave this option at its default value.
+<LI>
+<STRONG>OUTPUT_DIRECTORY:</STRONG>
+This is a string valued option whose default value is the current
+directory.  This controls where output files are generated.
+</UL>
+
+<P>
+<HR>
+<P>
+
+<TABLE>
+<TR>
+<TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="prod5">production</A></TD>
+<TD ALIGN=CENTER VALIGN=BASELINE>::=</TD>
+<TD ALIGN=LEFT VALIGN=BASELINE><A HREF="#prod9">javacode_production</A></TD>
+</TR>
+<TR>
+<TD ALIGN=RIGHT VALIGN=BASELINE></TD>
+<TD ALIGN=CENTER VALIGN=BASELINE>|</TD>
+<TD ALIGN=LEFT VALIGN=BASELINE><A HREF="#prod10">regular_expr_production</A></TD>
+</TR>
+<TR>
+<TD ALIGN=RIGHT VALIGN=BASELINE></TD>
+<TD ALIGN=CENTER VALIGN=BASELINE>|</TD>
+<TD ALIGN=LEFT VALIGN=BASELINE><A HREF="#prod11">bnf_production</A></TD>
+</TR>
+<TR>
+<TD ALIGN=RIGHT VALIGN=BASELINE></TD>
+<TD ALIGN=CENTER VALIGN=BASELINE>|</TD>
+<TD ALIGN=LEFT VALIGN=BASELINE><A HREF="#prod12">token_manager_decls</A></TD>
+</TR>
+</TABLE>
+<P>
+
+There are four kinds of productions in JavaCC.
+<A HREF="#prod9">javacode_production</A> and <A HREF="#prod11">bnf_production</A>
+are used to define the grammar from which the parser is generated.
+<A HREF="#prod10">regular_expr_production</A> is used to define the grammar
+tokens - the token manager is generated from this information (as well as from
+inline token specifications in the parser grammar).
+<A HREF="#prod12">token_manager_decls</A> is used to introduce declarations
+that get inserted into the generated token manager.
+
+<P>
+<HR>
+<P>
+
+<TABLE>
+<TR>
+<TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="prod9">javacode_production</A></TD>
+<TD ALIGN=CENTER VALIGN=BASELINE>::=</TD>
+<TD ALIGN=LEFT VALIGN=BASELINE>"<A NAME="JAVACODE">JAVACODE</A>"</TD>
+</TR>
+<TR>
+<TD></TD><TD></TD>
+<TD ALIGN=LEFT VALIGN=BASELINE><EM>java_access_modifier</EM> <EM>java_return_type</EM> <EM>java_identifier</EM> "(" <EM>java_parameter_list</EM> ")"</TD>
+</TR>
+<TR>
+<TD></TD><TD></TD>
+<TD ALIGN=LEFT VALIGN=BASELINE><EM>java_block</EM>
+</TR>
+</TABLE>
+<P>
+
+The JAVACODE production is a way to write Java code for some
+productions instead of the usual EBNF expansion.  This is useful when
+there is the need to recognize something that is not context-free
+or for whatever reason is very difficult to write a grammar for.
+An example of the use of JAVACODE is shown below.  In this example,
+the non-terminal "skip_to_matching_brace" consumes tokens in the input
+stream all the way up to a matching closing brace (the opening brace
+is assumed to have been just scanned):
+<P>
+<PRE>
+    JAVACODE
+    void skip_to_matching_brace() {
+      <A HREF="apiroutines.html">Token</A> tok;
+      int nesting = 1;
+      while (true) {
+        tok = <A HREF="apiroutines.html">getToken</A>(1);
+        if (tok.kind == LBRACE) nesting++;
+        if (tok.kind == RBRACE) {
+          nesting--;
+          if (nesting == 0) break;
+        }
+        tok = <A HREF="apiroutines.html">getNextToken</A>();
+      }
+    }
+</PRE>
+<P>
+Care must be taken when using JAVACODE productions.  While you can
+say pretty much what you want with these productions, JavaCC simply
+considers it a black box (that somehow performs its parsing task).
+This becomes a problem when JAVACODE productions appear at
+<A HREF="lookahead.html">choice points</A>.  For example, if the
+above JAVACODE production was referred to from the following production:
+<P>
+<PRE>
+  void NT() :
+  {}
+  {
+    skip_to_matching_brace()
+  |
+    some_other_production()
+  }
+</PRE>
+<P>
+Then JavaCC would not know how to choose between the two choices.
+On the other hand, if the JAVACODE production is used at a non-choice
+point as in the following example, there is no problem:
+<P>
+<PRE>
+  void NT() :
+  {}
+  {
+    "{" skip_to_matching_brace()
+  |
+    "(" parameter_list() ")"
+  }
+</PRE>
+<P>
+When JAVACODE productions are used at choice points, JavaCC will
+print a warning message stating this fact.  You will then have to
+insert some explicit LOOKAHEAD specifications to help JavaCC.  See
+<A HREF="lookahead.html">the minitutorial on LOOKAHEAD</A> for a
+detailed guide on such issues.
+<P>
+The default access modifier for JAVACODE productions is package private.
+
+<P>
+<HR>
+<P>
+
+<TABLE>
+<TR>
+<TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="prod11">bnf_production</A></TD>
+<TD ALIGN=CENTER VALIGN=BASELINE>::=</TD>
+<TD ALIGN=LEFT VALIGN=BASELINE><EM>java_access_modifier</EM> <EM>java_return_type</EM> <EM>java_identifier</EM> "(" <EM>java_parameter_list</EM> ")" ":"</TD>
+</TR>
+<TR>
+<TD></TD><TD></TD>
+<TD ALIGN=LEFT VALIGN=BASELINE><EM>java_block</EM>
+</TR>
+<TR>
+<TD></TD><TD></TD>
+<TD ALIGN=LEFT VALIGN=BASELINE>"{" <A HREF="#prod16">expansion_choices</A> "}"</TD>
+</TR>
+</TABLE>
+<P>
+
+The BNF production is the standard production used
+in specifying JavaCC grammars.  Each BNF production has a left hand
+side which is a non-terminal specification.  The BNF production then
+defines this non-terminal in terms of BNF expansions on the right hand
+side.  The non-terminal is written exactly like a declared Java method.
+Since each non-terminal is translated into a method
+in the generated parser, this style of writing the non-terminal makes
+this association obvious.  The name of the non-terminal is the name of
+the method, and the parameters and return value declared are the means
+to pass values up and down the parse tree.  As will be seen later,
+non-terminals on the right hand sides of productions are written as
+method calls, so the passing of values up and down the tree are done
+using exactly the same paradigm as method call and return.
+The default access modifier for BNF productions is public.
+<P>
+There are two parts on the right hand side of an BNF production.  The
+first part is a set of arbitrary Java declarations and code (the Java
+block).  This code is generated at the beginning
+of the method generated for the Java non-terminal.  Hence, every time
+this non-terminal is used in the parsing process, these declarations and
+code are executed.  The declarations in this part are visible to all Java
+code in actions in the BNF expansions.  JavaCC does not do any processing
+of these declarations and code, except to skip to the matching ending
+brace, collecting all text encountered on the way.  Hence, a Java compiler
+can detect errors in this code that has been processed by JavaCC.
+<P>
+The second part of the right hand side are the BNF expansions.  This
+is described <A NAME="prod16">later</A>.
+
+<P>
+<HR>
+<P>
+
+<TABLE>
+<TR>
+<TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="prod10">regular_expr_production</A></TD>
+<TD ALIGN=CENTER VALIGN=BASELINE>::=</TD>
+<TD ALIGN=LEFT VALIGN=BASELINE>[ <A HREF="#newprod1">lexical_state_list</A> ]</TD>
+</TR>
+<TR>
+<TD></TD><TD></TD>
+<TD ALIGN=LEFT VALIGN=BASELINE><A HREF="#prod17">regexpr_kind</A> [ "[" "IGNORE_CASE" "]" ] ":"</TD>
+</TR>
+<TR>
+<TD></TD><TD></TD>
+<TD ALIGN=LEFT VALIGN=BASELINE>"{" <A HREF="#prod18">regexpr_spec</A> ( "|" <A HREF="#prod18">regexpr_spec</A> )* "}"</TD>
+</TR>
+</TABLE>
+<P>
+
+A regular expression production is used to define lexical entities
+that get processed by the generated token manager.  A detailed description
+of how the token manager works is provided in
+<A HREF="tokenmanager.html">this minitutorial (click here)</A>.  This
+page describes the syntactic aspects of specifying lexical entities,
+while <A HREF="tokenmanager.html">the minitutorial</A> describes how
+these syntactic constructs tie in with how the token manager actually
+works.
+<P>
+A regular expression production starts with a specification of the
+lexical states for which it applies (the
+<A HREF="#newprod1">lexical state list</A>).
+There is a standard lexical state called "DEFAULT".  If the
+<A HREF="#newprod1">lexical state list</A> is omitted, the regular
+expression production applies to the lexical state "DEFAULT".
+<P>
+Following this is a description of what kind of regular expression
+production this is (<A HREF="#prod17">see below for what this means</A>).
+<P>
+After this is an optional "[IGNORE_CASE]".  If this is present, the
+regular expression production is case insensitive - it has the same
+effect as the
+<A HREF="#prod6">IGNORE_CASE</A>
+option, except that in this case it applies locally to this regular
+expression production.
+<P>
+This is then followed by a list of regular expression specifications
+that describe in more detail the lexical entities of this regular
+expression production.
+
+<P>
+<HR>
+<P>
+
+<TABLE>
+<TR>
+<TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="prod12">token_manager_decls</A></TD>
+<TD ALIGN=CENTER VALIGN=BASELINE>::=</TD>
+<TD ALIGN=LEFT VALIGN=BASELINE>"<A NAME="TOKEN_MGR_DECLS">TOKEN_MGR_DECLS</A>" ":" <EM>java_block</EM></TD>
+</TR>
+</TABLE>
+<P>
+
+The token manager declarations starts with the reserved word
+"TOKEN_MGR_DECLS" followed by a ":" and then a set of Java declarations
+and statements (the Java block).  These declarations and statements are
+written into the generated token manager and are accessible from within
+<A HREF="#prod18">lexical actions</A>.  See
+<A HREF="tokenmanager.html">the minitutorial on the token manager</A>
+for more details.
+<P>
+There can only be one token manager declaration in a JavaCC grammar file.
+
+<P>
+<HR>
+<P>
+
+<TABLE>
+<TR>
+<TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="newprod1">lexical_state_list</A></TD>
+<TD ALIGN=CENTER VALIGN=BASELINE>::=</TD>
+<TD ALIGN=LEFT VALIGN=BASELINE>"&lt;" "*" "&gt;"</TD>
+</TR>
+<TR>
+<TD></TD><TD>|</TD>
+<TD ALIGN=LEFT VALIGN=BASELINE>"&lt;" <EM>java_identifier</EM> ( "," <EM>java_identifier</EM> )* "&gt;"</TD>
+</TR>
+</TABLE>
+<P>
+
+The lexical state list describes the set of lexical states for which
+the corresponding <A HREF="#prod10">regular expression production</A>
+applies.  If this is written as "<*>", the regular expression production
+applies to all lexical states.  Otherwise, it applies to all the lexical
+states in the identifier list within the angular brackets.
+
+<P>
+<HR>
+<P>
+
+<TABLE>
+<TR>
+<TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="prod17">regexpr_kind</A></TD>
+<TD ALIGN=CENTER VALIGN=BASELINE>::=</TD>
+<TD ALIGN=LEFT VALIGN=BASELINE>"TOKEN"</TD>
+</TR>
+<TR>
+<TD ALIGN=RIGHT VALIGN=BASELINE></TD>
+<TD ALIGN=CENTER VALIGN=BASELINE>|</TD>
+<TD ALIGN=LEFT VALIGN=BASELINE>"SPECIAL_TOKEN"</TD>
+</TR>
+<TR>
+<TD ALIGN=RIGHT VALIGN=BASELINE></TD>
+<TD ALIGN=CENTER VALIGN=BASELINE>|</TD>
+<TD ALIGN=LEFT VALIGN=BASELINE>"SKIP"</TD>
+</TR>
+<TR>
+<TD ALIGN=RIGHT VALIGN=BASELINE></TD>
+<TD ALIGN=CENTER VALIGN=BASELINE>|</TD>
+<TD ALIGN=LEFT VALIGN=BASELINE>"MORE"</TD>
+</TR>
+</TABLE>
+<P>
+
+This specifies the kind of
+<A HREF="#prod10">regular expression production</A>.
+There are four kinds:
+<P>
+<UL>
+<LI>
+<STRONG><A NAME="TOKEN">TOKEN</A></STRONG>:
+The regular expressions in this regular expression production describe
+<EM>tokens</EM> in the grammar.  The token manager creates a
+<A HREF="apiroutines.html">Token</A> object for each match of such
+a regular expression and returns it to the parser.
+<P>
+<LI>
+<STRONG><A NAME="SPECIAL_TOKEN">SPECIAL_TOKEN</A></STRONG>:
+The regular expressions in this regular expression production describe
+<EM>special tokens</EM>.  Special tokens are like tokens, except that
+they do not have significance during parsing - that is the BNF productions
+ignore them.  Special tokens are, however, still passed on to the parser
+so that parser actions can access them.  Special tokens are passed
+to the parser by linking them to neighboring real tokens using the
+field "specialToken" in the <A HREF="apiroutines.html">Token</A>
+class.  Special tokens are useful in the processing of lexical entities
+such as comments which have no significance to parsing, but still
+are an important part of the input file.  See
+<A HREF="tokenmanager.html">the minitutorial on the token manager</A>
+for more details of special token handling.
+<P>
+<LI>
+<STRONG><A NAME="SKIP">SKIP</A></STRONG>:
+Matches to regular expressions in this regular expression production
+are simply skipped (ignored) by the token manager.
+<P>
+<LI>
+<STRONG><A NAME="MORE">MORE</A></STRONG>:
+Sometimes it is useful to gradually build up a token to be passed on
+to the parser.  Matches to this kind of regular expression are stored
+in a buffer until the next TOKEN or SPECIAL_TOKEN match.  Then all
+the matches in the buffer and the final TOKEN/SPECIAL_TOKEN match
+are concatenated together to form one TOKEN/SPECIAL_TOKEN that is
+passed on to the parser.  If a match to a SKIP regular expression
+follows a sequence of MORE matches, the contents of the buffer is
+discarded.
+</UL>
+
+<P>
+<HR>
+<P>
+
+<TABLE>
+<TR>
+<TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="prod18">regexpr_spec</A></TD>
+<TD ALIGN=CENTER VALIGN=BASELINE>::=</TD>
+<TD ALIGN=LEFT VALIGN=BASELINE><A HREF="#prod19">regular_expression</A> [ <EM>java_block</EM> ] [ ":" <EM>java_identifier</EM> ]</TD>
+</TR>
+</TABLE>
+<P>
+
+The regular expression specification begins the actual description
+of the lexical entities that are part of this
+<A HREF="#prod10">regular expression production</A>.
+Each regular expression production may contain any number of
+regular expression specifications.
+<P>
+Each regular expression specification contains a regular expression
+followed by a Java block (the lexical action) which is optional.
+This is then followed by an identifier of a lexical state (which
+is also optional).  Whenever this regular expression is matched,
+the lexical action (if any) gets executed, followed by any
+<A HREF="#prod6">common token actions</A>.  Then the action depending
+on the
+<A HREF="#prod17">regular expression production kind</A>
+is taken.  Finally, if a lexical state is specified, the token
+manager moves to that lexical state for further processing (the
+token manager starts initially in the state "DEFAULT").
+
+<P>
+<HR>
+<P>
+
+<TABLE>
+<TR>
+<TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="prod16">expansion_choices</A></TD>
+<TD ALIGN=CENTER VALIGN=BASELINE>::=</TD>
+<TD ALIGN=LEFT VALIGN=BASELINE><A HREF="#prod20">expansion</A> ( "|" <A HREF="#prod20">expansion</A> )*</TD>
+</TR>
+</TABLE>
+<P>
+
+Expansion choices are written as a list of one or more expansions
+separated by "|"s.  The set of legal parses allowed by an expansion
+choice is a legal parse of any one of the contained expansions.
+
+<P>
+<HR>
+<P>
+
+<TABLE>
+<TR>
+<TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="prod20">expansion</A></TD>
+<TD ALIGN=CENTER VALIGN=BASELINE>::=</TD>
+<TD ALIGN=LEFT VALIGN=BASELINE>( <A HREF="#prod22">expansion_unit</A> )*</TD>
+</TR>
+</TABLE>
+<P>
+
+An expansion is written as a sequence of expansion units.
+A concatenation of legal
+parses of the expansion units is a legal parse of the expansion.
+<P>
+For example, the expansion "{" decls() "}" consists of three expansion
+units - "{", decls(), and "}".  A match for the expansion is a concatenation
+of the matches for the individual expansion units - in this case, that would
+be any string that begins with a "{", ends with a "}", and contains a match
+for decls() in between.
+
+<P>
+<HR>
+<P>
+
+<TABLE>
+<TR>
+<TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="prod22">expansion_unit</A></TD>
+<TD ALIGN=CENTER VALIGN=BASELINE>::=</TD>
+<TD ALIGN=LEFT VALIGN=BASELINE><A HREF="#prod21">local_lookahead</A></TD>
+</TR>
+<TR>
+<TD ALIGN=RIGHT VALIGN=BASELINE></TD>
+<TD ALIGN=CENTER VALIGN=BASELINE>|</TD>
+<TD ALIGN=LEFT VALIGN=BASELINE><EM>java_block</EM></TD>
+</TR>
+<TR>
+<TD ALIGN=RIGHT VALIGN=BASELINE></TD>
+<TD ALIGN=CENTER VALIGN=BASELINE>|</TD>
+<TD ALIGN=LEFT VALIGN=BASELINE>"(" <A HREF="#prod16">expansion_choices</A> ")" [ "+" | "*" | "?" ]</TD>
+</TR>
+<TR>
+<TD ALIGN=RIGHT VALIGN=BASELINE></TD>
+<TD ALIGN=CENTER VALIGN=BASELINE>|</TD>
+<TD ALIGN=LEFT VALIGN=BASELINE>"[" <A HREF="#prod16">expansion_choices</A> "]"</TD>
+</TR>
+<TR>
+<TD ALIGN=RIGHT VALIGN=BASELINE></TD>
+<TD ALIGN=CENTER VALIGN=BASELINE>|</TD>
+<TD ALIGN=LEFT VALIGN=BASELINE>[ <EM>java_assignment_lhs</EM> "=" ] <A HREF="#prod19">regular_expression</A></TD>
+</TR>
+<TR>
+<TD ALIGN=RIGHT VALIGN=BASELINE></TD>
+<TD ALIGN=CENTER VALIGN=BASELINE>|</TD>
+<TD ALIGN=LEFT VALIGN=BASELINE>[ <EM>java_assignment_lhs</EM> "=" ] <EM>java_identifier</EM> "(" <EM>java_expression_list</EM> ")"</TD>
+</TR>
+</TABLE>
+<P>
+
+An expansion unit can be a <A HREF="#prod21">local LOOKAHEAD specification</A>.
+This instructs the
+generated parser on how to make choices at choice points.  For details
+on how LOOKAHEAD specifications work and how to write LOOKAHEAD specifications,
+<A HREF="lookahead.html">click here to visit the minitutorial on LOOKAHEAD</A>.
+<P>
+An expansion unit can be a set of Java declarations and code enclosed
+within braces (the Java block).  These are also called <EM>parser
+actions</EM>.  This is generated into the method parsing the
+non-terminal at the appropriate location.  This block is executed
+whenever the parsing process crosses this point successfully.
+When JavaCC processes the Java block, it does not perform any detailed
+syntax or semantic checking.  Hence it is possible that the Java compiler
+will find errors in your actions that have been processed by JavaCC.
+<EM>Actions are not executed during
+<A HREF="lookahead.html">lookahead evaluation</A>.</EM>
+<P>
+An expansion unit can be a parenthesized set of one or more
+<A HREF="#prod16">expansion choices</A>.  In which case, a legal parse of the expansion
+unit is any legal parse of the nested expansion choices.
+The parenthesized set of expansion choices can be suffixed (optionally) by:
+<UL>
+<LI>
+<STRONG>"+":</STRONG>
+Then any legal parse of the expansion unit is one or more
+repetitions of a legal parse of the parenthesized set of
+expansion choices.
+<LI>
+<STRONG>"*":</STRONG>
+Then any legal parse of the expansion unit is zero or more
+repetitions of a legal parse of the parenthesized set of
+expansion choices.
+<LI>
+<STRONG>"?":</STRONG>
+Then a legal parse of the expansion unit is either the
+empty token sequence or any legal parse of the nested expansion choices.
+An alternate syntax for this construct is to enclose the
+expansion choices within brackets "[...]".
+</UL>
+<P>
+An expansion unit can be a <A HREF="#prod19">regular expression</A>.  Then a legal parse
+of the expansion unit is any token that matches this regular
+expression.  When a regular expression is matched, it creates an
+object of type <A HREF="apiroutines.html">Token</A>.  This object
+can be accessed by assigning it to a variable by prefixing the
+regular expression with "variable =".  In general, you may have any
+valid Java assignment left-hand side to the left of the "=".
+<EM>This assignment is not performed during
+<A HREF="lookahead.html">lookahead evaluation</A>.</EM>
+<P>
+An expansion unit can be a non-terminal (the last choice in the syntax
+above).  In which case, it takes
+the form of a method call with the non-terminal name used as the
+name of the method.  A successful parse of the non-terminal causes
+the parameters placed in the method call to be operated on and a
+value returned (in case the non-terminal was not declared to be
+of type "void").  The return value can be assigned (optionally) to
+a variable by prefixing the regular expression with "variable =".
+In general, you may have any
+valid Java assignment left-hand side to the left of the "=".
+<EM>This assignment is not performed during
+<A HREF="lookahead.html">lookahead evaluation</A>.</EM>
+Non-terminals may not be used in an expansion in a manner that introduces
+left-recursion.  JavaCC checks this for you.
+
+<P>
+<HR>
+<P>
+
+<TABLE>
+<TR>
+<TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="prod21">local_lookahead</A></TD>
+<TD ALIGN=CENTER VALIGN=BASELINE>::=</TD>
+<TD ALIGN=LEFT VALIGN=BASELINE>"LOOKAHEAD" "(" [ <EM>java_integer_literal</EM> ] [ "," ] [ <A HREF="#prod16">expansion_choices</A> ] [ "," ] [ "{" <EM>java_expression</EM> "}" ] ")"</TD>
+</TR>
+</TABLE>
+<P>
+
+A local lookahead specification is used to influence the way the generated
+parser makes choices at the various
+<A HREF="lookahead.html">choice points</A>
+in the grammar.  A local lookahead specification starts with the reserved
+word "LOOKAHEAD" followed by a set of lookahead constraints within parentheses.
+There are three different kinds of lookahead constraints - a lookahead limit
+(the integer literal), a syntactic lookahead (the expansion choices), and
+a semantic lookahead (the expression within braces).  At least one lookahead
+constraint must be present.  If more than one lookahead constraint is present,
+they must be separated by commas.
+<P>
+For a detailed description of how lookahead works, please
+<A HREF="lookahead.html">click here to visit the minitutorial on LOOKAHEAD</A>.
+A brief description of each kind of lookahead constraint is given below:
+<P>
+<UL>
+<LI>
+<STRONG>Lookahead Limit:</STRONG>
+This is the maximum number of tokens of lookahead that may be used for choice
+determination purposes.  This overrides the default value which is specified
+by the <A HREF="#prod2">LOOKAHEAD option</A>.  This lookahead limit applies
+only to the <A HREF="lookahead.html">choice point</A>
+at the location of the local lookahead specification.
+If the local lookahead specification is not at a choice point, the lookahead
+limit (if any) is ignored.
+<P>
+<LI>
+<STRONG>Syntactic Lookahead:</STRONG>
+This is an expansion (or expansion choices) that is used for the purpose of
+determining whether or not the particular choice that this local lookahead
+specification applies to is to be taken.  If this was not provided, the parser
+uses the expansion to be selected during lookahead determination.
+If the local lookahead specification is not at a
+<A HREF="lookahead.html">choice point</A>, the syntactic
+lookahead (if any) is ignored.
+<P>
+<LI>
+<STRONG>Semantic Lookahead:</STRONG>
+This is a boolean expression that is evaluated whenever the parser crosses this
+point during parsing.  If the expression evaluates to true, the parsing
+continues normally.  If the expression evaluates to false and the local
+lookahead specification is at a <A HREF="lookahead.html">choice point</A>,
+the current choice is not taken and the next choice is considered.
+If the expression evaluates to false and the local lookahead specification
+is <EM>not</EM> at a choice point, then parsing aborts with a parse error.
+Unlike the other two lookahead constraints that are ignored at non-choice
+points, semantic lookahead is always evaluated.  In fact, semantic lookahead
+is even evaluated if it is encountered during the evaluation of some other
+syntactic lookahead check (for more details
+<A HREF="lookahead.html">click here to visit the minitutorial on LOOKAHEAD</A>).
+</UL>
+<P>
+<STRONG>Default values for lookahead constraints:</STRONG>
+If a local lookahead specification has been provided, but not all lookahead
+constraints have been included, then the missing ones are assigned default
+values as follows:
+<P>
+<UL>
+<LI>
+If the lookahead limit is not provided and if the syntactic lookahead is
+provided, then the lookahead limit defaults to the largest integer value
+(2147483647).  This essentially implements "infinite lookahead" - namely,
+look ahead as many tokens as necessary to match the syntactic lookahead that
+has been provided.
+<P>
+<LI>
+If neither the lookahead limit nor the syntactic lookahead has been
+provided (which means the semantic lookahead is provided), the lookahead
+limit defaults to 0.  This means that syntactic lookahead is not performed
+(it passes trivially), and only semantic lookahead is performed.
+<P>
+<LI>
+If the syntactic lookahead is not provided, it defaults to the choice
+to which the local lookahead specification applies.  If the local lookahead
+specification is not at a choice point, then the syntactic lookahead is
+ignored - hence a default value is not relevant.
+<P>
+<LI>
+If the semantic lookahead is not provided, it defaults to the boolean
+expression "true".  That is, it trivially passes.
+</UL>
+<P>
+<HR>
+<P>
+
+<TABLE>
+<TR>
+<TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="prod19">regular_expression</A></TD>
+<TD ALIGN=CENTER VALIGN=BASELINE>::=</TD>
+<TD ALIGN=LEFT VALIGN=BASELINE><EM>java_string_literal</EM></TD>
+</TR>
+<TR>
+<TD ALIGN=RIGHT VALIGN=BASELINE></TD>
+<TD ALIGN=CENTER VALIGN=BASELINE>|</TD>
+<TD ALIGN=LEFT VALIGN=BASELINE>"&lt;" [ [ "#" ] <EM>java_identifier</EM> ":" ] <A HREF="#prod29">complex_regular_expression_choices</A> "&gt;"</TD>
+</TR>
+<TR>
+<TD ALIGN=RIGHT VALIGN=BASELINE></TD>
+<TD ALIGN=CENTER VALIGN=BASELINE>|</TD>
+<TD ALIGN=LEFT VALIGN=BASELINE>"&lt;" <EM>java_identifier</EM> "&gt;"</TD>
+</TR>
+<TR>
+<TD ALIGN=RIGHT VALIGN=BASELINE></TD>
+<TD ALIGN=CENTER VALIGN=BASELINE>|</TD>
+<TD ALIGN=LEFT VALIGN=BASELINE>"&lt;" "EOF" "&gt;"</TD>
+</TR>
+</TABLE>
+<P>
+
+There are two places in a grammar files where regular expressions may be
+written:
+<UL>
+<LI>
+Within a <A HREF="#prod18">regular expression specification</A>
+(part of a <A HREF="#prod10">regular expression production</A>),
+<P>
+<LI>
+As an <A HREF="#prod22">expansion unit</A> with an <A HREF="#prod20">expansion</A>.
+When a regular expression is used in this manner, it is as if the regular expression
+were defined in the following manner at this location and then referred to by its
+label from the expansion unit:
+<P>
+<PRE>
+    &lt;DEFAULT&gt; TOKEN :
+    {
+      regular expression
+    }
+</PRE>
+<P>
+That is, this usage of regular expression can be rewritten using the other
+kind of usage.
+</UL>
+<P>
+The complete details of regular expression matching by the token manager is
+available in
+<A HREF="tokenmanager.html">the minitutorial on the token manager</A>.  The
+description of the syntactic constructs follows.
+<P>
+The first kind of regular expression is a string literal.  The input being
+parsed matches this regular expression if the token manager is in a
+<A HREF="#prod10">lexical state</A> for which this regular expression applies
+and the next set of characters in the input stream is the same (possibly with
+case ignored) as this string literal.
+<P>
+A regular expression may also be a more <A HREF="#prod29">complex regular expression</A>
+using which more involved regular expression (than string literals can be defined).
+Such a regular expression is placed within angular brackets "&lt;...&gt;", and
+may be labeled optionally with an identifier.  This label may be used to refer
+to this regular expression from
+<A HREF="#prod22">expansion units</A>
+or from within other regular expressions.
+If the label is preceded by a "#", then this regular expression may not be
+referred to from expansion units, but only from within other regular expressions.
+When the "#" is present, the regular expression is referred to as a
+"private regular expression".
+<P>
+A regular expression may be a reference to some other labeled regular expression
+in which case it is written as the label enclosed in angular brackets "&lt;...&gt;".
+<P>
+Finally, a regular expression may be a reference to the predefined regular
+expression "&lt;EOF&gt;" which is matched by the end of file.
+<P>
+Private regular expressions are not matched as tokens by the token manager.
+Their purpose is solely to facilitate the definition of other more complex
+regular expressions.
+<P>
+Consider the following example defining Java floating point literals:
+<P>
+<PRE>
+TOKEN :
+{
+  < FLOATING_POINT_LITERAL:
+        (["0"-"9"])+ "." (["0"-"9"])* (&lt;EXPONENT>)? (["f","F","d","D"])?
+      | "." (["0"-"9"])+ (&lt;EXPONENT>)? (["f","F","d","D"])?
+      | (["0"-"9"])+ &lt;EXPONENT> (["f","F","d","D"])?
+      | (["0"-"9"])+ (&lt;EXPONENT>)? ["f","F","d","D"]
+  >
+|
+  < #EXPONENT: ["e","E"] (["+","-"])? (["0"-"9"])+ >
+}
+</PRE>
+<P>
+In this example, the token FLOATING_POINT_LITERAL is defined using the
+definition of another token, namely, EXPONENT.  The "#" before the label
+EXPONENT indicates that this exists solely for the purpose of defining other
+tokens (FLOATING_POINT_LITERAL in this case).  The definition of
+FLOATING_POINT_LITERAL is not affected by the presence or absence of the "#".
+However, the token manager's behavior is.  If the "#" is omitted, the
+token manager will
+erroneously recognize a string like E123 as a legal token of kind EXPONENT
+(instead of IDENTIFIER in the Java grammar).
+
+<P>
+<HR>
+<P>
+
+<TABLE>
+<TR>
+<TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="prod29">complex_regular_expression_choices</A></TD>
+<TD ALIGN=CENTER VALIGN=BASELINE>::=</TD>
+<TD ALIGN=LEFT VALIGN=BASELINE><A HREF="#prod30">complex_regular_expression</A> ( "|" <A HREF="#prod30">complex_regular_expression</A> )*</TD>
+</TR>
+</TABLE>
+<P>
+
+Complex regular expression choices is made up of a list of one or more
+<A HREF="#prod30">complex regular expressions</A> separated by "|"s.
+A match for a complex regular expression choice is a match of any of its
+constituent complex regular expressions.
+
+<P>
+<HR>
+<P>
+
+<TABLE>
+<TR>
+<TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="prod30">complex_regular_expression</A></TD>
+<TD ALIGN=CENTER VALIGN=BASELINE>::=</TD>
+<TD ALIGN=LEFT VALIGN=BASELINE>( <A HREF="#prod31">complex_regular_expression_unit</A> )*</TD>
+</TR>
+</TABLE>
+<P>
+
+A complex regular expression is a sequence of complex regular expression units.
+A match for a complex regular expression is a concatenation of matches to
+the complex regular expression units.
+
+<P>
+<HR>
+<P>
+
+<TABLE>
+<TR>
+<TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="prod31">complex_regular_expression_unit</A></TD>
+<TD ALIGN=CENTER VALIGN=BASELINE>::=</TD>
+<TD ALIGN=LEFT VALIGN=BASELINE><EM>java_string_literal</EM></TD>
+</TR>
+<TR>
+<TD ALIGN=RIGHT VALIGN=BASELINE></TD>
+<TD ALIGN=CENTER VALIGN=BASELINE>|</TD>
+<TD ALIGN=LEFT VALIGN=BASELINE>"&lt;" <EM>java_identifier</EM> "&gt;"</TD>
+</TR>
+<TR>
+<TD ALIGN=RIGHT VALIGN=BASELINE></TD>
+<TD ALIGN=CENTER VALIGN=BASELINE>|</TD>
+<TD ALIGN=LEFT VALIGN=BASELINE><A HREF="#prod32">character_list</A></TD>
+</TR>
+<TR>
+<TD ALIGN=RIGHT VALIGN=BASELINE></TD>
+<TD ALIGN=CENTER VALIGN=BASELINE>|</TD>
+<TD ALIGN=LEFT VALIGN=BASELINE>"(" <A HREF="#prod29">complex_regular_expression_choices</A> ")" [ "+" | "*" | "?" ]</TD>
+</TR>
+</TABLE>
+<P>
+
+A complex regular expression unit can be a string literal,  in which case
+there is exactly one match for this unit, namely, the string literal itself.
+<P>
+A complex regular expression unit can be a reference to another regular
+expression.  The other regular expression has to be labeled so that it
+can be referenced.  The matches of this unit are all the matches of this
+other regular expression.  Such references in regular expressions cannot
+introduce loops in the dependency between tokens.
+<P>
+A complex regular expression unit can be a <A HREF="#prod32">character list</A>.
+A character list is a way of defining a set of characters.  A match for this
+kind of complex regular expression unit is any character that is allowed
+by the character list.
+<P>
+A complex regular expression unit can be a parenthesized set of
+complex regular expression choices.  In this case, a legal match of
+the unit is any legal match of the nested choices.  The parenthesized
+set of choices can be suffixed (optionally) by:
+<UL>
+<LI>
+<STRONG>"+":</STRONG>
+Then any legal match of the unit is one or more
+repetitions of a legal match of the parenthesized set of
+choices.
+<LI>
+<STRONG>"*":</STRONG>
+Then any legal match of the unit is zero or more
+repetitions of a legal match of the parenthesized set of
+choices.
+<LI>
+<STRONG>"?":</STRONG>
+Then a legal match of the unit is either the
+empty string or any legal match of the nested choices.
+</UL>
+Note that unlike the BNF <A HREF="#prod20">expansions</A>,
+the regular expression "[...]" is not equivalent
+to the regular expression "(...)?".  This is because the [...]
+construct is used to describe <A HREF="#prod32">character lists</A>
+in regular expressions.
+
+<P>
+<HR>
+<P>
+
+<TABLE>
+<TR>
+<TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="prod32">character_list</A></TD>
+<TD ALIGN=CENTER VALIGN=BASELINE>::=</TD>
+<TD ALIGN=LEFT VALIGN=BASELINE>[ "~" ] "[" [ <A HREF="#prod33">character_descriptor</A> ( "," <A HREF="#prod33">character_descriptor</A> )* ] "]"</TD>
+</TR>
+</TABLE>
+<P>
+
+A character list describes a set of characters.  A legal match for a
+character list is any character in this set.  A character list is a list
+of character descriptors separated by commas within square brackets.
+Each character descriptor describes a single character or a range of characters
+(see <A HREF="#prod33">character descriptor</A> below),
+and this is added to the set of characters of the character
+list.  If the character list is prefixed by the "~" symbol, the set of
+characters it represents is any UNICODE character not in the specified set.
+
+<P>
+<HR>
+<P>
+
+<TABLE>
+<TR>
+<TD ALIGN=RIGHT VALIGN=BASELINE><A NAME="prod33">character_descriptor</A></TD>
+<TD ALIGN=CENTER VALIGN=BASELINE>::=</TD>
+<TD ALIGN=LEFT VALIGN=BASELINE><EM>java_string_literal</EM> [ "-" <EM>java_string_literal</EM> ]</TD>
+</TR>
+</TABLE>
+<P>
+
+A character descriptor can be a single character string literal, in which
+case it describes a singleton set containing that character; or it is
+two single character string literals separated by a "-", in which case, it
+describes the set of all characters in the range between and including these
+two characters.
+
+<P>
+
+</BODY>
+</HTML>
diff --git a/tools/javacc-4.0/doc/javaccreleasenotes.html b/tools/javacc-4.0/doc/javaccreleasenotes.html
new file mode 100644
index 0000000000000000000000000000000000000000..613aebcdad6314a7aa3cc5c2ccbcab5f11e7f964
--- /dev/null
+++ b/tools/javacc-4.0/doc/javaccreleasenotes.html
@@ -0,0 +1,715 @@
+<HTML>
+<!--
+
+Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+intellectual property rights relating to technology embodied in the product
+that is described in this document. In particular, and without limitation,
+these intellectual property rights may include one or more of the U.S.
+patents listed at http://www.sun.com/patents and one or more additional
+patents or pending patent applications in the U.S. and in other countries.
+U.S. Government Rights - Commercial software. Government users are subject
+to the Sun Microsystems, Inc. standard license agreement and applicable
+provisions of the FAR and its supplements.  Use is subject to license terms.
+Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+product is covered and controlled by U.S. Export Control laws and may be
+subject to the export or import laws in other countries.  Nuclear, missile,
+chemical biological weapons or nuclear maritime end uses or end users, whether
+direct or indirect, are strictly prohibited.  Export or reexport to countries
+subject to U.S. embargo or to entities identified on U.S. export exclusion
+lists, including, but not limited to, the denied persons and specially
+designated nationals lists is strictly prohibited.
+
+-->
+<HEAD>
+ <title>JavaCC Release Notes</title>
+<!-- Changed by: Michael Van De Vanter, 14-Jan-2003 -->
+</HEAD>
+<BODY bgcolor="#FFFFFF" >
+
+<H1>JavaCC [tm]: Release Notes</H1>
+
+<pre>
+THIS FILE IS A COMPLETE LOG OF ALL CHANGES THAT HAVE TAKEN PLACE SINCE
+THE RELEASE OF VERSION 0.5 IN OCTOBER, 1996.
+
+AS NOTED HERE, DURING THE TRANSITION FROM 0.5 TO 3.1, THERE HAVE BEEN
+THE FOLLOWING INTERMEDIATE VERSIONS:
+
+	0.6.-10
+	0.6.-9
+	0.6.-8
+	0.6(Beta1)
+	0.6(Beta2)
+	0.6
+	0.6.1
+	0.7pre1
+	0.7pre2
+	0.7pre3
+	0.7pre4
+	0.7pre5
+	0.7pre6
+	0.7pre7
+	0.7
+	0.7.1
+	0.8pre1
+	0.8pre2
+	1.0
+	1.2
+	2.0
+	2.1
+	3.0
+	3.1
+	3.2
+	4.0
+
+
+-------------------------------------------------------------------
+*******************************************************************
+-------------------------------------------------------------------
+
+MODIFICATIONS IN VERSION 4.0
+-------------------------------------------------------------------
+
+See the bug list in issue tracker for all the bugs fixed in this release.
+JJTree and JavaCC both now support 1.5 syntax.
+We now support accessing token fields in the grammar like: s=<ID>.image
+Convenient constructors for passing encoding directly to the grammar
+Tabsetting is now customizable.
+SimpleNode can now extend a class using the NODE_EXTENDS option.
+JAVACODE and BNF productions take optional access modifiers.
+
+-------------------------------------------------------------------
+*******************************************************************
+-------------------------------------------------------------------
+
+MODIFICATIONS IN VERSION 3.2
+-------------------------------------------------------------------
+New regular expression kind with range operator where the upperbound is
+optional, meaning just minimum, no max - (<RE>){n,}
+Fix for issue 41 where it takes exponential time to minimumSize
+
+MODIFICATIONS IN VERSION 3.2
+-------------------------------------------------------------------
+Added the LICENSE file to the installation root directory.
+Fixed issues #: 10, 11, 13, 2, 4, 5, 7
+In particular, the generated code should now compile with JDK 1.5 (Tiger)
+
+-------------------------------------------------------------------
+*******************************************************************
+-------------------------------------------------------------------
+
+MODIFICATIONS IN VERSION 3.1
+-------------------------------------------------------------------
+
+Open source with BSD license.
+Fixed the copyright text in the sourcefiles.
+
+-------------------------------------------------------------------
+*******************************************************************
+-------------------------------------------------------------------
+
+MODIFICATIONS IN VERSION 3.0 (as compared to version 2.1)
+-------------------------------------------------------------------
+
+No GUI version anymore.
+
+Fixed a bug in handling string literals when they intersect some
+regular expression.
+
+Split up initializations of jj_la1_* vars into smaller methods so
+that there is no code size issue. This is a recently reported bug.
+
+-------------------------------------------------------------------
+*******************************************************************
+-------------------------------------------------------------------
+
+MODIFICATIONS IN VERSION 2.1 (as compared to version 2.0)
+-------------------------------------------------------------------
+
+Added a new option - KEEP_LINE_COLUMN default true.
+
+If you set this option to false, the generated CharStream will not
+have any line/column tracking code. It will be your responsibility
+to do it some other way. This is needed for systems which don't care
+about giving error messages etc.
+
+-------------------------------------------------------------------
+
+API Changes: JavaCC no longer generates one of the 4 stream classes:
+
+      ASCII_CharStream
+      ASCII_UCodeESC_CharStream
+      UCode_CharStream
+      UCode_UCodeESC_CharStream
+
+In stead, it now supports two kinds of streams:
+
+      SimpleCharStream
+      JavaCharStream
+
+Both can be instantiated using a Reader object.
+
+SimpleCharStream just reads the characters from the Reader using the
+read(char[], int, int) method. So if you want to support a specific
+encoding - like SJIS etc., you will first create the Reader object
+with that encoding and instantiate the SimpleCharStream with that
+Reader so your encoding is automatically used. This should solve a
+whole bunch of issues with UCode* classes that were reported.
+
+JavaCharStream is pretty much like SimpleCharStream, but it also does
+\uxxxx processing as used by the Java programming language.
+
+Porting old grammars:
+
+Just replace Stream class names as follows -
+
+    if you are using ASCII_CharStream or UCode_CharStream,
+    change it to SimpleCharStream
+
+    if you are using ASCII_UCodeESC_CharStream or UCode_UCodeESC_CharStream,
+    change it to JavaCharStream
+
+The APIs remain the same.
+
+Also, the CharStream interface remains the same. So, if you have been using
+USER_CHAR_STREAM option, then you don't need to change anything.
+
+-------------------------------------------------------------------
+*******************************************************************
+-------------------------------------------------------------------
+
+MODIFICATIONS IN VERSION 2.0 (as compared to version 1.2)
+-------------------------------------------------------------------
+
+Added CPP grammar to examples directory (contributed by Malome Khomo).
+
+-------------------------------------------------------------------
+
+GUI is now available to run JavaCC.  You can control all aspects of
+JJTree and JavaCC (except creating and editing the grammar file)
+through this GUI.
+
+-------------------------------------------------------------------
+
+Desktop icons now available on a variety of platforms so you can
+run JavaCC by double clicking the icon.
+
+-------------------------------------------------------------------
+
+Bash on NT support improved.
+
+-------------------------------------------------------------------
+
+Uninstaller included.
+
+-------------------------------------------------------------------
+
+Fixed some minor bugs.
+
+-------------------------------------------------------------------
+*******************************************************************
+-------------------------------------------------------------------
+
+MODIFICATIONS IN VERSION 1.2 (as compared to version 1.0)
+-------------------------------------------------------------------
+
+Moved JavaCC to the Metamata installer and made it available for
+download from Metamata's web site.
+
+-------------------------------------------------------------------
+
+Added Java 1.2 grammars to the examples directory.
+
+-------------------------------------------------------------------
+
+Added repetition range specifications for regular expressions.
+You can specify exact number of times a particular re should
+occur or a {man, max} range, e.g,
+
+    TOKEN:
+    {
+         &lt; TLA: (["A"-"Z"]){3} &gt; // Three letter acronyms!
+
+      |
+
+         &lt; DOS_FILENAME: (~[".", ":", ";", "\\"]) {1,8}
+                         ( "." (~[".", ":", ";", "\\"]){1,3})? &gt;
+               // An incomplete spec for the DOS file name format
+    }
+
+The translation is right now expanding out these many number of times
+so use it with caution.
+
+-------------------------------------------------------------------
+
+You can now specify actions/state changes for EOF. It is right now
+very strict in that it has to look exactly like:
+
+   &lt;*&gt; TOKEN:
+   {
+      &lt; EOF &gt; { action } : NEW_STATE
+   }
+
+which means that EOF is still EOF in every state except that now
+you can specify what state changes  if any or what java code
+if any to execute on seeing EOF.
+
+This should help in writing grammars for processing C/C++ #include
+files, without going through hoops as in the old versions.
+
+-------------------------------------------------------------------
+*******************************************************************
+-------------------------------------------------------------------
+
+MODIFICATIONS IN VERSION 1.0 (as compared to version 0.8pre2)
+-------------------------------------------------------------------
+
+Fixed bugs related to usage of JavaCC with Java 2.
+
+-------------------------------------------------------------------
+
+Many other bug fixes.
+
+-------------------------------------------------------------------
+*******************************************************************
+-------------------------------------------------------------------
+
+MODIFICATIONS IN VERSION 0.8pre2 (as compared to version 0.8pre1)
+-------------------------------------------------------------------
+
+Mainly bug fixes.
+
+-------------------------------------------------------------------
+*******************************************************************
+-------------------------------------------------------------------
+
+MODIFICATIONS IN VERSION 0.8pre1 (as compared to version 0.7.1)
+-------------------------------------------------------------------
+
+Changed all references to Stream classes in the JavaCC code itself and
+changed them to Reader/Writer.
+
+-------------------------------------------------------------------
+
+Changed all the generated *CharStream classes to use Reader instead of
+InputStream. The names of the generated classes still say *CharStream.
+For compatibility reasons, the old constructors are still supported.
+All the constructors that take InputStream create InputStreamReader
+objects for reading the input data. All users parsing non-ASCII inputs
+should continue to use the InputStream constructors.
+
+-------------------------------------------------------------------
+
+Generate inner classes instead of top level classes where appropriate.
+
+-------------------------------------------------------------------
+*******************************************************************
+-------------------------------------------------------------------
+
+MODIFICATIONS IN VERSION 0.7.1 (as compared to version 0.7)
+-------------------------------------------------------------------
+
+Fixed a bug in the handling of empty PARSER_BEGIN...PARSER_END
+regions.
+
+-------------------------------------------------------------------
+
+Fixed a bug in Java1.1noLA.jj - the improved performance Java grammar.
+
+-------------------------------------------------------------------
+
+Fixed a spurious definition that was being generated into the parser
+when USER_TOKEN_MANAGER was set to true.
+
+-------------------------------------------------------------------
+*******************************************************************
+-------------------------------------------------------------------
+
+MODIFICATIONS IN VERSION 0.7 (as compared to version 0.7pre7)
+-------------------------------------------------------------------
+
+Fixed the error reporting routines to delete duplicate entries from
+the "expected" list.
+
+-------------------------------------------------------------------
+
+Generated braces around the "if (true) ..." construct inserted
+by JavaCC to prevent the dangling else problem.
+
+-------------------------------------------------------------------
+
+Added code to consume_token that performs garbage collections of
+tokens no longer necessary for error reporting purposes.
+
+-------------------------------------------------------------------
+
+Fixed a bug with OPTIMIZE_TOKEN_MANAGER when there is a common prefix
+for two or more (complex) regular expressions.
+
+-------------------------------------------------------------------
+
+Fixed a JJTree bug where a node annotation #P() caused a null pointer
+error.
+
+-------------------------------------------------------------------
+
+Only generate the jjtCreate() methods if the NODE_FACTORY option is
+set.
+
+-------------------------------------------------------------------
+
+Fixed a bug where the name of the JJTree state file was being used in
+the declaration of the field.
+
+-------------------------------------------------------------------
+
+Updated the performance page to demonstrate how JavaCC performance
+has improved since Version 0.5.
+
+-------------------------------------------------------------------
+*******************************************************************
+-------------------------------------------------------------------
+
+MODIFICATIONS IN VERSION 0.7pre7 (as compared to version 0.7pre6)
+-------------------------------------------------------------------
+
+Added an option CACHE_TOKENS with a default value of false.  You
+can generate slightly faster and (it so happens) more compact
+parsers if you set CACHE_TOKENS to true.
+
+-------------------------------------------------------------------
+
+Improved time and space requirements as compared to earlier
+versions - regardless of the setting of CACHE_TOKENS.
+
+Performance has improved roughly 10% (maybe even a little more).
+Space requirements have reduced approximately 30%.
+
+It is now possible to generate a Java parser whose class file is
+only 28K in size.  To do this, run JavaCC on Java1.1noLA.jj with
+options ERROR_REPORTING=false and CACHE_TOKENS=true.
+
+And over the next few months, there is still places where space
+and time can be trimmed!
+
+-------------------------------------------------------------------
+
+The token_mask arrays are completely gone and replaced by bit
+vectors.
+
+-------------------------------------------------------------------
+
+Nested switch statements have been flattened.
+
+-------------------------------------------------------------------
+
+Fixed a bug in the outputting of code to generate a method
+
+    jjCheckNAddStates(int i)
+
+calls to which are generated, but not the method.
+
+-------------------------------------------------------------------
+
+Generating the `static' keyword for the backup method of the
+UCode*.java files when STATIC flag is set.
+
+-------------------------------------------------------------------
+*******************************************************************
+-------------------------------------------------------------------
+
+MODIFICATIONS IN VERSION 0.7pre6 (as compared to version 0.7pre5)
+-------------------------------------------------------------------
+
+Extended the generated CharStream classes with a method to adjust the
+line and column numbers for the beginning of a token.  Look at the C++
+grammar in the distribution to see an example usage.
+
+-------------------------------------------------------------------
+
+Fixed the JavaCC front-end so that error messages are given with line
+numbers relative to the original .jjt file if the .jj file is generated
+by pre-processing using jjtree.
+
+-------------------------------------------------------------------
+
+Removed support for old deprecated features:
+
+. IGNORE_IN_BNF can no longer be used.  Until this version, you
+  would get a deprecated warning message if you did use it.
+
+. The extra {} in TOKEN specifications can no longer be used.  Until
+  this version, you would get a deprecated warning message if your
+  did use it.
+
+-------------------------------------------------------------------
+
+ParseError is no longer supported.  It is now ParseException.  Please
+delete the existing generated files for ParseError and ParseException.
+The right ParseException will automatically get regenerated.
+
+-------------------------------------------------------------------
+
+Completed step 1 in getting rid of the token mask arrays.  This
+occupies space and is also somewhat inefficient.  Essentially,
+replaced all "if" statements that test a token mask entry with
+faster "switch" statements.  The token mask array still exist for
+error reporting - but they will be removed in the next step (in
+the next release).  As a result, we have noticed improved parser
+speeds (up to 10% for the Java grammar).
+
+As a consequence of doing step 1, but not step 2, the size of the
+generated parser has increased a small amount.  When step 2 is
+completed, the size of the generated parser will go down to be even
+smaller than what it was before.
+
+-------------------------------------------------------------------
+
+Cache tokens one step ahead during parsing for performance reasons.
+
+-------------------------------------------------------------------
+
+Made the static token mask fields "final".  Note that the token
+mask arrays will go away in the next release.
+
+-------------------------------------------------------------------
+
+The Java 1.1 grammar was corrected to allow interfaces nested within
+blocks.  The JavaCC grammar was corrected to fix a bug in its
+handling of the "&gt;&gt;&gt;=" operator.
+
+-------------------------------------------------------------------
+
+Fixed a bug in the optimizations of the lexical analyzer.
+
+-------------------------------------------------------------------
+
+Many changes have been made to JJTree.  See the JJTree release
+notes for more information.
+
+-------------------------------------------------------------------
+*******************************************************************
+-------------------------------------------------------------------
+
+MODIFICATIONS IN VERSION 0.7pre5 (as compared to version 0.7pre4)
+-------------------------------------------------------------------
+
+Fixed a bug with TOKEN_MGR_DECLS introduced in 0.7pre4.
+
+-------------------------------------------------------------------
+
+Enhanced JavaCC input grammar to allow JavaCC reserved words in
+Java code (such as actions).  This too was disallowed in 0.7pre4
+only and has been rectified.
+
+-------------------------------------------------------------------
+
+The JavaCC+JJTree grammar is now being offered to our users.  You
+can find it in the examples directory.
+
+-------------------------------------------------------------------
+
+Fixed an array index out of bounds bug in the parser - that sometimes
+can happen when a non-terminal can expand to more than 100 other
+non-terminals.
+
+-------------------------------------------------------------------
+
+Fixed a bug in generating parsers with USER_CHAR_STREAM set to true.
+
+-------------------------------------------------------------------
+
+Created an alternate Java 1.1 grammar in which lookaheads have been
+modified to minimize the space requirements of the generated
+parser.  See the JavaGrammars directory under the examples directory.
+
+-------------------------------------------------------------------
+
+Provided instructions on how you can make your own grammars space
+efficient (until JavaCC is improved to do this).  See the
+JavaGrammars directory under the examples directory.
+
+-------------------------------------------------------------------
+
+Updated all examples to make them current.  Some examples had become
+out of date due to newer versions of JavaCC.
+
+-------------------------------------------------------------------
+
+Updated the VHDL example - Chris Grimm made a fresh contribution.
+This seems to be a real product quality example now.
+
+-------------------------------------------------------------------
+
+Fixed bugs in the Obfuscator example that has started being used
+for real obfuscation by some users.
+
+-------------------------------------------------------------------
+
+The token manager class is non-final (this was a bug).
+
+-------------------------------------------------------------------
+
+Many changes have been made to JJTree.  See the JJTree release
+notes for more information.
+
+-------------------------------------------------------------------
+
+Fixed all token manager optimization bugs that we know about.
+
+-------------------------------------------------------------------
+
+Fixed all UNICODE lexing bugs that we know about.
+
+-------------------------------------------------------------------
+
+Fixed an array index out of bounds bug in the token manager.
+
+-------------------------------------------------------------------
+*******************************************************************
+-------------------------------------------------------------------
+
+MODIFICATIONS IN VERSION 0.7pre4 (as compared to version 0.7pre3)
+-------------------------------------------------------------------
+
+The only significant change for this version is that we incorporated
+the Java grammar into the JavaCC grammar.  The JavaCC front end is
+therefore able to parse the entire grammar file intelligently rather
+than simple ignore the actions.
+
+-------------------------------------------------------------------
+*******************************************************************
+-------------------------------------------------------------------
+
+MODIFICATIONS IN VERSION 0.7pre3 (as compared to version 0.7pre2)
+-------------------------------------------------------------------
+
+WE HAVE NOT ADDED ANY MAJOR FEATURES TO JAVACC FOR THIS PRERELEASE.
+WE'VE FOCUSED MAINLY ON BUG FIXES.  BUT HERE IS WHAT HAS CHANGED:
+
+-------------------------------------------------------------------
+
+Fixed the JavaCC license agreement to allow redistributions of example
+grammars.
+
+-------------------------------------------------------------------
+
+Fixed a couple of bugs in the JavaCC grammar.
+
+-------------------------------------------------------------------
+
+Fixed an obscure bug that caused spurious '\r's to be generated
+on Windows machines.
+
+-------------------------------------------------------------------
+
+Changed the generated *CharStream classes to take advantage of the
+STATIC flag setting.  With this (like the token manager and parser)
+the *CharStream class also will have all the methods and variables to
+be static with STATIC flag.
+
+-------------------------------------------------------------------
+
+A new option OPTIMIZE_TOKEN_MANAGER is introduced. It defaults to
+true.  When this option is set, optimizations for the TokenManager, in
+terms of size *and* time are performed.
+
+This option is automatically set to false if DEBUG_TOKEN_MANAGER is
+set to true.
+
+The new option OPTIMIZE_TOKEN_MANAGER might do some unsafe
+optimization that can cause your token manager not to compile or run
+properly. While we don't expect this to happen that much, in case it
+happens, just turn off the option so that those optimizations will not
+happen and you can continue working. Also, if this happens, please
+send us the grammar so we can analyze the problem and fix JavaCC.
+
+-------------------------------------------------------------------
+
+A String-valued option OUTPUT_DIRECTORY is implemented. This can be
+used to instruct JavaCC to generate all the code files in a particular
+directory.  By default, this is set to user.dir.
+
+-------------------------------------------------------------------
+
+Fixed a minor bug (in 0.7pre2) in that the specialToken field was not
+being set before a lexical action for a TOKEN type reg. exp.
+
+-------------------------------------------------------------------
+
+Added a toString method to the Token class to return the image.
+
+
+-------------------------------------------------------------------
+*******************************************************************
+-------------------------------------------------------------------
+
+MODIFICATIONS IN VERSION 0.7pre2 (as compared to version 0.7pre1)
+
+-------------------------------------------------------------------
+
+AS USUAL, KEEP IN MIND THAT THIS IS A PRERELEASE THAT WE HAVE NOT
+TESTED EXTENSIVELY.  THERE ARE A FEW KNOWN BUGS THAT ARE STILL PRESENT
+IN THIS VERSION.  QUALITY CONTROL FOR PRERELEASES ARE SIGNIFICANTLY
+LOWER THAN STABLE RELEASES - I.E., WE DON'T MIND THE PRESENCE OF BUGS
+THAT WE WOULD FEEL EMBARRASSED ABOUT IN STABLE RELEASES.
+
+-------------------------------------------------------------------
+
+Main feature release for 0.7pre2 is a completely redone JJTree.  It
+now bootstraps itself.  See the JJTree release notes for more
+information.
+
+-------------------------------------------------------------------
+
+Error recovery constructs have been modified a bit from 0.7pre1.  The
+parser methods now throw only ParseException by default.  You can now
+specify a "throws" clause with your non-terminals to add other
+exceptions to this list explicitly.  Please see the help web page at:
+
+   http://www.suntest.com/JavaCCBeta/newerrorhandling.html
+
+for complete information on error recovery.
+
+-------------------------------------------------------------------
+
+A new Java grammar improved for performance in the presence of very
+complex expressions is now included.  This is NewJava1.1.jj.
+
+-------------------------------------------------------------------
+
+More optimizations for the size of the token manager's java and class
+files.  The generated .java files are about 10-15% smaller that
+0.7pre1 (and 40-45%) smaller compared to 0.6. The class files (with
+-O) are about 20% smaller compared to 0.6.
+
+-------------------------------------------------------------------
+
+The parser size has been decreased.  The current optimizations affect
+grammars that have small amounts of non-1 lookaheads.  For example the
+generated code for the Java grammar has now reduced by 10%.
+
+-------------------------------------------------------------------
+
+Extended the Token class to introduce a new factory function that
+takes the token kind and returns a new Token object. This is done to
+facilitate creating Objects of subclasses of Token based on the kind.
+Look at the generated file Token.java for more details.
+
+-------------------------------------------------------------------
+
+The restriction on the input size (to be &lt; 2 gbytes) for the token
+manager is gone.  Now the lexer can tokenize any size input (no
+limit).
+
+-------------------------------------------------------------------
+
+Removed all the references to System.out.println in the *CharStream
+classes.  Now all these are thrown as Error objects.
+
+-------------------------------------------------------------------
+
+Fixed a very old problem with giving input from System.in. Previously
+for the EOF, you needed to give  or 
diff --git a/tools/javacc-4.0/doc/jjdocreleasenotes.html b/tools/javacc-4.0/doc/jjdocreleasenotes.html
new file mode 100644
index 0000000000000000000000000000000000000000..f435d31a5ebd36469e0f7d22f093ffe369585ef8
--- /dev/null
+++ b/tools/javacc-4.0/doc/jjdocreleasenotes.html
@@ -0,0 +1,126 @@
+<HTML>
+<!--
+
+Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+intellectual property rights relating to technology embodied in the product
+that is described in this document. In particular, and without limitation,
+these intellectual property rights may include one or more of the U.S.
+patents listed at http://www.sun.com/patents and one or more additional
+patents or pending patent applications in the U.S. and in other countries.
+U.S. Government Rights - Commercial software. Government users are subject
+to the Sun Microsystems, Inc. standard license agreement and applicable
+provisions of the FAR and its supplements.  Use is subject to license terms.
+Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+product is covered and controlled by U.S. Export Control laws and may be
+subject to the export or import laws in other countries.  Nuclear, missile,
+chemical biological weapons or nuclear maritime end uses or end users, whether
+direct or indirect, are strictly prohibited.  Export or reexport to countries
+subject to U.S. embargo or to entities identified on U.S. export exclusion
+lists, including, but not limited to, the denied persons and specially
+designated nationals lists is strictly prohibited.
+
+-->
+<HEAD>
+ <title>JavaCC: JJDoc Release Notes</title>
+<!-- Changed by: Michael Van De Vanter, 14-Jan-2003 -->
+</HEAD>
+<BODY bgcolor="#FFFFFF" >
+
+<H1>JavaCC [tm]: JJDoc Release Notes</H1>
+
+<pre>
+=================================
+Changes from JJDoc 0.1.4 to 0.1.5
+=================================
+
+----------------------------------------------------------------
+
+Fixed bug where Writers were not being closed correctly.
+
+----------------------------------------------------------------
+
+=================================
+Changes from JJDoc 0.1.3 to 0.1.4
+=================================
+
+----------------------------------------------------------------
+
+Now accepts JavaCC try/catch/finally blocks.
+
+----------------------------------------------------------------
+
+=================================
+Changes from JJDoc 0.1.2 to 0.1.3
+=================================
+
+----------------------------------------------------------------
+
+Made appropriate internal modifications for the JavaCC 0.7 parse error
+exceptions.
+
+----------------------------------------------------------------
+
+=================================
+Changes from JJDoc 0.1.1 to 0.1.2
+=================================
+
+----------------------------------------------------------------
+
+Fixed bug where ()+ expansions were being reported as ()*.
+
+----------------------------------------------------------------
+
+===============================
+Changes from JJDoc 0.1 to 0.1.1
+===============================
+
+----------------------------------------------------------------
+
+Fixed several stupid bugs in the Macintosh main class.
+
+----------------------------------------------------------------
+
+Fixed bug where production comments were being generated multiple
+times in text modes and one table HTML mode.
+
+----------------------------------------------------------------
+
+Moved production comments to the correct place: they were coming out
+with the preceding production in one table HTML mode.
+
+----------------------------------------------------------------
+
+=========
+JJDoc 0.1
+=========
+
+JJDoc takes a JavaCC parser specification and produces documentation
+for the BNF grammar.  It can operate in three modes, determined by
+command line options.
+
+    TEXT                   (default false)
+
+Setting TEXT to true causes JJDoc to generate a plain text format
+description of the BNF.  Some formatting is done via tab characters,
+but the intention is to leave it as plain as possible.
+
+The default value of TEXT causes JJDoc to generate a hyperlinked HTML
+document.
+
+    ONE_TABLE              (default true)
+
+The default value of ONE_TABLE is used to generate a single HTML table
+for the BNF.  Setting it to false will produce one table for every
+production in the grammar.
+
+    OUTPUT_FILE
+
+The default behavior is to put the JJDoc output into a file with
+either .html or .txt added as a suffix to the input file's base name.
+You can supply a different file name with this option.
+</pre>
+
+</BODY>
+</HTML>
diff --git a/tools/javacc-4.0/doc/jjtreeREADME.html b/tools/javacc-4.0/doc/jjtreeREADME.html
new file mode 100644
index 0000000000000000000000000000000000000000..cb9a2ce2379240d76d55872cf237b899f7a34d0b
--- /dev/null
+++ b/tools/javacc-4.0/doc/jjtreeREADME.html
@@ -0,0 +1,201 @@
+<HTML>
+<!--
+
+Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+intellectual property rights relating to technology embodied in the product
+that is described in this document. In particular, and without limitation,
+these intellectual property rights may include one or more of the U.S.
+patents listed at http://www.sun.com/patents and one or more additional
+patents or pending patent applications in the U.S. and in other countries.
+U.S. Government Rights - Commercial software. Government users are subject
+to the Sun Microsystems, Inc. standard license agreement and applicable
+provisions of the FAR and its supplements.  Use is subject to license terms.
+Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+product is covered and controlled by U.S. Export Control laws and may be
+subject to the export or import laws in other countries.  Nuclear, missile,
+chemical biological weapons or nuclear maritime end uses or end users, whether
+direct or indirect, are strictly prohibited.  Export or reexport to countries
+subject to U.S. embargo or to entities identified on U.S. export exclusion
+lists, including, but not limited to, the denied persons and specially
+designated nationals lists is strictly prohibited.
+
+-->
+<HEAD>
+ <title>JavaCC: JJTree README</title>
+<!-- Changed by: Michael Van De Vanter, 14-Jan-2003 -->
+</HEAD>
+<BODY bgcolor="#FFFFFF" >
+
+<H1>JavaCC [tm]: README for JJTreeExamples</H1>
+
+<PRE>
+JJTreeExamples
+
+This directory contains some simple JJTree input files intended to
+illustrate some of the basic ideas.  All of them are based on an
+grammar to recognize arithmetic expressions built out of identifiers
+and constants.
+
+eg1.jjt
+
+This example is just the JavaCC [tm] grammar, with a little extra code in
+the parser's main method to call the dump method on the generated
+tree.  It illustrates how the default behavior of JJTree will produce
+a tree of non-terminals.
+
+eg2.jjt
+
+This example is the same grammar as eg1.jjt with modifications to
+customize the generated tree.  It illustrates how unnecessary
+intermediate nodes can be suppressed, and how actions in the grammar
+can attach extra information to the nodes.
+
+eg3.jjt
+
+This example is a modification of eg2.jjt with the NODE_DEFAULT_VOID
+option set.  This instructs JJTree to treat all undecorated
+non-terminals as if they were decorated as #void. The default JJTree
+behavior is to treat such non-terminals as if they were decorated
+with the name of the non-terminal.
+
+eg4.jjt
+
+This is a modification of eg3.jjt with the VISITOR option set.  This
+instructs JJTree to insert a jjtAccept() method into all nodes it
+generates, and to produce a visitor class.  The visitor is used to
+dump the tree.
+
+
+Here are some instructions on how to run the examples and the output
+you can expect to see.
+
+eg1.jjt
+-------
+
+The only bit of JJTree-specific code is an action in the start
+production that dumps the constructed parse tree when the parse is
+complete.  It uses JJTree simple mode.
+
+The input file is eg1.jjt.
+
+trane% jjtree eg1.jjt
+<<< Version and copyright info>>>
+(type "jjtree" with no arguments for help)
+Reading from file eg1.jjt . . .
+Annotated grammar generated successfully in eg1.jj
+trane% 
+
+JJTree has now generated the JavaCC parser source, as well as Java
+source for the parse tree node building classes.  Running JavaCC in
+the normal way generates the remaining Java code.
+
+trane% javacc eg1.jj
+<<< Version and copyright info>>>
+(type "javacc" with no arguments for help)
+Reading from file eg1.jj . . .
+File "TokenMgrError.java" does not exist.  Will create one.
+File "ParseException.java" does not exist.  Will create one.
+File "Token.java" does not exist.  Will create one.
+File "ASCII_CharStream.java" does not exist.  Will create one.
+Parser generated successfully.
+trane% 
+
+Compile and run the Java program as usual.  The expression is read from the
+standard input (you type in "(a + b) * (c + 1);"):
+
+trane% javac eg1.java
+trane% java eg1
+Reading from standard input...
+(a + b) * (c + 1);
+Start
+ Expression
+  AdditiveExpression
+   MultiplicativeExpression
+    UnaryExpression
+     Expression
+      AdditiveExpression
+       MultiplicativeExpression
+        UnaryExpression
+         Identifier
+       MultiplicativeExpression
+        UnaryExpression
+         Identifier
+    UnaryExpression
+     Expression
+      AdditiveExpression
+       MultiplicativeExpression
+        UnaryExpression
+         Identifier
+       MultiplicativeExpression
+        UnaryExpression
+         Integer
+Thank you.
+trane% 
+
+eg2.jjt
+-------
+
+This is a modification of the first example to illustrate how the
+parse tree can be customized:
+
+trane% jjtree eg2.jjt 
+<<< Version and copyright info>>>
+(type "jjtree" with no arguments for help)
+Reading from file eg2.jjt . . .
+File "Node.java" does not exist.  Will create one.
+File "SimpleNode.java" does not exist.  Will create one.
+File "ASTStart.java" does not exist.  Will create one.
+File "ASTAdd.java" does not exist.  Will create one.
+File "ASTMult.java" does not exist.  Will create one.
+File "ASTInteger.java" does not exist.  Will create one.
+Annotated grammar generated successfully in eg2.jj
+trane% 
+trane% javacc eg2.jj
+<<< Version and copyright info>>>
+(type "javacc" with no arguments for help)
+Reading from file eg2.jj . . .
+File "TokenMgrError.java" does not exist.  Will create one.
+File "ParseException.java" does not exist.  Will create one.
+File "Token.java" does not exist.  Will create one.
+File "ASCII_CharStream.java" does not exist.  Will create one.
+Parser generated successfully.
+trane% 
+trane% javac eg2.java
+trane% java eg2
+Reading from standard input...
+(a + b) * (c + 1);
+Start
+ Mult
+  Add
+   Identifier: a
+   Identifier: b
+  Add
+   Identifier: c
+   Integer
+Thank you.
+trane% 
+
+Look at eg2.jjt to see how node annotations can be used to restructure
+the parse tree, and at ASTMyID.java to see how you can write your own
+node classes that maintain more information from the input stream.
+
+eg3.jjt
+-------
+
+This example can be run in the same manner as you ran eg2.jjt.
+
+eg4.jjt
+-------
+
+This example again can be run in the same manner as you ran eg2.jjt.
+One thing to take care in this case is that you must run jjtree on
+a clean directory (that does not contain previously generated files).
+For example, the file SimpleNode.java is different when the option
+VISITOR is set to true.
+</PRE>
+<P>
+
+</BODY>
+</HTML>
diff --git a/tools/javacc-4.0/doc/jjtreeintro.html b/tools/javacc-4.0/doc/jjtreeintro.html
new file mode 100644
index 0000000000000000000000000000000000000000..66a0d3c3ccb5bacb9044c08e6b21237f7e93efb4
--- /dev/null
+++ b/tools/javacc-4.0/doc/jjtreeintro.html
@@ -0,0 +1,466 @@
+<HTML>
+<!--
+
+Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+intellectual property rights relating to technology embodied in the product
+that is described in this document. In particular, and without limitation,
+these intellectual property rights may include one or more of the U.S.
+patents listed at http://www.sun.com/patents and one or more additional
+patents or pending patent applications in the U.S. and in other countries.
+U.S. Government Rights - Commercial software. Government users are subject
+to the Sun Microsystems, Inc. standard license agreement and applicable
+provisions of the FAR and its supplements.  Use is subject to license terms.
+Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+product is covered and controlled by U.S. Export Control laws and may be
+subject to the export or import laws in other countries.  Nuclear, missile,
+chemical biological weapons or nuclear maritime end uses or end users, whether
+direct or indirect, are strictly prohibited.  Export or reexport to countries
+subject to U.S. embargo or to entities identified on U.S. export exclusion
+lists, including, but not limited to, the denied persons and specially
+designated nationals lists is strictly prohibited.
+
+-->
+<HEAD>
+ <title>JavaCC: JJTree Introduction</title>
+<!-- Changed by: Michael Van De Vanter, 14-Jan-2003 -->
+</HEAD>
+<BODY bgcolor="#FFFFFF" >
+
+<H1>JavaCC [tm]: JJTree Introduction</H1>
+
+<pre>
+JJTree is a preprocessor for JavaCC [tm] that inserts parse tree building actions
+at various places in the JavaCC source. The output of JJTree is run through
+JavaCC to create the parser. This document describes how to use JJTree, and
+how you can interface your parser to it.
+
+By default, JJTree generates code to construct parse tree nodes for each
+nonterminal in the language. This behavior can be modified so that some
+nonterminals do not have nodes generated, or so that a node is generated for a
+part of a production's expansion.
+
+JJTree defines a Java interface Node that all parse tree nodes must
+implement. The interface provides methods for operations such as setting the
+parent of the node, and for adding children and retrieving them.
+
+JJTree operates in one of two modes, simple and multi (for want of better
+terms). In simple mode, each parse tree node is of concrete type SimpleNode; in
+multi mode, the type of the parse tree node is derived from the name of the
+node. If you don't provide implementations for the node classes JJTree will
+generate sample implementations based on SimpleNode for you. You can then
+modify the implementations to suit.
+
+Although JavaCC is a top-down parser, JJTree constructs the parse tree from
+the bottom up. To do this it uses a stack where it pushes nodes after they
+have been created. When it finds a parent for them, it pops the children from
+the stack and adds them to the parent, and finally pushes the new parent node
+itself. The stack is open, which means that you have access to it from within
+grammar actions: you can push, pop and otherwise manipulate its contents
+however you feel appropriate. See Node Scopes and User Actions below for more
+important information.
+
+JJTree provides decorations for two basic varieties of nodes, and some
+syntactic shorthand to make their use convenient.
+     1.
+
+        A definite node is constructed with a specific number of
+        children. That many nodes are popped from the stack and made the
+        children of the new node, which is then pushed on the stack
+        itself. You notate a definite node like this:
+
+        #ADefiniteNode(INTEGER EXPRESSION)
+
+        A definite node descriptor expression can be any integer expression,
+        although literal integer constants are by far the most common
+        expressions.
+     2.
+
+        A conditional node is constructed with all of the children that were
+        pushed on the stack within its node scope if and only if its condition
+        evaluates to true. If it evaluates to false, the node is not
+        constructed, and all of the children remain on the node stack. You
+        notate a conditional node like this:
+
+        #ConditionalNode(BOOLEAN EXPRESSION)
+
+        A conditional node descriptor expression can be any boolean
+        expression. There are two common shorthands for conditional nodes:
+         1)
+
+            Indefinite nodes
+
+            #IndefiniteNode is short for #IndefiniteNode(true)
+         2)
+
+            Greater-than nodes
+
+            #GTNode(>1) is short for #GTNode(jjtree.arity() > 1)
+
+        The indefinite node shorthand (1) can lead to ambiguities in the
+        JJTree source when it is followed by a parenthesized expansion. In
+        those cases the shorthand must be replaced by the full expression. For
+        example:
+
+        
+        	  ( ... ) #N ( a() )
+
+        is ambiguous; you have to use the explicit condition:
+
+                  ( ... ) #N(true) ( a() )
+
+WARNING: node descriptor expression should not have side-effects. JJTree
+doesn't specify how many times the expression will be evaluated.
+
+By default JJTree treats each nonterminal as an indefinite node and derives
+the name of the node from the name of its production. You can give it a
+different name with the following syntax:
+
+
+    void P1() #MyNode : { ... } { ... }
+
+When the parser recognizes a P1 nonterminal it begins an indefinite node. It
+marks the stack, so that any parse tree nodes created and pushed on the stack
+by nonterminals in the expansion for P1 will be popped off and made children
+of the node MyNode.
+
+If you want to suppress the creation of a node for a production, you can use
+the following syntax:
+
+
+    void P2() #void : { ... } { ... }
+
+Now any parse tree nodes pushed by nonterminals in the expansion of P2 will
+remain on the stack, to be popped and made children of a production further up
+the tree. You can make this the default behavior for non-decorated nodes by
+using the NODE_DEFAULT_VOID option.
+
+
+    void P3() : {}
+    {
+        P4() ( P5() )+ P6()
+    }
+
+In this example, an indefinite node P3 is begun, marking the stack, and then a
+P4 node, one or more P5 nodes and a P6 node are parsed. Any nodes that they
+push are popped and made the children of P3. You can further customize the
+generated tree:
+
+
+    void P3() : {}
+    {
+        P4() ( P5() )+ #ListOfP5s P6()
+    }
+
+Now the P3 node will have a P4 node, a ListOfP5s node and a P6 node as
+children. The #Name construct acts as a postfix operator, and its scope is the
+immediately preceding expansion unit.
+
+Node Scopes and User Actions
+
+Each node is associated with a node scope. User actions within this scope can
+access the node under construction by using the special identifier jjtThis to
+refer to the node. This identifier is implicitly declared to be of the correct
+type for the node, so any fields and methods that the node has can be easily
+accessed.
+
+A scope is the expansion unit immediately preceding the node decoration. This
+can be a parenthesized expression. When the production signature is decorated
+(perhaps implicitly with the default node), the scope is the entire right hand
+side of the production including its declaration block.
+
+You can also use an expression involving jjtThis on the left hand side of an
+expansion reference. For example:
+
+
+    ... ( jjtThis.my_foo = foo() ) #Baz ...
+
+Here jjtThis refers to a Baz node, which has a field called my_foo. The result
+of parsing the production foo() is assigned to that my_foo.
+
+The final user action in a node scope is different from all the others. When
+the code within it executes, the node's children have already been popped from
+the stack and added to the node, which has itself been pushed onto the
+stack. The children can now be accessed via the node's methods such as
+jjtGetChild().
+
+User actions other than the final one can only access the children on the
+stack. They have not yet been added to the node, so they aren't available via
+the node's methods.
+
+A conditional node that has a node descriptor expression that evaluates to
+false will not get added to the stack, nor have children added to it. The
+final user action within a conditional node scope can determine whether the
+node was created or not by calling the nodeCreated() method. This returns true
+if the node's condition was satisfied and the node was created and pushed on
+the node stack, and false otherwise.
+
+Exception handling
+
+An exception thrown by an expansion within a node scope that is not caught
+within the node scope is caught by JJTree itself. When this occurs, any nodes
+that have been pushed on to the node stack within the node scope are popped
+and thrown away. Then the exception is rethrown.
+
+The intention is to make it possible for parsers to implement error recovery
+and continue with the node stack in a known state.
+
+WARNING: JJTree currently cannot detect whether exceptions are thrown from
+user actions within a node scope. Such an exception will probably be handled
+incorrectly.
+
+Node Scope Hooks
+
+If the NODE_SCOPE_HOOK option is set to true, JJTree generates calls to two
+user-defined parser methods on the entry and exit of every node scope. The
+methods must have the following signatures:
+
+
+    void jjtreeOpenNodeScope(Node n)
+    void jjtreeCloseNodeScope(Node n)
+
+If the parser is STATIC then these methods will have to be declared as static
+as well. They are both called with the current node as a parameter.
+
+One use for these functions is to store the node's first and last tokens so
+that the input can be easily reproduced again. For example:
+
+
+    void jjtreeOpenNodeScope(Node n)
+    {
+      ((MySimpleNode)n).first_token = getToken(1);
+    }
+
+    void jjtreeCloseNodeScope(Node n)
+    {
+      ((MySimpleNode)n).last_token = getToken(0);
+    }
+
+where MySimpleNode is based on SimpleNode and has the following additional
+fields:
+
+
+    Token first_token, last_token;
+
+Another use might be to store the parser object itself in the node so that
+state that should be shared by all nodes produced by that parser can be
+provided. For example, the parser might maintain a symbol table.
+
+The Life Cycle of a Node
+
+A node goes through a well determined sequence of steps as it is built. The
+following
+is that sequence viewed from the perspective of the node itself:
+     1. the node's constructor is called with a unique integer parameter. This
+        parameter identifies the kind of node and is especially useful in
+        simple mode. JJTree automatically generates a file called
+        parserTreeConstants.java and declares Java constants for the node
+        identifiers. It also declares an array of Strings called jjtNodeName[]
+        which maps the identifier integers to the names of the nodes.
+     2. the node's jjtOpen() method is called.
+     3. if the option NODE_SCOPE_HOOK is set, the user-defined parser method
+        openNodeScope() is called and passed the node as its parameter. This
+        method can initialize fields in the node or call its methods. For
+        example, it might store the node's first token in the node.
+     4. if an unhandled exception is thrown while the node is being parsed
+        then the node is abandoned. JJTree will never refer to it again. It
+        will not be closed, and the user-defined node scope hook
+        closeNodeHook() will not be called with it as a parameter.
+     5. otherwise, if the node is conditional and its conditional expression
+        evaluates to false then the node is abandoned. It will not be closed,
+        although the user-defined node scope hook closeNodeHook() might be
+        called with it as a parameter.
+     6. otherwise, all of the children of the node as specified by the integer
+        expression of a definite node, or all the nodes that were pushed on
+        the stack within a conditional node scope are added to the node. The
+        order they are added is not specified.
+     7. the node's jjtClose() method is called.
+     8. the node is pushed on the stack.
+     9. if the option NODE_SCOPE_HOOK is set, the user-defined parser method
+        closenNodeScope() is called and passed the node as its parameter.
+    10. if the node is not the root node, it is added as a child of another
+        node and its jjtSetParent() method is called.
+
+Visitor Support
+
+JJTree provides some basic support for the visitor design pattern. If the
+VISITOR option is set to true, JJTree will insert an jjtAccept() method into
+all of the node classes it generates, and also generate a visitor interface
+that can be implemented and passed to the nodes to accept.
+
+The name of the visitor interface is constructed by appending Visitor to the
+name of the parser. The interface is regenerated every time that JJTree is
+run, so that it accurately represents the set of nodes used by the
+parser. This will cause compile time errors if the implementation class has
+not been updated for the new nodes. This is a feature.
+
+Options
+
+JJTree 0.3pre4 supports the following options on the command line and in the
+JavaCC options statement:
+
+    BUILD_NODE_FILES (default: true)
+      Generate sample implementations for SimpleNode and any other nodes used
+      in the grammar.
+
+    MULTI (default: false)
+      Generate a multi mode parse tree. The default for this is false,
+      generating a simple mode parse tree.
+
+    NODE_DEFAULT_VOID (default: false)
+      Instead of making each non-decorated production an indefinite node, make
+      it void instead.
+
+    NODE_FACTORY (default: false)
+      Use a factory method with following signature to construct nodes:
+      public static Node jjtCreate(int id)
+
+    NODE_PACKAGE (default: "")
+      The package to generate the node classes into. The default for this is
+      the parser package.
+
+    NODE_PREFIX (default: "AST")
+      The prefix used to construct node class names from node identifiers in
+      multi mode. The default for this is AST.
+
+    NODE_SCOPE_HOOK (default: false)
+      Insert calls to user-defined parser methods on entry and exit of every
+      node scope. See Node Scope Hooks above.
+
+    NODE_USES_PARSER (default: false)
+      JJTree will use an alternate form of the node construction routines
+      where it passes the parser object in. For example,
+
+      public static Node MyNode.jjtCreate(MyParser p, int id);
+      MyNode(MyParser p, int id);
+
+    STATIC (default: true)
+      Generate code for a static parser. The default for this is true. This
+      must be used consistently with the equivalent JavaCC options. The value
+      of this option is emitted in the JavaCC source.
+
+    VISITOR (default: false)
+      Insert a jjtAccept() method in the node classes, and generate a visitor
+      implementation with an entry for every node type used in the grammar.
+
+    VISITOR_EXCEPTION (default: "")
+      If this option is set, it is used in the signature of the generated
+      jjtAccept() methods and the visit() methods. Note: this option will be
+      removed in a later version of JJTree. Don't use it if that bothers you.
+
+JJTree state
+
+JJTree keeps its state in a parser class field called jjtree. You can use
+methods in this member to manipulate the node stack.
+
+
+    final class JJTreeState {
+      /* Call this to reinitialize the node stack.  */
+      void reset();
+
+      /* Return the root node of the AST. */
+      Node rootNode();
+
+      /* Determine whether the current node was actually closed and
+	 pushed */
+      boolean nodeCreated();
+
+      /* Return the number of nodes currently pushed on the node
+         stack in the current node scope. */
+      int arity();
+
+      /* Push a node on to the stack. */
+      void pushNode(Node n);
+
+      /* Return the node on the top of the stack, and remove it from the
+	 stack.  */
+      Node popNode();
+
+      /* Return the node currently on the top of the stack. */
+      Node peekNode();
+    }
+
+Node Objects
+
+
+    /* All AST nodes must implement this interface.  It provides basic
+       machinery for constructing the parent and child relationships
+       between nodes. */
+
+    public interface Node {
+      /** This method is called after the node has been made the current
+	node.  It indicates that child nodes can now be added to it. */
+      public void jjtOpen();
+
+      /** This method is called after all the child nodes have been
+	added. */
+      public void jjtClose();
+
+      /** This pair of methods are used to inform the node of its
+	parent. */
+      public void jjtSetParent(Node n);
+      public Node jjtGetParent();
+
+      /** This method tells the node to add its argument to the node's
+	list of children.  */
+      public void jjtAddChild(Node n, int i);
+
+      /** This method returns a child node.  The children are numbered
+	 from zero, left to right. */
+      public Node jjtGetChild(int i);
+
+      /** Return the number of children the node has. */
+      int jjtGetNumChildren();
+    }
+
+The class SimpleNode implements the Node interface, and is automatically
+generated by JJTree if it doesn't already exist. You can use this class as a
+template or superclass for your node implementations, or you can modify it to
+suit. SimpleNode additionally provides a rudimentary mechanism for recursively
+dumping the node and its children. You might use this is in action like this:
+
+
+    {
+        ((SimpleNode)jjtree.rootNode()).dump(">");
+    }
+
+The String parameter to dump() is used as padding to indicate the tree
+hierarchy.
+
+Another utility method is generated if the VISITOR options is set:
+
+
+    {
+        public void childrenAccept(MyParserVisitor visitor);
+    }
+
+This walks over the node's children in turn, asking them to accept the
+visitor. This can be useful when implementing preorder and postorder
+traversals.
+
+More Documentation
+
+Jocelyn Paine has contributed a very nice introduction to JJTree where he
+describes how he has used it to develop an extension to HTML for interactive
+web pages: http://users.ox.ac.uk/~popx/jjtree.html
+
+Examples
+
+JJTree 0.3pre3 is distributed with some simple examples containing a grammar
+that parses arithmetic expressions. See the file
+examples/JJTreeExamples/README for further details.
+
+There is also an interpreter for a simple language that uses JJTree to build
+the program representation. See the file examples/Interpreter/README for more
+information.
+
+A grammar for HTML 3.2 is also included in the distribution. See
+examples/HTMLGrammars/RobsHTML/README to find out more.
+
+Information about an example using the visitor support is in
+examples/VTransformer/README.
+</pre>
+
+</BODY>
+</HTML>
diff --git a/tools/javacc-4.0/doc/jjtreereleasenotes.html b/tools/javacc-4.0/doc/jjtreereleasenotes.html
new file mode 100644
index 0000000000000000000000000000000000000000..87d4635170ab882588b56b399e9d044978c4fe0e
--- /dev/null
+++ b/tools/javacc-4.0/doc/jjtreereleasenotes.html
@@ -0,0 +1,446 @@
+<HTML>
+<!--
+
+Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+intellectual property rights relating to technology embodied in the product
+that is described in this document. In particular, and without limitation,
+these intellectual property rights may include one or more of the U.S.
+patents listed at http://www.sun.com/patents and one or more additional
+patents or pending patent applications in the U.S. and in other countries.
+U.S. Government Rights - Commercial software. Government users are subject
+to the Sun Microsystems, Inc. standard license agreement and applicable
+provisions of the FAR and its supplements.  Use is subject to license terms.
+Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+product is covered and controlled by U.S. Export Control laws and may be
+subject to the export or import laws in other countries.  Nuclear, missile,
+chemical biological weapons or nuclear maritime end uses or end users, whether
+direct or indirect, are strictly prohibited.  Export or reexport to countries
+subject to U.S. embargo or to entities identified on U.S. export exclusion
+lists, including, but not limited to, the denied persons and specially
+designated nationals lists is strictly prohibited.
+
+-->
+<HEAD>
+ <title>JavaCC: JJTree Release Notes</title>
+<!-- Changed by: Michael Van De Vanter, 14-Jan-2003 -->
+</HEAD>
+<BODY bgcolor="#FFFFFF" >
+
+<H1>JavaCC [tm]: JJTree Release Notes</H1>
+
+<pre>
+
+======================================
+Changes in 4.0
+======================================
+New option NODE_EXTENDS to specify a classname that 
+SimpleNode extends so that boiler plate code can be  put
+in that class. See the examples/Interpreter for an example
+usage.
+
+======================================
+Changes from JJTree 0.3pre5 to 0.3pre6
+======================================
+
+----------------------------------------------------------------
+
+Fixed bug where Writers were not being closed correctly.
+
+----------------------------------------------------------------
+
+======================================
+Changes from JJTree 0.3pre4 to 0.3pre5
+======================================
+
+----------------------------------------------------------------
+
+Fixed a bug where a node annotation #P() caused a null pointer error.
+
+----------------------------------------------------------------
+
+Only generate the jjtCreate() methods if the NODE_FACTORY option is
+set.
+
+----------------------------------------------------------------
+
+Fixed a bug where the name of the JJTree state file was being used in
+the declaration of the field.
+
+----------------------------------------------------------------
+
+======================================
+Changes from JJTree 0.3pre3 to 0.3pre4
+======================================
+
+----------------------------------------------------------------
+
+Made the constructors of nodes public.  Also made the node identifier
+constants and the associated strings public.
+
+----------------------------------------------------------------
+
+Fixed a misleading error message that was produced when the output
+file couldn't be generated for some reason.
+
+----------------------------------------------------------------
+
+Brought the HTML documentation up to date.
+
+----------------------------------------------------------------
+
+Fixed a bug where the file containing the JJTree state class was
+ignoring the OUTPUT_DIRECTORY option.
+
+----------------------------------------------------------------
+
+Fixed a bug where a construction like this:
+
+	a=foo() #Foo
+
+was being incorrectly handled and generating bad Java code.
+
+----------------------------------------------------------------
+
+Changed the visitor support from a void function to one which takes a
+parameter and returns a result.  This is a non-compatible change, so
+you will have to update your code if it uses the visitor support.
+
+
+[Also, if the string option VISITOR_EXCEPTION is set, its value is
+also used in the signatures of the various methods in the pattern.
+
+Please note: this exception support is very provisional and will be
+replaced in a following version by a more general solution.  It's only
+here because I needed it for one of my own projects and thought it
+might be useful to someone else too.  Don't use it unless you're
+prepared to change your code again later.  Rob.]
+
+----------------------------------------------------------------
+
+======================================
+Changes from JJTree 0.3pre2 to 0.3pre3
+======================================
+
+----------------------------------------------------------------
+
+JJTree now uses the same grammar as JavaCC.  This means that Java code
+in parser actions is parsed.
+
+----------------------------------------------------------------
+
+Added support for the Visitor design pattern.  If the VISITOR option
+is true, JJTree adds an accept method to the node classes that it
+generates, and also generates a visitor interface.  This interface is
+regenerated every time that JJTree is run, so that new nodes will
+cause compilation errors in concrete visitors that have not been
+updated for them.
+
+----------------------------------------------------------------
+
+Added a couple of examples to illustrate the Visitor support.
+JJTreeExamples/eg4.jjt is yet another version of the expression tree
+builder which uses a visitor to dump the expression tree; and
+VTransformer is a variation of the Java source code transformer.
+
+VTransformer is also possibly directly useful as a tool that inserts
+visitor accept methods into class files that were generated with
+earlier versions of JJTree.
+
+----------------------------------------------------------------
+
+Added the BUILD_NODE_FILES option, with a default value of true.  If
+set to false, it prevents JJTree from generating SimpleNode.java and
+nodes that are usually built in MULTI mode.  Node.java is still
+generated, as are the various tree constants, etc.
+
+----------------------------------------------------------------
+
+Code that is inserted into the grammar is now enclosed in the standard
+@bgen/@egen pair.
+
+----------------------------------------------------------------
+
+The JJTree state object is now generated into its own file if it
+doesn't already exist.  This is to make it easier to modify.
+
+----------------------------------------------------------------
+
+Fixed a couple of bugs in the HTML example grammar where the closing
+tags didn't match the opening tags.
+
+----------------------------------------------------------------
+
+Fixed a bug where JJTree was trying to clear the node scope while
+handling an exception, even when the node had been closed successfully.
+
+----------------------------------------------------------------
+
+NODE_FACTORY no longer implies NODE_USES_PARSER.
+
+If you have been using NODE_FACTORY, then now you'll also need
+NODE_USES_PARSER.  Unless, of course, you were never using the parser
+in your node factories.
+
+----------------------------------------------------------------
+
+Removed not very useful debugging stuff from the JJTree state object.
+It was causing problems with parsers running in security environments
+where access to arbitrary properties is disallowed.
+
+----------------------------------------------------------------
+
+======================================
+Changes from JJTree 0.3pre1 to 0.3pre2
+======================================
+
+----------------------------------------------------------------
+
+The state that JJTree inserts into the parser class is now guarded by
+the formal comments.
+
+----------------------------------------------------------------
+
+The JJTree syntax has been changed so that the node descriptor now
+comes after the throws clause, rather than before it.
+
+----------------------------------------------------------------
+
+Fixed a bug where string-valued options did not have their quotes
+stripped.
+
+----------------------------------------------------------------
+
+Fixed a bug where nodes were being closed early for actions within
+ZeroOrMore etc., expansion units.
+
+----------------------------------------------------------------
+
+The special identifier `jjtThis' was not being translated in parameter
+lists or in the BNF declaration section.  Fixed it.
+
+----------------------------------------------------------------
+
+Added the OUTPUT_DIRECTORY option.  The default value is "".
+
+----------------------------------------------------------------
+
+Reinstated node factory methods.  They are enabled by setting the
+NODE_FACTORY option to true.  Unlike the original node factory methods
+they take two arguments: the node identifier constant and a reference
+to the parser.  The reference is null for static parsers.
+
+----------------------------------------------------------------
+
+Added the NODE_USES_PARSER option with a default value of false.  When
+set to true, JJTree will call the node constructor with a reference to
+the parser object as an extra parameter.  This reference is null for
+static parsers.
+
+----------------------------------------------------------------
+
+====================================
+Changes from JJTree 0.2.6 to 0.3pre1
+====================================
+
+----------------------------------------------------------------
+
+JJTree 0.3pre1 has been bootstrapped with JJTree 0.2.6.
+
+Some aspects of JJTree 0.3pre1 are not backwards-compatible with
+0.2.6.  Some users will need to modify their parsers in
+straightforward ways in order to work with the new version.  See the
+file JJTREE-FIX to find out if you need to change anything, and for
+detailed instructions on what to change.
+
+----------------------------------------------------------------
+
+JJTree works with the JavaCC exception handling code.  Any unhandled
+exceptions within a node scope are caught, the node stack is cleaned
+up a bit, and then the exception is rethrown.
+
+----------------------------------------------------------------
+
+Indefinite and Greater-Than nodes have been generalized into
+conditional nodes.
+
+Definite nodes now take any integer expression to indicate now many
+children they take.  Conditional nodes take any boolean expression to
+indicate whether the node is closed and pushed on to the node stack.
+
+----------------------------------------------------------------
+
+The life cycle of a node is now defined.
+
+----------------------------------------------------------------
+
+User-defined parser methods can be called when a node scope is entered
+and exited.
+
+----------------------------------------------------------------
+
+The NODE_STACK_SIZE and CHECK_DEFINITE_NODE options are now ignored.
+
+The NODE_SCOPE_HOOK option has been added.  This boolean option
+determines whether calls to certain user-defined parser methods are
+generated at the beginning and end of each node scope.  The default
+value for this option is false.
+
+----------------------------------------------------------------
+
+The special identifier jjtThis can now be used in the declarations
+section of a production, as well as on the left hand side of call to a
+nonterminal.
+
+----------------------------------------------------------------
+
+A new method arity() has been added to the JJTree state.  It returns
+the number of nodes that have been pushed so far in the current node
+scope.
+
+----------------------------------------------------------------
+
+The Node interface has changed.  The method jjtAddChild() now takes an
+argument to indicate the index of the child it is adding.
+
+----------------------------------------------------------------
+
+The node factory methods are no longer used.  You can remove all your
+jjtCreate() methods.
+
+The node constructor now takes an int parameter instead of a String.
+You will have to modify your node implementations to use the new
+signature.  The protected field `identifier' no longer exists: you can
+use the jjtNodeName[] array to map from the new parameter to the old
+String.
+
+----------------------------------------------------------------
+
+The implementation of SimpleNode has changed significantly.  It now
+uses an array to hold any child nodes instead of a Vector.  It no
+longer implements a node factory, its constructor takes an int instead
+of a String, and it uses the jjtNodeName[] mechanism for dumping.  The
+setInfo() and getInfo() methods have been removed.
+
+----------------------------------------------------------------
+
+The implementation of the state that JJTree keeps in the parser has
+changed.  It is now considerably more lightweight: the auxiliary
+classes JJTreeNodeStack and JJTreeNodeStackEnum have been abolished.
+
+----------------------------------------------------------------
+
+The JJTree state method currentNode() has been removed.  Any calls to
+the method in an action within a node scope are automatically replaced
+by references to the special identifier jjtThis.
+
+----------------------------------------------------------------
+
+==================================
+Changes from JJTree 0.2.5 to 0.2.6
+==================================
+
+----------------------------------------------------------------
+
+Made appropriate internal modifications for the JavaCC 0.7 parse error
+exceptions.
+
+----------------------------------------------------------------
+
+==================================
+Changes from JJTree 0.2.4 to 0.2.5
+==================================
+
+----------------------------------------------------------------
+
+Fixed a bug where the current node was not being updated in the right
+place for final user actions.
+
+----------------------------------------------------------------
+
+==================================
+Changes from JJTree 0.2.3 to 0.2.4
+==================================
+
+----------------------------------------------------------------
+
+Fixed a bug where bad code was generated for void nodes in MULTI mode.
+
+----------------------------------------------------------------
+
+Fixed a bug where a node decoration directly on an action generated
+bad code. For example,
+
+	{} #MyNode
+
+----------------------------------------------------------------
+
+==================================
+Changes from JJTree 0.2.2 to 0.2.3
+==================================
+
+----------------------------------------------------------------
+
+Added toString() and toString(String) methods to SimpleNode and
+modified the dumping code to use them.  Now you can easily customize
+how a node appears in the tree dump, without having to reproduce the
+tree walking machinery.  See SimpleNode.java for details.
+
+----------------------------------------------------------------
+
+Clarified the concept of node scope.  currentNode() now refers to the
+node currently being built for the current scope.  It used to be
+incorrectly implemented as referring to the most recently created
+node, and was synonymous with peekNode().
+
+This change may break some existing programs.  Those programs should
+be changed to use peekNode() where they currently use currentNode().
+
+Added jjtThis to every user action.  It refers to the same node that
+currentNode() does, but is already cast to the appropriate node type.
+
+The final user action in a node scope is different from all the
+others.  When it is executed the node has been fully created, had its
+children added, and has been pushed on the node stack.  By contrast,
+other user actions within the scope are called when the children are
+still on the stack, and the current node is not.
+
+Added the nodeCreated() method so that final actions within greater
+than nodes can tell whether the node was created or not.
+
+----------------------------------------------------------------
+
+Fixed several stupid bugs in the Macintosh main class.
+
+----------------------------------------------------------------
+
+Fixed names of internally used JJTree classes so that they use the JJT
+prefix and the name of the parser.  This is to avoid naming conflicts
+where there is more than one JJTree parser in the same package.
+
+----------------------------------------------------------------
+
+================================
+Changes from JJTree 0.2 to 0.2.2
+================================
+
+The main change between Beanstalk 0.2 and JJTree 0.2.2 is the removal
+of the factory classes.  Their function is now performed by a static
+method in the node classes themselves.
+
+The state maintained in the parser class has been changed from bs to
+jjtree.  The prefix on the Node class methods has been changed from bs
+to jjt.
+
+A new node method jjtGetNumChildren() returns the number of children
+the node has.  You can use this in conjunction with jjtGetChild() to
+iterate over the children.
+
+Two new options have been added: OUTPUT_FILE and NODE_DEFAULT_VOID.
+
+----------------------------------------------------------------
+</pre>
+
+</BODY>
+</HTML>
diff --git a/tools/javacc-4.0/doc/lexertips.html b/tools/javacc-4.0/doc/lexertips.html
new file mode 100644
index 0000000000000000000000000000000000000000..c1a7c88ad4e7c61daf9761e065eeb85dddadcbc3
--- /dev/null
+++ b/tools/javacc-4.0/doc/lexertips.html
@@ -0,0 +1,99 @@
+<html><head><title>Tips for writing a good JavaCC lexical specification</title></head>
+
+<body><h1 align="center"> Tips for writing a good JavaCC lexical specification</h1>
+<hr>
+
+<p>
+There are many ways to write the lexical specification for a grammar. But 
+the performance of the generated token manager varies significantly depending
+on how you do this.  Here are a few tips:
+
+</p><ul>
+
+<li> Try to specify as many String literals as possible. These are recognized
+   by a Deterministic Finite Automata (DFA), which is much faster than the Nondeterministic Finite Automata (NFA) needed to recognize other kinds
+   of complex regular expressions. For example, to skip blanks/tabs/newlines,
+<pre>   
+    SKIP : { " " | "\t" | "\n" }
+</pre>
+   is more efficient than doing 
+
+<pre>    SKIP : { &lt; ([" ", "\t", "\n"])+ &gt; }
+</pre>
+
+   because in the first case you only have string literals, it will generate
+   a DFA whereas for the second case it will generate an NFA.
+<p>
+
+</p></li><li> Try to use the pattern ~[] just by itself as much as possible. For example,
+   doing a 
+
+<pre>      MORE : { &lt; ~[] &gt; }
+</pre>
+
+   is better than doing
+
+<pre>      TOKEN : { &lt; (~[])+ &gt; }
+</pre>
+
+   of course, if your grammar dictates that one of these cannot be used, then
+   you don't have a choice, but try to use &lt; ~[] &gt; as much as possible.
+<p>
+
+</p></li><li> Specify all the String literals in the order of increasing length, i.e.,
+   all shorter string literals before longer ones. This will help optimizing
+   the bit vectors needed for string literals.
+<p>
+
+</p></li><li> Try to minimize the use of lexical states. When using these, try to move
+   all your complex regular expressions into a single lexical state, leaving
+   others to just recognize simple string literals.
+<p>
+
+</p></li><li> Try to use IGNORE_CASE judiciously. Best thing to do is to set this option
+   at the grammar level. If that is not possible, then try to have it set for 
+   *all* regular expressions in a lexical state. There is heavy performance
+   penalty for setting IGNORE_CASE for some regular expressions and not for others in the
+   same lexical state.
+<p>
+
+</p></li><li> Try to SKIP as much possible, if you don't care about certain patterns.
+   Here, you have to be a bit careful about EOF. seeing an EOF after SKIP
+   is fine whereas, seeing an EOF after a MORE is a lexical error.
+<p>
+
+</p></li><li> Try to avoid specifying lexical actions with MORE specifications. Generally
+   every MORE should end up in a TOKEN (or SPECIAL_TOKEN) finally so you can
+   do the action there at the TOKEN level, if it is possible.
+<p>
+
+</p></li><li> Also try to avoid lexical actions and lexical state changes with SKIP
+   specifications (especially for single character SKIP's like " ", "\t",
+   "\n" etc.). For such cases, a simple loop is generated to eat up the
+   SKIP'ed single characters. So obviously, if there is a lexical action
+   or state change associated with this, it is not possible to it this way.
+<p>
+
+</p></li><li>Try to avoid having a choice of String literals for the same token, e.g.
+<pre> 
+      &lt; NONE : "\"none\"" | "\'none\'" &gt;
+</pre> 
+   
+   Instead, have two different token kinds for this and use a nonterminal which
+   is a choice between those choices. The above example can be written as :
+                                      
+<pre> 
+        &lt; NONE1 : "\"none\"" &gt;             
+      |  
+        &lt; NONE2 : "\'none'\" &gt;             
+</pre> 
+                                      
+   and define a nonterminal called None() as :
+                                      
+<pre> 
+      void None() : {} { &lt;NONE1&gt; | &lt;NONE2&gt; }
+</pre> 
+ 
+   This will make recognition much faster. Note however, that if the choice is
+   between two complex regular expressions, it is OK to have the choice.
+<p></p></li></ul></body></html>
diff --git a/tools/javacc-4.0/doc/lookahead.html b/tools/javacc-4.0/doc/lookahead.html
new file mode 100644
index 0000000000000000000000000000000000000000..d038e495658f45ee7a2a070b1e0396cce4a08bf2
--- /dev/null
+++ b/tools/javacc-4.0/doc/lookahead.html
@@ -0,0 +1,844 @@
+<HTML>
+<!--
+
+Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+intellectual property rights relating to technology embodied in the product
+that is described in this document. In particular, and without limitation,
+these intellectual property rights may include one or more of the U.S.
+patents listed at http://www.sun.com/patents and one or more additional
+patents or pending patent applications in the U.S. and in other countries.
+U.S. Government Rights - Commercial software. Government users are subject
+to the Sun Microsystems, Inc. standard license agreement and applicable
+provisions of the FAR and its supplements.  Use is subject to license terms.
+Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+product is covered and controlled by U.S. Export Control laws and may be
+subject to the export or import laws in other countries.  Nuclear, missile,
+chemical biological weapons or nuclear maritime end uses or end users, whether
+direct or indirect, are strictly prohibited.  Export or reexport to countries
+subject to U.S. embargo or to entities identified on U.S. export exclusion
+lists, including, but not limited to, the denied persons and specially
+designated nationals lists is strictly prohibited.
+
+-->
+<HEAD>
+ <title>JavaCC: LOOKAHEAD MiniTutorial</title>
+<!-- Changed by: Michael Van De Vanter, 14-Jan-2003 -->
+</HEAD>
+<BODY bgcolor="#FFFFFF" >
+
+<H1>JavaCC [tm]: LOOKAHEAD MiniTutorial</H1>
+
+<HR>
+
+<P>
+<STRONG>This minitutorial is under preparation.  This tutorial refers
+to examples that are available in the Lookahead directory under the
+examples directory of the release.  Currently, this page is a copy of
+the contents of the README file within that directory.
+</STRONG>
+<P>
+
+<PRE>
+This directory contains the tutorial on LOOKAHEAD along with all
+examples used in the tutorial.
+
+We assume that you have already taken a look at some of the simple
+examples provided in the release before you read this section.
+
+1. WHAT IS LOOKAHEAD?
+
+The job of a parser is to read an input stream and determine whether
+or not the input stream conforms to the grammar.
+
+This determination in its most general form can be quite time
+consuming.  Consider the following example (file Example1.jj):
+
+----------------------------------------------------------------
+
+	void Input() :
+	{}
+	{
+	  "a" BC() "c"
+	}
+
+	void BC() :
+	{}
+	{
+	  "b" [ "c" ]
+	}
+
+In this simple example, it is quite clear that there are exactly two
+strings that match the above grammar, namely:
+
+	abc
+	abcc
+
+The general way to perform this match is to walk through the grammar
+based on the string as follows.  Here, we use "abc" as the input
+string:
+
+Step 1. There is only one choice here - the first input character
+must be 'a' - and since that is indeed the case, we are OK.
+
+Step 2. We now proceed on to non-terminal BC.  Here again, there is
+only one choice for the next input character - it must be 'b'.  The
+input matches this one too, so we are still OK.
+
+Step 3. We now come to a "choice point" in the grammar.  We can either
+go inside the [...] and match it, or ignore it altogether.  We decide
+to go inside.  So the next input character must be a 'c'.  We are
+again OK.
+
+Step 4. Now we have completed with non-terminal BC and go back to
+non-terminal Input.  Now the grammar says the next character must be
+yet another 'c'.  But there are no more input characters.  So we have
+a problem.
+
+Step 5. When we have such a problem in the general case, we conclude
+that we may have made a bad choice somewhere.  In this case, we made
+the bad choice in Step 3.  So we retrace our steps back to step 3 and
+make another choice and try that.  This process is called
+"backtracking".
+
+Step 6. We have now backtracked and made the other choice we could
+have made at Step 3 - namely, ignore the [...].  Now we have completed
+with non-terminal BC and go back to non-terminal Input.  Now the
+grammar says the next character must be yet another 'c'.  The next
+input character is a 'c', so we are OK now.
+
+Step 7. We realize we have reached the end of the grammar (end of
+non-terminal Input) successfully.  This means we have successfully
+matched the string "abc" to the grammar.
+
+----------------------------------------------------------------
+
+As the above example indicates, the general problem of matching an
+input with a grammar may result in large amounts of backtracking and
+making new choices and this can consume a lot of time.  The amount of
+time taken can also be a function of how the grammar is written.  Note
+that many grammars can be written to cover the same set of inputs - or
+the same language (i.e., there can be multiple equivalent grammars for
+the same input language).
+
+----------------------------------------------------------------
+
+For example, the following grammar would speed up the parsing of the
+same language as compared to the previous grammar:
+
+	void Input() :
+	{}
+	{
+	  "a" "b" "c" [ "c" ]
+	}
+
+while the following grammar slows it down even more since the parser
+has to backtrack all the way to the beginning:
+
+	void Input() :
+	{}
+	{
+	  "a" "b" "c" "c"
+	|
+	  "a" "b" "c"
+	}
+
+One can even have a grammar that looks like the following:
+
+	void Input() :
+	{}
+	{
+	  "a" ( BC1() | BC2() )
+	}
+
+	void BC1() :
+	{}
+	{
+	  "b" "c" "c"
+	}
+
+	void BC2() :
+	{}
+	{
+	  "b" "c" [ "c" ]
+	}
+
+This grammar can match "abcc" in two ways, and is therefore considered
+"ambiguous".
+
+----------------------------------------------------------------
+
+The performance hit from such backtracking is unacceptable for most
+systems that include a parser.  Hence most parsers do not backtrack in
+this general manner (or do not backtrack at all), rather they make
+decisions at choice points based on limited information and then
+commit to it.
+
+Parsers generated by Java Compiler Compiler [tm] make decisions at choice
+points based on some exploration of tokens further ahead in the input
+stream, and once they make such a decision, they commit to it.  i.e.,
+No backtracking is performed once a decision is made.
+
+The process of exploring tokens further in the input stream is termed
+"looking ahead" into the input stream - hence our use of the term
+"LOOKAHEAD".
+
+Since some of these decisions may be made with less than perfect
+information (JavaCC [tm] will warn you in these situations, so you don't
+have to worry), you need to know something about LOOKAHEAD to make
+your grammar work correctly.
+
+The two ways in which you make the choice decisions work properly are:
+
+. Modify the grammar to make it simpler.
+
+. Insert hints at the more complicated choice points to help the
+  parser make the right choices.
+
+----------------------------------------------------------------
+
+2. CHOICE POINTS IN JAVACC GRAMMARS
+
+There are 4 different kinds of choice points in JavaCC:
+
+. An expansion of the form: ( exp1 | exp2 | ... ).  In this case, the
+  generated parser has to somehow determine which of exp1, exp2, etc.
+  to select to continue parsing.
+
+. An expansion of the form: ( exp )?.  In this case, the generated parser
+  must somehow determine whether to choose exp or to continue beyond
+  the ( exp )? without choosing exp.  Note: ( exp )? may also be written
+  as [ exp ].
+
+. An expansion of the form ( exp )*.  In this case, the generated parser
+  must do the same thing as in the previous case, and furthermore, after
+  each time a successful match of exp (if exp was chosen) is completed,
+  this choice determination must be made again.
+
+. An expansion of the form ( exp )+.  This is essentially similar to
+  the previous case with a mandatory first match to exp.
+
+Remember that token specifications that occur within angular
+brackets &lt;...&gt; also have choice points.  But these choices are made
+in different ways and are the subject of a different tutorial.
+
+----------------------------------------------------------------
+
+3. THE DEFAULT CHOICE DETERMINATION ALGORITHM
+
+The default choice determination algorithm looks ahead 1 token in the
+input stream and uses this to help make its choice at choice points.
+
+The following examples will describe the default algorithm fully:
+
+----------------------------------------------------------------
+
+Consider the following grammar (file Example2.jj):
+
+	void basic_expr() :
+	{}
+	{
+	  &lt;ID&gt; "(" expr() ")"	// Choice 1
+	|
+	  "(" expr() ")"	// Choice 2
+	|
+	  "new" &lt;ID&gt;		// Choice 3
+	}
+
+The choice determination algorithm works as follows:
+
+	if (next token is &lt;ID&gt;) {
+	  choose Choice 1
+	} else if (next token is "(") {
+	  choose Choice 2
+	} else if (next token is "new") {
+	  choose Choice 3
+	} else {
+	  produce an error message
+	}
+
+----------------------------------------------------------------
+
+In the above example, the grammar has been written such that the
+default choice determination algorithm does the right thing.  Another
+thing to note is that the choice determination algorithm works in a
+top to bottom order - if Choice 1 was selected, the other choices are
+not even considered.  While this is not an issue in this example
+(except for performance), it will become important later below when
+local ambiguities require the insertion of LOOKAHEAD hints.
+
+Suppose the above grammar was modified to (file Example3.jj):
+
+	void basic_expr() :
+	{}
+	{
+	  &lt;ID&gt; "(" expr() ")"	// Choice 1
+	|
+	  "(" expr() ")"	// Choice 2
+	|
+	  "new" &lt;ID&gt;		// Choice 3
+	|
+	  &lt;ID&gt; "." &lt;ID&gt;		// Choice 4
+	}
+
+Then the default algorithm will always choose Choice 1 when the next
+input token is &lt;ID&gt; and never choose Choice 4 even if the token
+following &lt;ID&gt; is a ".".  More on this later.
+
+You can try running the parser generated from Example3.jj on the input
+"id1.id2".  It will complain that it encountered a "." when it was
+expecting a "(".  Note - when you built the parser, it would have
+given you the following warning message:
+
+Warning: Choice conflict involving two expansions at
+         line 25, column 3 and line 31, column 3 respectively.
+         A common prefix is: &lt;ID&gt;
+         Consider using a lookahead of 2 for earlier expansion.
+
+Essentially, JavaCC is saying it has detected a situation in your
+grammar which may cause the default lookahead algorithm to do strange
+things.  The generated parser will still work using the default
+lookahead algorithm - except that it may not do what you expect of it.
+
+----------------------------------------------------------------
+
+Now consider the following example (file Example 4.jj):
+
+	void identifier_list() :
+	{}
+	{
+	  &lt;ID&gt; ( "," &lt;ID&gt; )*
+	}
+
+Suppose the first &lt;ID&gt; has already been matched and that the parser
+has reached the choice point (the (...)* construct).  Here's how the
+choice determination algorithm works:
+
+	while (next token is ",") {
+	  choose the nested expansion (i.e., go into the (...)* construct)
+	  consume the "," token
+	  if (next token is &lt;ID&gt;) consume it, otherwise report error
+	}
+
+----------------------------------------------------------------
+
+In the above example, note that the choice determination algorithm
+does not look beyond the (...)* construct to make its decision.
+Suppose there was another production in that same grammar as follows
+(file Example5.jj):
+
+	void funny_list() :
+	{}
+	{
+	  identifier_list() "," &lt;INT&gt;
+	}
+
+When the default algorithm is making a choice at ( "," &lt;ID&gt; )*, it
+will always go into the (...)* construct if the next token is a ",".
+It will do this even when identifier_list was called from funny_list
+and the token after the "," is an &lt;INT&gt;.  Intuitively, the right thing
+to do in this situation is to skip the (...)* construct and return to
+funny_list.  More on this later.
+
+As a concrete example, suppose your input was "id1, id2, 5", the
+parser will complain that it encountered a 5 when it was expecting an
+&lt;ID&gt;.  Note - when you built the parser, it would have given you the
+following warning message:
+
+Warning: Choice conflict in (...)* construct at line 25, column 8.
+         Expansion nested within construct and expansion following construct
+         have common prefixes, one of which is: ","
+         Consider using a lookahead of 2 or more for nested expansion.
+
+Essentially, JavaCC is saying it has detected a situation in your
+grammar which may cause the default lookahead algorithm to do strange
+things.  The generated parser will still work using the default
+lookahead algorithm - except that it may not do what you expect of it.
+
+----------------------------------------------------------------
+
+We have shown you examples of two kinds of choice points in the
+examples above - "exp1 | exp2 | ...", and "(exp)*".  The other two
+kinds of choice points - "(exp)+" and "(exp)?" - behave similarly to
+(exp)* and we will not be providing examples of their use here.
+
+----------------------------------------------------------------
+
+4. MULTIPLE TOKEN LOOKAHEAD SPECIFICATIONS
+
+So far, we have described the default lookahead algorithm of the
+generated parsers.  In the majority of situations, the default
+algorithm works just fine.  In situations where it does not work
+well, Java Compiler Compiler provides you with warning messages like
+the ones shown above.  If you have a grammar that goes through
+Java Compiler Compiler without producing any warnings, then the
+grammar is a LL(1) grammar.  Essentially, LL(1) grammars are those
+that can be handled by top-down parsers (such as those generated
+by Java Compiler Compiler) using at most one token of LOOKAHEAD.
+
+When you get these warning messages, you can do one of two things.
+
+----------------------------------------------------------------
+
+Option 1
+
+You can modify your grammar so that the warning messages go away.
+That is, you can attempt to make your grammar LL(1) by making some
+changes to it.
+
+The following (file Example6.jj) shows how you may change Example3.jj
+to make it LL(1):
+
+	void basic_expr() :
+	{}
+	{
+	  &lt;ID&gt; ( "(" expr() ")" | "." &lt;ID&gt; )
+	|
+	  "(" expr() ")"
+	|
+	  "new" &lt;ID&gt;
+	}
+
+What we have done here is to factor the fourth choice into the first
+choice.  Note how we have placed their common first token &lt;ID&gt; outside
+the parentheses, and then within the parentheses, we have yet another
+choice which can now be performed by looking at only one token in the
+input stream and comparing it with "(" and ".".  This process of
+modifying grammars to make them LL(1) is called "left factoring".
+
+The following (file Example7.jj) shows how Example5.jj may be changed
+to make it LL(1):
+
+	void funny_list() :
+	{}
+	{
+	  &lt;ID&gt; "," ( &lt;ID&gt; "," )* &lt;INT&gt;
+	}
+
+Note that this change is somewhat more drastic.
+
+----------------------------------------------------------------
+
+Option 2
+
+You can provide the generated parser with some hints to help it out
+in the non-LL(1) situations that the warning messages bring to your
+attention.
+
+All such hints are specified using either setting the global LOOKAHEAD
+value to a larger value (see below) or by using the LOOKAHEAD(...)
+construct to provide a local hint.
+
+A design decision must be made to determine if Option 1 or Option 2 is
+the right one to take.  The only advantage of choosing Option 1 is
+that it makes your grammar perform better.  JavaCC generated parsers
+can handle LL(1) constructs much faster than other constructs.
+However, the advantage of choosing Option 2 is that you have a simpler
+grammar - one that is easier to develop and maintain - one that
+focuses on human-friendliness and not machine-friendliness.
+
+Sometimes Option 2 is the only choice - especially in the presence of
+user actions.  Suppose Example3.jj contained actions as shown below:
+
+	void basic_expr() :
+	{}
+	{
+	  { initMethodTables(); } &lt;ID&gt; "(" expr() ")"
+	|
+	  "(" expr() ")"
+	|
+	  "new" &lt;ID&gt;
+	|
+	  { initObjectTables(); } &lt;ID&gt; "." &lt;ID&gt;
+	}
+
+Since the actions are different, left-factoring cannot be performed.
+
+----------------------------------------------------------------
+
+4.1. SETTING A GLOBAL LOOKAHEAD SPECIFICATION
+
+You can set a global LOOKAHEAD specification by using the option
+"LOOKAHEAD" either from the command line, or at the beginning of the
+grammar file in the options section.  The value of this option is an
+integer which is the number of tokens to look ahead when making choice
+decisions.  As you may have guessed, the default value of this option
+is 1 - which derives the default LOOKAHEAD algorithm described above.
+
+Suppose you set the value of this option to 2.  Then the LOOKAHEAD
+algorithm derived from this looks at two tokens (instead of just one
+token) before making a choice decision.  Hence, in Example3.jj, choice
+1 will be taken only if the next two tokens are &lt;ID&gt; and "(", while
+choice 4 will be taken only if the next two tokens are &lt;ID&gt; and ".".
+Hence, the parser will now work properly for Example3.jj.  Similarly,
+the problem with Example5.jj also goes away since the parser goes into
+the (...)* construct only when the next two tokens are "," and &lt;ID&gt;.
+
+By setting the global LOOKAHEAD to 2, the parsing algorithm
+essentially becomes LL(2).  Since you can set the global LOOKAHEAD to
+any value, parsers generated by Java Compiler Compiler are called
+LL(k) parsers.
+
+----------------------------------------------------------------
+
+4.2. SETTING A LOCAL LOOKAHEAD SPECIFICATION
+
+You can also set a local LOOKAHEAD specification that affects only a
+specific choice point.  This way, the majority of the grammar can
+remain LL(1) and hence perform better, while at the same time one gets
+the flexibility of LL(k) grammars.  Here's how Example3.jj is modified
+with local LOOKAHEAD to fix the choice ambiguity problem (file
+Example8.jj):
+
+	void basic_expr() :
+	{}
+	{
+	  LOOKAHEAD(2)
+	  &lt;ID&gt; "(" expr() ")"	// Choice 1
+	|
+	  "(" expr() ")"	// Choice 2
+	|
+	  "new" &lt;ID&gt;		// Choice 3
+	|
+	  &lt;ID&gt; "." &lt;ID&gt;		// Choice 4
+	}
+
+Only the first choice (the first condition in the translation below)
+is affected by the LOOKAHEAD specification.  All others continue to
+use a single token of LOOKAHEAD:
+
+	if (next 2 tokens are &lt;ID&gt; and "(" ) {
+	  choose Choice 1
+	} else if (next token is "(") {
+	  choose Choice 2
+	} else if (next token is "new") {
+	  choose Choice 3
+	} else if (next token is &lt;ID&gt;) {
+	  choose Choice 4
+	} else {
+	  produce an error message
+	}
+
+Similarly, Example5.jj can be modified as shown below (file
+Example9.jj):
+
+	void identifier_list() :
+	{}
+	{
+	  &lt;ID&gt; ( LOOKAHEAD(2) "," &lt;ID&gt; )*
+	}
+
+Note, the LOOKAHEAD specification has to occur inside the (...)* which
+is the choice is being made.  The translation for this construct is
+shown below (after the first &lt;ID&gt; has been consumed):
+
+	while (next 2 tokens are "," and &lt;ID&gt;) {
+	  choose the nested expansion (i.e., go into the (...)* construct)
+	  consume the "," token
+	  consume the &lt;ID&gt; token
+	}
+
+----------------------------------------------------------------
+
+We strongly discourage you from modifying the global LOOKAHEAD
+default.  Most grammars are predominantly LL(1), hence you will be
+unnecessarily degrading performance by converting the entire grammar
+to LL(k) to facilitate just some portions of the grammar that are not
+LL(1).  If your grammar and input files being parsed are very small,
+then this is okay.
+
+You should also keep in mind that the warning messages JavaCC prints
+when it detects ambiguities at choice points (such as the two messages
+shown earlier) simply tells you that the specified choice points are
+not LL(1).  JavaCC does not verify the correctness of your local
+LOOKAHEAD specification - it assumes you know what you are doing, in
+fact, it really cannot verify the correctness of local LOOKAHEAD's as
+the following example of if statements illustrates (file
+Example10.jj):
+
+	void IfStm() :
+	{}
+	{
+	 "if" C() S() [ "else" S() ]
+	}
+
+	void S() :
+	{}
+	{
+	  ...
+	|
+	  IfStm()
+	}
+
+This example is the famous "dangling else" problem.  If you have a
+program that looks like:
+
+	"if C1 if C2 S1 else S2"
+
+The "else S2" can be bound to either of the two if statements.  The
+standard interpretation is that it is bound to the inner if statement
+(the one closest to it).  The default choice determination algorithm
+happens to do the right thing, but it still prints the following
+warning message:
+
+Warning: Choice conflict in [...] construct at line 25, column 15.
+         Expansion nested within construct and expansion following construct
+         have common prefixes, one of which is: "else"
+         Consider using a lookahead of 2 or more for nested expansion.
+
+To suppress the warning message, you could simply tell JavaCC that
+you know what you are doing as follows:
+
+	void IfStm() :
+	{}
+	{
+	 "if" C() S() [ LOOKAHEAD(1) "else" S() ]
+	}
+
+To force lookahead ambiguity checking in such instances, set the option
+FORCE_LA_CHECK to true.
+
+----------------------------------------------------------------
+
+5. SYNTACTIC LOOKAHEAD
+
+Consider the following production taken from the Java grammar:
+
+	void TypeDeclaration() :
+	{}
+	{
+	  ClassDeclaration()
+	|
+	  InterfaceDeclaration()
+	}
+
+At the syntactic level, ClassDeclaration can start with any number of
+"abstract"s, "final"s, and "public"s.  While a subsequent semantic
+check will produce error messages for multiple uses of the same
+modifier, this does not happen until parsing is completely over.
+Similarly, InterfaceDeclaration can start with any number of
+"abstract"s and "public"s.
+
+What if the next tokens in the input stream are a very large number of
+"abstract"s (say 100 of them) followed by "interface"?  It is clear
+that a fixed amount of LOOKAHEAD (such as LOOKAHEAD(100) for example)
+will not suffice.  One can argue that this is such a weird situation
+that it does not warrant any reasonable error message and that it is
+okay to make the wrong choice in some pathological situations.  But
+suppose one wanted to be precise about this.
+
+The solution here is to set the LOOKAHEAD to infinity - that is set no
+bounds on the number of tokens to look ahead.  One way to do this is
+to use a very large integer value (such as the largest possible
+integer) as follows:
+
+	void TypeDeclaration() :
+	{}
+	{
+	  LOOKAHEAD(2147483647)
+	  ClassDeclaration()
+	|
+	  InterfaceDeclaration()
+	}
+
+One can also achieve the same effect with "syntactic LOOKAHEAD".  In
+syntactic LOOKAHEAD, you specify an expansion to try out and it that
+succeeds, then the following choice is taken.  The above example is
+rewritten using syntactic LOOKAHEAD below:
+
+	void TypeDeclaration() :
+	{}
+	{
+	  LOOKAHEAD(ClassDeclaration())
+	  ClassDeclaration()
+	|
+	  InterfaceDeclaration()
+	}
+
+Essentially, what this is saying is:
+
+	if (the tokens from the input stream match ClassDeclaration) {
+	  choose ClassDeclaration()
+	} else if (next token matches InterfaceDeclaration) {
+	  choose InterfaceDeclaration()
+	} else {
+	  produce an error message
+	}
+
+The problem with the above syntactic LOOKAHEAD specification is that
+the LOOKAHEAD calculation takes too much time and does a lot of
+unnecessary checking.  In this case, the LOOKAHEAD calculation can
+stop as soon as the token "class" is encountered, but the
+specification forces the calculation to continue until the end of the
+class declaration has been reached - which is rather time consuming.
+This problem can be solved by placing a shorter expansion to try out
+in the syntactic LOOKAHEAD specification as in the following example:
+
+	void TypeDeclaration() :
+	{}
+	{
+	  LOOKAHEAD( ( "abstract" | "final" | "public" )* "class" )
+	  ClassDeclaration()
+	|
+	  InterfaceDeclaration()
+	}
+
+Essentially, what this is saying is:
+
+	if (the nest set of tokens from the input stream are a sequence of
+	    "abstract"s, "final"s, and "public"s followed by a "class") {
+	  choose ClassDeclaration()
+	} else if (next token matches InterfaceDeclaration) {
+	  choose InterfaceDeclaration()
+	} else {
+	  produce an error message
+	}
+
+By doing this, you make the choice determination algorithm stop as
+soon as it sees "class" - i.e., make its decision at the earliest
+possible time.
+
+You can place a bound on the number of tokens to consume during
+syntactic lookahead as follows:
+
+	void TypeDeclaration() :
+	{}
+	{
+	  LOOKAHEAD(10, ( "abstract" | "final" | "public" )* "class" )
+	  ClassDeclaration()
+	|
+	  InterfaceDeclaration()
+	}
+
+In this case, the LOOKAHEAD determination is not permitted to go beyond
+10 tokens.  If it reaches this limit and is still successfully matching
+( "abstract" | "final" | "public" )* "class", then ClassDeclaration is
+selected.
+
+Actually, when such a limit is not specified, it defaults to the largest
+integer value (2147483647).
+
+----------------------------------------------------------------
+
+6. SEMANTIC LOOKAHEAD
+
+Let us go back to Example1.jj:
+
+	void Input() :
+	{}
+	{
+	  "a" BC() "c"
+	}
+
+	void BC() :
+	{}
+	{
+	  "b" [ "c" ]
+	}
+
+Let us suppose that there is a good reason for writing a grammar this
+way (maybe the way actions are embedded).  As noted earlier, this
+grammar recognizes two string "abc" and "abcc".  The problem here is
+that the default LL(1) algorithm will choose the [ "c" ] every time
+it sees a "c" and therefore "abc" will never be matched.  We need to
+specify that this choice must be made only when the next token is a
+"c", and the token following that is not a "c".  This is a negative
+statement - one that cannot be made using syntactic LOOKAHEAD.
+
+We can use semantic LOOKAHEAD for this purpose.  With semantic
+LOOKAHEAD, you can specify any arbitrary boolean expression whose
+evaluation determines which choice to take at a choice point.  The
+above example can be instrumented with semantic LOOKAHEAD as follows:
+
+	void BC() :
+	{}
+	{
+	  "b"
+	  [ LOOKAHEAD( { getToken(1).kind == C && getToken(2).kind != C } )
+	    &lt;C:"c"&gt;
+	  ]
+	}
+
+First we give the token "c" a label C so that we can refer to it from
+the semantic LOOKAHEAD.  The boolean expression essentially states the
+desired property.  The choice determination decision is therefore:
+
+	if (next token is "c" and following token is not "c") {
+	  choose the nested expansion (i.e., go into the [...] construct)
+	} else {
+	  go beyond the [...] construct without entering it.
+	}
+
+This example can be rewritten to combine both syntactic and semantic
+LOOKAHEAD as follows (recognize the first "c" using syntactic
+LOOKAHEAD and the absence of the second using semantic LOOKAHEAD):
+
+	void BC() :
+	{}
+	{
+	  "b"
+	  [ LOOKAHEAD( "c", { getToken(2).kind != C } )
+	    &lt;C:"c"&gt;
+	  ]
+	}
+
+----------------------------------------------------------------
+
+7. GENERAL STRUCTURE OF LOOKAHEAD
+
+We've pretty much covered the various aspects of LOOKAHEAD in the
+previous sections.  A couple of advanced topics follow.  However,
+we shall now present a formal language reference for LOOKAHEAD in
+Java Compiler Compiler:
+
+The general structure of a LOOKAHEAD specification is:
+
+	LOOKAHEAD( amount,
+	           expansion,
+	           { boolean_expression }
+	         )
+
+"amount" specifies the number of tokens to LOOKAHEAD,"expansion"
+specifies the expansion to use to perform syntactic LOOKAHEAD, and
+"boolean_expression" is the expression to use for semantic
+LOOKAHEAD.
+
+At least one of the three entries must be present.  If more than
+one are present, they are separated by commas.  The default values
+for each of these entities is defined below:
+
+"amount":
+ - if "expansion is present, this defaults to 2147483647.
+ - otherwise ("boolean_expression" must be present then) this
+   defaults to 0.
+
+Note: When "amount" is 0, no syntactic LOOKAHEAD is performed.  Also,
+"amount" does not affect the semantic LOOKAHEAD.
+
+"expansion":
+- defaults to the expansion being considered.
+
+"boolean_expression":
+
+- defaults to true.
+
+----------------------------------------------------------------
+
+8. NESTED EVALUATION OF SEMANTIC LOOKAHEAD
+
+TBD
+
+----------------------------------------------------------------
+
+9. JAVACODE PRODUCTIONS
+
+TBD
+
+----------------------------------------------------------------
+
+</PRE>
+<P>
+
+</BODY>
+</HTML>
diff --git a/tools/javacc-4.0/doc/mailinglist.html b/tools/javacc-4.0/doc/mailinglist.html
new file mode 100644
index 0000000000000000000000000000000000000000..84599e05aa7b39663f004416b6dd48a524758767
--- /dev/null
+++ b/tools/javacc-4.0/doc/mailinglist.html
@@ -0,0 +1,43 @@
+<HTML>
+<!--
+
+Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+intellectual property rights relating to technology embodied in the product
+that is described in this document. In particular, and without limitation,
+these intellectual property rights may include one or more of the U.S.
+patents listed at http://www.sun.com/patents and one or more additional
+patents or pending patent applications in the U.S. and in other countries.
+U.S. Government Rights - Commercial software. Government users are subject
+to the Sun Microsystems, Inc. standard license agreement and applicable
+provisions of the FAR and its supplements.  Use is subject to license terms.
+Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+product is covered and controlled by U.S. Export Control laws and may be
+subject to the export or import laws in other countries.  Nuclear, missile,
+chemical biological weapons or nuclear maritime end uses or end users, whether
+direct or indirect, are strictly prohibited.  Export or reexport to countries
+subject to U.S. embargo or to entities identified on U.S. export exclusion
+lists, including, but not limited to, the denied persons and specially
+designated nationals lists is strictly prohibited.
+
+-->
+<HEAD>
+ <title>JavaCC Mailing Lists</title>
+<!-- Changed by: Michael Van De Vanter, 14-Jan-2003 -->
+</HEAD>
+<BODY bgcolor="#FFFFFF" >
+
+<h1>JavaCC [tm]: Mailing Lists </h1>
+
+You may communicate with the JavaCC [tm] developers and other JavaCC users by sending email to one of the JavaCC mailing lists:
+<ul>
+<li><a href="https://javacc.dev.java.net/servlets/SummarizeList?listName=announce">Announcements</a>
+<li><a href="https://javacc.dev.java.net/servlets/SummarizeList?listName=users">Users</a>
+<li><a href="https://javacc.dev.java.net/servlets/SummarizeList?listName=dev">Developers</a>
+<li><a href="https://javacc.dev.java.net/servlets/SummarizeList?listName=issues">Issues</a>
+</ul>
+<p>Note that you may want to search the mailing list archives first to see if your question has already been answered.
+
+</BODY>
+</HTML>
diff --git a/tools/javacc-4.0/doc/simpleREADME.html b/tools/javacc-4.0/doc/simpleREADME.html
new file mode 100644
index 0000000000000000000000000000000000000000..39c9e472990f6bbb956c2657b6afb0c2191a547a
--- /dev/null
+++ b/tools/javacc-4.0/doc/simpleREADME.html
@@ -0,0 +1,412 @@
+<HTML>
+<!--
+
+Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+intellectual property rights relating to technology embodied in the product
+that is described in this document. In particular, and without limitation,
+these intellectual property rights may include one or more of the U.S.
+patents listed at http://www.sun.com/patents and one or more additional
+patents or pending patent applications in the U.S. and in other countries.
+U.S. Government Rights - Commercial software. Government users are subject
+to the Sun Microsystems, Inc. standard license agreement and applicable
+provisions of the FAR and its supplements.  Use is subject to license terms.
+Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+product is covered and controlled by U.S. Export Control laws and may be
+subject to the export or import laws in other countries.  Nuclear, missile,
+chemical biological weapons or nuclear maritime end uses or end users, whether
+direct or indirect, are strictly prohibited.  Export or reexport to countries
+subject to U.S. embargo or to entities identified on U.S. export exclusion
+lists, including, but not limited to, the denied persons and specially
+designated nationals lists is strictly prohibited.
+
+-->
+<HEAD>
+ <title>JavaCC README for SimpleExamples</title>
+<!-- Changed by: Michael Van De Vanter, 14-Jan-2003 -->
+</HEAD>
+<BODY bgcolor="#FFFFFF" >
+
+<H1>JavaCC [tm]: README for SimpleExamples</H1>
+
+<P>
+<PRE>
+This directory contains five examples to get you started using JavaCC [tm].
+Each example is contained in a single grammar file and is listed
+below:
+
+	Simple1.jj
+	Simple2.jj
+	Simple3.jj
+	Simple4.jj
+	NL_Xlator.jj
+
+Once you have tried out and understood each of these examples, you
+should take a look at more complex examples in other sub-directories
+under the examples directory.  But even with just these examples, you
+should be able to get started on reasonably complex grammars.
+
+---------------------------------------------------------------------
+
+Summary Instructions:
+
+If you are a parser and lexical analyzer expert and can understand the
+examples by just reading them, the following instructions show you how
+to get started with JavaCC.  The instructions below are with respect
+to Simple1.jj, but you can build any parser using the same set of
+commands.
+
+1. Run javacc on the grammar input file to generate a bunch of Java
+   files that implement the parser and lexical analyzer (or token
+   manager):
+
+	javacc Simple1.jj
+
+2. Now compile the resulting Java programs:
+
+	javac *.java
+
+3. The parser is now ready to use.  To run the parser, type:
+
+	java Simple1
+
+The Simple1 parser and others in this directory are designed to take
+input from standard input.  Simple1 recognizes matching braces
+followed by zero or more line terminators and then an end of file.
+
+Examples of legal strings in this grammar are:
+
+  "{}", "{{{{{}}}}}", etc.
+
+Examples of illegal strings are:
+
+  "{{{{", "{}{}", "{}}", "{{}{}}", "{ }", "{x}", etc.
+
+Try typing various different inputs to Simple1.  Remember &lt;control-d&gt;
+may be used to indicate the end of file (this is on the UNIX platform).
+Here are some sample runs:
+
+	% java Simple1
+	{{}}&lt;return&gt;
+	&lt;control-d&gt;
+	%
+
+	% java Simple1
+	{x&lt;return&gt;
+	Lexical error at line 1, column 2.  Encountered: "x"
+	TokenMgrError: Lexical error at line 1, column 2.  Encountered: "x" (120), after : ""
+	        at Simple1TokenManager.getNextToken(Simple1TokenManager.java:146)
+	        at Simple1.getToken(Simple1.java:140)
+	        at Simple1.MatchedBraces(Simple1.java:51)
+	        at Simple1.Input(Simple1.java:10)
+	        at Simple1.main(Simple1.java:6)
+	%
+
+	% java Simple1
+	{}}&lt;return&gt;
+	ParseException: Encountered "}" at line 1, column 3.
+	Was expecting one of:
+	    &lt;EOF&gt; 
+	    "\n" ...
+	    "\r" ...
+
+	        at Simple1.generateParseException(Simple1.java:184)
+	        at Simple1.jj_consume_token(Simple1.java:126)
+	        at Simple1.Input(Simple1.java:32)
+	        at Simple1.main(Simple1.java:6)
+	%
+
+---------------------------------------------------------------------
+
+DETAILED DESCRIPTION OF Simple1.jj:
+
+This is a simple JavaCC grammar that recognizes a set of left braces
+followed by the same number of right braces and finally followed by
+zero or more line terminators and finally an end of file.  Examples of
+legal strings in this grammar are:
+
+  "{}", "{{{{{}}}}}", etc.
+
+Examples of illegal strings are:
+
+  "{{{{", "{}{}", "{}}", "{{}{}}", etc.
+
+This grammar file starts with settings for all the options offered by
+JavaCC.  In this case the option settings are their default values.
+Hence these option settings were really not necessary.  One could as
+well have completely omitted the options section, or omitted one or
+more of the individual option settings.  The details of the individual
+options is described in the JavaCC documentation in the web pages.
+
+Following this is a Java compilation unit enclosed between
+"PARSER_BEGIN(name)" and "PARSER_END(name)".  This compilation unit
+can be of arbitrary complexity.  The only constraint on this
+compilation unit is that it must define a class called "name" - the
+same as the arguments to PARSER_BEGIN and PARSER_END.  This is the
+name that is used as the prefix for the Java files generated by the
+parser generator.  The parser code that is generated is inserted
+immediately before the closing brace of the class called "name".
+
+In the above example, the class in which the parser is generated
+contains a main program.  This main program creates an instance of the
+parser object (an object of type Simple1) by using a constructor that
+takes one argument of type java.io.InputStream ("System.in" in this
+case).
+
+The main program then makes a call to the non-terminal in the grammar
+that it would like to parse - "Input" in this case.  All non-terminals
+have equal status in a JavaCC generated parser, and hence one may
+parse with respect to any grammar non-terminal.
+
+Following this is a list of productions.  In this example, there are
+two productions that define the non-terminals, "Input" and
+"MatchedBraces," respectively.  In JavaCC grammars, non-terminals are
+written and implemented (by JavaCC) as Java methods.  When the
+non-terminal is used on the left-hand side of a production, it is
+considered to be declared and its syntax follows the Java syntax.  On
+the right-hand side, its use is similar to a Java method call.
+
+Each production defines its left-hand side non-terminal followed by a
+colon.  This is followed by a bunch of declarations and statements
+within braces (in both cases in the above example, there are no
+declarations and hence this appears as "{}") which are generated as
+common declarations and statements into the generated method.  This is
+then followed by a set of expansions also enclosed within braces.
+
+Lexical tokens (regular expressions) in a JavaCC input grammar are
+either simple strings ("{", "}", "\n", and "\r" in the above example),
+or a more complex regular expression.  In our example above, there is
+one such regular expression "&lt;EOF&gt;" which is matched by the end of
+file.  All complex regular expressions are enclosed within angular
+brackets.
+
+The first production above says that the non-terminal "Input" expands
+to the non-terminal "MethodBraces" followed by zero or more line
+terminators ("\n" or "\r") and then the end of file.
+
+The second production above says that the non-terminal "MatchedBraces"
+expands to the token "{" followed by an optional nested expansion of
+"MatchedBraces" followed by the token "}".  Square brackets [...]
+in a JavaCC input file indicate that the ... is optional.
+
+[...] may also be written as (...)?.  These two forms are equivalent.
+Other structures that may appear in expansions are:
+
+   e1 | e2 | e3 | ... : A choice of e1, e2, e3, etc.
+   ( e )+             : One or more occurrences of e
+   ( e )*             : Zero or more occurrences of e
+
+Note that these may be nested within each other, so we can have
+something like:
+
+   (( e1 | e2 )* [ e3 ] ) | e4
+
+To build this parser, simply run JavaCC on this file and compile the
+resulting Java files:
+
+	javacc Simple1.jj
+	javac *.java
+
+Now you should be able to run the generated parser.  Make sure that
+the current directory is in your CLASSPATH and type:
+
+	java Simple1
+
+Now type a sequence of matching braces followed by a return and an end
+of file (CTRL-D on UNIX machines).  If this is a problem on your
+machine, you can create a file and pipe it as input to the generated
+parser in this manner (piping also does not work on all machines - if
+this is a problem, just replace "System.in" in the grammar file with
+'new FileInputStream("testfile")' and place your input inside this
+file):
+
+	java Simple1 &lt; myfile
+
+Also try entering illegal sequences such as mismatched braces, spaces,
+and carriage returns between braces as well as other characters and
+take a look at the error messages produced by the parser.
+
+---------------------------------------------------------------------
+
+DETAILED DESCRIPTION OF Simple2.jj:
+
+Simple2.jj is a minor modification to Simple1.jj to allow white space
+characters to be interspersed among the braces.  So then input such
+as:
+
+	"{{  }\n}\n\n"
+
+will now be legal.
+
+Take a look at Simple2.jj.  The first thing you will note is that we
+have omitted the options section.  This does not change anything since
+the options in Simple1.jj were all assigned their default values.
+
+The other difference between this file and Simple1.jj is that this
+file contains a lexical specification - the region that starts with
+"SKIP".  Within this region are 4 regular expressions - space, tab,
+newline, and return.  This says that matches of these regular
+expressions are to be ignored (and not considered for parsing).  Hence
+whenever any of these 4 characters are encountered, they are just
+thrown away.
+
+In addition to SKIP, JavaCC has three other lexical specification
+regions.  These are:
+
+. TOKEN:         This is used to specify lexical tokens (see next example)
+. SPECIAL_TOKEN: This is used to specify lexical tokens that are to be
+                 ignored during parsing.  In this sense, SPECIAL_TOKEN is
+                 the same as SKIP.  However, these tokens can be recovered
+                 within parser actions to be handled appropriately.
+. MORE:          This specifies a partial token.  A complete token is
+                 made up of a sequence of MORE's followed by a TOKEN
+                 or SPECIAL_TOKEN.
+
+Please take a look at some of the more complex grammars such as the
+Java grammars for examples of usage of these lexical specification
+regions.
+
+You may build Simple2 and invoke the generated parser with input from
+the keyboard as standard input.
+
+You can also try generating the parser with the various debug options
+turned on and see what the output looks like.  To do this type:
+
+	javacc -debug_parser Simple2.jj
+	javac Simple2*.java
+	java Simple2
+
+Then type:
+
+	javacc -debug_token_manager Simple2.jj
+	javac Simple2*.java
+	java Simple2
+
+Note that token manager debugging produces a lot of diagnostic
+information and it is typically used to look at debug traces a single
+token at a time.
+
+---------------------------------------------------------------------
+
+DETAILED DESCRIPTION OF Simple3.jj:
+
+Simple3.jj is the third and final version of our matching brace
+detector.  This example illustrates the use of the TOKEN region for
+specifying lexical tokens.  In this case, "{" and "}" are defined as
+tokens and given names LBRACE and RBRACE respectively.  These labels
+can then be used within angular brackets (as in the example) to refer
+to this token.  Typically such token specifications are used for
+complex tokens such as identifiers and literals.  Tokens that are
+simple strings are left as is (in the previous examples).
+
+This example also illustrates the use of actions in the grammar
+productions.  The actions inserted in this example count the number of
+matching braces.  Note the use of the declaration region to declare
+variables "count" and "nested_count".  Also note how the non-terminal
+"MatchedBraces" returns its value as a function return value.
+
+---------------------------------------------------------------------
+
+DETAILED DESCRIPTION OF NL_Xlator.jj:
+
+This example goes into the details of writing regular expressions in
+JavaCC grammar files.  It also illustrates a slightly more complex set
+of actions that translate the expressions described by the grammar
+into English.
+
+The new concept in the above example is the use of more complex
+regular expressions.  The regular expression:
+
+  &lt; ID: ["a"-"z","A"-"Z","_"] ( ["a"-"z","A"-"Z","_","0"-"9"] )* &gt;
+
+creates a new regular expression whose name is ID.  This can be
+referred anywhere else in the grammar simply as &lt;ID&gt;.  What follows in
+square brackets are a set of allowable characters - in this case it is
+any of the lower or upper case letters or the underscore.  This is
+followed by 0 or more occurrences of any of the lower or upper case
+letters, digits, or the underscore.
+
+Other constructs that may appear in regular expressions are:
+
+  ( ... )+	: One or more occurrences of ...
+  ( ... )?	: An optional occurrence of ... (Note that in the case
+                  of lexical tokens, (...)? and [...] are not equivalent)
+  ( r1 | r2 | ... ) : Any one of r1, r2, ...
+
+A construct of the form [...] is a pattern that is matched by the
+characters specified in ... .  These characters can be individual
+characters or character ranges.  A "~" before this construct is a
+pattern that matches any character not specified in ... .  Therefore:
+
+  ["a"-"z"] matches all lower case letters
+  ~[] matches any character
+  ~["\n","\r"] matches any character except the new line characters
+
+When a regular expression is used in an expansion, it takes a value of
+type "Token".  This is generated into the generated parser directory
+as "Token.java".  In the above example, we have defined a variable of
+type "Token" and assigned the value of the regular expression to it.
+
+---------------------------------------------------------------------
+
+DETAILED DESCRIPTION OF IdList.jj:
+
+This example illustrates an important attribute of the SKIP
+specification.  The main point to note is that the regular expressions
+in the SKIP specification are only ignored *between tokens* and not
+*within tokens*.  This grammar accepts any sequence of identifiers
+with white space in between.
+
+A legal input for this grammar is:
+
+"abc xyz123 A B C \t\n aaa"
+
+This is because any number of the SKIP regular expressions are allowed
+in between consecutive &lt;Id&gt;'s.  However, the following is not a legal
+input:
+
+"xyz 123"
+
+This is because the space character after "xyz" is in the SKIP
+category and therefore causes one token to end and another to begin.
+This requires "123" to be a separate token and hence does not match
+the grammar.
+
+If spaces were OK within &lt;Id&gt;'s, then all one has to do is to replace
+the definition of Id to:
+
+TOKEN :
+{
+  &lt; Id: ["a"-"z","A"-"Z"] ( (" ")* ["a"-"z","A"-"Z","0"-"9"] )* &gt;
+}
+
+Note that having a space character within a TOKEN specification does
+not mean that the space character cannot be used in the SKIP
+specification.  All this means is that any space character that
+appears in the context where it can be placed within an identifier
+will participate in the match for &lt;Id&gt;, whereas all other space
+characters will be ignored.  The details of the matching algorithm are
+described in the JavaCC documentation in the web pages.
+
+As a corollary, one must define as tokens anything within which
+characters such as white space characters must not be present.  In the
+above example, if &lt;Id&gt; was defined as a grammar production rather than
+a lexical token as shown below this paragraph, then "xyz 123" would
+have been recognized as a legitimate &lt;Id&gt; (wrongly).
+
+void Id() :
+{}
+{
+  &lt;["a"-"z","A"-"Z"]&gt; ( &lt;["a"-"z","A"-"Z","0"-"9"]&gt; )*
+}
+
+Note that in the above definition of non-terminal Id, it is made up of
+a sequence of single character tokens (note the location of &lt;...&gt;s),
+and hence white space is allowed between these characters.
+
+---------------------------------------------------------------------
+</PRE>
+
+</BODY>
+</HTML>
diff --git a/tools/javacc-4.0/doc/support.html b/tools/javacc-4.0/doc/support.html
new file mode 100644
index 0000000000000000000000000000000000000000..720bf9c77578cc886262074e6091ae10305e60f5
--- /dev/null
+++ b/tools/javacc-4.0/doc/support.html
@@ -0,0 +1,38 @@
+<HTML>
+<!--
+
+Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+intellectual property rights relating to technology embodied in the product
+that is described in this document. In particular, and without limitation,
+these intellectual property rights may include one or more of the U.S.
+patents listed at http://www.sun.com/patents and one or more additional
+patents or pending patent applications in the U.S. and in other countries.
+U.S. Government Rights - Commercial software. Government users are subject
+to the Sun Microsystems, Inc. standard license agreement and applicable
+provisions of the FAR and its supplements.  Use is subject to license terms.
+Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+product is covered and controlled by U.S. Export Control laws and may be
+subject to the export or import laws in other countries.  Nuclear, missile,
+chemical biological weapons or nuclear maritime end uses or end users, whether
+direct or indirect, are strictly prohibited.  Export or reexport to countries
+subject to U.S. embargo or to entities identified on U.S. export exclusion
+lists, including, but not limited to, the denied persons and specially
+designated nationals lists is strictly prohibited.
+
+-->
+<HEAD>
+ <title>JavaCC Support</title>
+<!-- Changed by: Michael Van De Vanter, 14-Jan-2003 -->
+</HEAD>
+<BODY bgcolor="#FFFFFF" >
+
+<h1>JavaCC [tm]: Customer Support</h1>
+
+Java Compiler Compiler [tm] is being supported on an informal basis by its developers
+through <a href="mailinglist.html">electronic mailing lists</a>.
+<P>
+
+</BODY>
+</HTML>
diff --git a/tools/javacc-4.0/doc/tokenmanager.html b/tools/javacc-4.0/doc/tokenmanager.html
new file mode 100644
index 0000000000000000000000000000000000000000..fb025d5fe2804cec645336ded6b0f4bcb25fa746
--- /dev/null
+++ b/tools/javacc-4.0/doc/tokenmanager.html
@@ -0,0 +1,337 @@
+<HTML>
+<!--
+
+Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+intellectual property rights relating to technology embodied in the product
+that is described in this document. In particular, and without limitation,
+these intellectual property rights may include one or more of the U.S.
+patents listed at http://www.sun.com/patents and one or more additional
+patents or pending patent applications in the U.S. and in other countries.
+U.S. Government Rights - Commercial software. Government users are subject
+to the Sun Microsystems, Inc. standard license agreement and applicable
+provisions of the FAR and its supplements.  Use is subject to license terms.
+Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+product is covered and controlled by U.S. Export Control laws and may be
+subject to the export or import laws in other countries.  Nuclear, missile,
+chemical biological weapons or nuclear maritime end uses or end users, whether
+direct or indirect, are strictly prohibited.  Export or reexport to countries
+subject to U.S. embargo or to entities identified on U.S. export exclusion
+lists, including, but not limited to, the denied persons and specially
+designated nationals lists is strictly prohibited.
+
+-->
+<HEAD>
+ <title>JavaCC: TokenManager MiniTutorial</title>
+<!-- Changed by: Michael Van De Vanter, 14-Jan-2003 -->
+</HEAD>
+<BODY bgcolor="#FFFFFF" >
+
+<H1>JavaCC [tm]: TokenManager MiniTutorial</H1>
+
+<PRE>
+The JavaCC [tm] lexical specification is organized into a set of "lexical
+states".  Each lexical state is named with an identifier.  There is a
+standard lexical state called DEFAULT.  The generated token manager is
+at any moment in one of these lexical states.  When the token manager
+is initialized, it starts off in the DEFAULT state, by default.  The
+starting lexical state can also be specified as a parameter while
+constructing a token manager object.
+
+Each lexical state contains an ordered list of regular expressions;
+the order is derived from the order of occurrence in the input file.
+There are four kinds of regular expressions: SKIP, MORE, TOKEN, and
+SPECIAL_TOKEN.
+
+All regular expressions that occur as expansion units in the grammar
+are considered to be in the DEFAULT lexical state and their order of
+occurrence is determined by their position in the grammar file.
+
+A token is matched as follows:  All regular expressions in the current
+lexical state are considered as potential match candidates.  The
+token manager consumes the maximum number of characters from the input
+stream possible that match one of these regular expressions.  That is,
+the token manager prefers the longest possible match.  If there are
+multiple longest matches (of the same length), the regular expression
+that is matched is the one with the earliest order of occurrence in
+the grammar file.
+
+As mentioned above, the token manager is in exactly one state at any
+moment.  At this moment, the token manager only considers the regular
+expressions defined in this state for matching purposes. After a match,
+one can specify an action to be executed as well as a new lexical
+state to move to.  If a new lexical state is not specified, the token
+manager remains in the current state.
+
+The regular expression kind specifies what to do when a regular
+expression has been successfully matched:
+
+SKIP: Simply throw away the matched string (after executing any
+      lexical action).
+MORE: Continue (to whatever the next state is) taking the matched
+      string along.  This string will be a prefix of the new matched
+      string.
+TOKEN: Create a token using the matched string and send it to the
+       parser (or any caller).
+SPECIAL_TOKEN: Creates a special token that does not participate in
+               parsing.  Already described earlier.
+
+(The mechanism of accessing special tokens is at the end of this
+page)
+
+Whenever the end of file &lt;EOF&gt; is detected, it causes the creation of
+an &lt;EOF&gt; token (regardless of the current state of the lexical
+analyzer).  However, if an &lt;EOF&gt; is detected in the middle of a match
+for a regular expression, or immediately after a MORE regular
+expression has been matched, an error is reported.
+
+After the regular expression is matched, the lexical action is
+executed.  All the variables (and methods) declared in the
+TOKEN_MGR_DECLS region (see below) are available here for use. In
+addition, the variables and methods listed below are also available
+for use.
+
+Immediately after this, the token manager changes state to that
+specified (if any).
+
+After that the action specified by the kind of the regular expression
+is taken (SKIP, MORE, ... ). If the kind is TOKEN, the matched token
+is returned.  If the kind is SPECIAL_TOKEN, the matched token is saved
+to be returned along with the next TOKEN that is matched.
+
+-------------------------------------------------------------------
+
+The following variables are available for use within lexical actions:
+
+1. StringBuffer image (READ/WRITE):
+
+"image" (different from the "image" field of the matched token) is a
+StringBuffer variable that contains all the characters that have been
+matched since the last SKIP, TOKEN, or SPECIAL_TOKEN.  You are free
+to make whatever changes you wish to it so long as you do not assign
+it to null (since this variable is used by the generated token manager
+also).  If you make changes to "image", this change is passed on to
+subsequent matches (if the current match is a MORE).  The content of
+"image" *does not* automatically get assigned to the "image" field
+of the matched token.  If you wish this to happen, you must explicitly
+assign it in a lexical action of a TOKEN or SPECIAL_TOKEN regular
+expression.
+
+Example:
+
+&lt;DEFAULT&gt; MORE : { "a" : S1 }
+
+&lt;S1&gt; MORE :
+{
+  "b"
+    { int l = image.length()-1; image.setCharAt(l, image.charAt(l).toUpperCase()); }
+    ^1                                                                             ^2
+    : S2
+}
+
+&lt;S2&gt; TOKEN :
+{
+  "cd" { x = image; } : DEFAULT
+       ^3
+}
+
+In the above example, the value of "image" at the 3 points marked by
+^1, ^2, and ^3 are:
+
+At ^1: "ab"
+At ^2: "aB"
+At ^3: "aBcd"
+
+2. int lengthOfMatch (READ ONLY):
+
+This is the length of the current match (is not cumulative over MORE's).
+See example below.  You should not modify this variable.
+
+Example:
+
+Using the same example as above, the values of "lengthOfMatch" are:
+
+At ^1: 1 (the size of "b")
+At ^2: 1 (does not change due to lexical actions)
+At ^3: 2 (the size of "cd")
+
+3. int curLexState (READ ONLY):
+
+This is the index of the current lexical state.  You should not modify
+this variable.  Integer constants whose names are those of the lexical
+state are generated into the ...Constants file, so you can refer to
+lexical states without worrying about their actual index value.
+
+4. inputStream (READ ONLY):
+
+This is an input stream of the appropriate type (one of
+ASCII_CharStream, ASCII_UCodeESC_CharStream, UCode_CharStream, or
+UCode_UCodeESC_CharStream depending on the values of options
+UNICODE_INPUT and JAVA_UNICODE_ESCAPE).  The stream is currently at
+the last character consumed for this match.  Methods of inputStream
+can be called.  For example, getEndLine and getEndColumn can be called
+to get the line and column number information for the current match.
+inputStream may not be modified.
+
+5. Token matchedToken (READ/WRITE):
+
+This variable may be used only in actions associated with TOKEN and
+SPECIAL_TOKEN regular expressions.  This is set to be the token that
+will get returned to the parser.  You may change this variable and
+thereby cause the changed token to be returned to the parser instead
+of the original one.  It is here that you can assign the value of
+variable "image" to "matchedToken.image".  Typically that's how your
+changes to "image" has effect outside the lexical actions.
+
+Example:
+
+If we modify the last regular expression specification of the
+above example to:
+
+&lt;S2&gt; TOKEN :
+{
+  "cd" { matchedToken.image = image.toString(); } : DEFAULT
+}
+
+Then the token returned to the parser will have its ".image" field
+set to "aBcd".  If this assignment was not performed, then the
+".image" field will remain as "abcd".
+
+6. void SwitchTo(int):
+
+Calling this method switches you to the specified lexical state.  This
+method may be called from parser actions also (in addition to being
+called from lexical actions).  However, care must be taken when using
+this method to switch states from the parser since the lexical
+analysis could be many tokens ahead of the parser in the presence of
+large lookaheads.  When you use this method within a lexical action,
+you must ensure that it is the last statement executed in the action
+(otherwise, strange things could happen).  If there is a state change
+specified using the ": state" syntax, it overrides all switchTo calls,
+hence there is no point having a switchTo call when there is an
+explicit state change specified.  In general, calling this method
+should be resorted to only when you cannot do it any other way.  Using
+this method of switching states also causes you to lose some of the
+semantic checking that JavaCC does when you use the standard syntax.
+
+-------------------------------------------------------------------
+
+Lexical actions have access to a set of class level declarations.
+These declarations are introduced within the JavaCC file using the
+following syntax:
+
+token_manager_decls ::=
+  "TOKEN_MGR_DECLS" ":"
+  "{" java_declarations_and_code "}"
+
+These declarations are accessible from all lexical actions.
+
+
+EXAMPLES
+--------
+
+Example 1: Comments
+
+SKIP :
+{
+  "/*" : WithinComment
+}
+
+&lt;WithinComment&gt; SKIP :
+{
+  "*/" : DEFAULT
+}
+
+&lt;WithinComment&gt; MORE :
+{
+  &lt;~[]&gt;
+}
+
+
+Example 2: String Literals with actions to print the length of the
+string:
+
+TOKEN_MGR_DECLS :
+{
+  int stringSize;
+}
+
+MORE :
+{
+  "\"" {stringSize = 0;} : WithinString
+}
+
+&lt;WithinString&gt; TOKEN :
+{
+  &lt;STRLIT: "\""&gt; {System.out.println("Size = " + stringSize);} : DEFAULT
+}
+
+&lt;WithinString&gt; MORE :
+{
+  &lt;~["\n","\r"]&gt; {stringSize++;}
+}
+
+
+
+HOW SPECIAL TOKENS ARE SENT TO THE PARSER:
+
+Special tokens are like tokens, except that they are permitted to
+appear anywhere in the input file (between any two tokens).  Special
+tokens can be specified in the grammar input file using the reserved
+word "SPECIAL_TOKEN" instead of "TOKEN" as in:
+
+SPECIAL_TOKEN :
+{
+  &lt;SINGLE_LINE_COMMENT: "//" (~["\n","\r"])* ("\n"|"\r"|"\r\n")&gt;
+}
+
+Any regular expression defined to be a SPECIAL_TOKEN may be accessed
+in a special manner from user actions in the lexical and grammar
+specifications.  This allows these tokens to be recovered during
+parsing while at the same time these tokens do not participate in the
+parsing.
+
+JavaCC has been bootstrapped to use this feature to automatically
+copy relevant comments from the input grammar file into the generated
+files.
+
+Details:
+
+The class Token now has an additional field:
+
+   Token specialToken;
+
+This field points to the special token immediately prior to the
+current token (special or otherwise).  If the token immediately prior
+to the current token is a regular token (and not a special token),
+then this field is set to null.  The "next" fields of regular tokens
+continue to have the same meaning - i.e., they point to the next
+regular token except in the case of the EOF token where the "next"
+field is null.  The "next" field of special tokens point to the
+special token immediately following the current token.  If the token
+immediately following the current token is a regular token, the "next"
+field is set to null.
+
+This is clarified by the following example.  Suppose you wish to print
+all special tokens prior to the regular token "t" (but only those that
+are after the regular token before "t"):
+
+  if (t.specialToken == null) return;
+    // The above statement determines that there are no special tokens
+    // and returns control to the caller.
+  Token tmp_t = t.specialToken;
+  while (tmp_t.specialToken != null) tmp_t = tmp_t.specialToken;
+    // The above line walks back the special token chain until it
+    // reaches the first special token after the previous regular
+    // token.
+  while (tmp_t != null) {
+    System.out.println(tmp_t.image);
+    tmp_t = tmp_t.next;
+  }
+    // The above loop now walks the special token chain in the forward
+    // direction printing them in the process.  
+</PRE>
+
+</BODY>
+</HTML>
diff --git a/tools/javacc-4.0/examples/CORBA-IDL/IDL.jj b/tools/javacc-4.0/examples/CORBA-IDL/IDL.jj
new file mode 100644
index 0000000000000000000000000000000000000000..4b3b58a81ccac95c5ae6f057cc69685401cdcd03
--- /dev/null
+++ b/tools/javacc-4.0/examples/CORBA-IDL/IDL.jj
@@ -0,0 +1,860 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+PARSER_BEGIN(IDLParser)
+
+public class IDLParser {
+
+  public static void main(String args[]) {
+    IDLParser parser;
+    if (args.length == 0) {
+      System.out.println("IDL Parser Version 0.1:  Reading from standard input . . .");
+      parser = new IDLParser(System.in);
+    } else if (args.length == 1) {
+      System.out.println("IDL Parser Version 0.1:  Reading from file " + args[0] + " . . .");
+      try {
+        parser = new IDLParser(new java.io.FileInputStream(args[0]));
+      } catch (java.io.FileNotFoundException e) {
+        System.out.println("IDL Parser Version 0.1:  File " + args[0] + " not found.");
+        return;
+      }
+    } else {
+      System.out.println("IDL Parser Version 0.1:  Usage is one of:");
+      System.out.println("         java IDLParser < inputfile");
+      System.out.println("OR");
+      System.out.println("         java IDLParser inputfile");
+      return;
+    }
+    try {
+      parser.specification();
+      System.out.println("IDL Parser Version 0.1:  Java program parsed successfully.");
+    } catch (ParseException e) {
+      System.out.println("IDL Parser Version 0.1:  Encountered errors during parse.");
+    }
+  }
+
+}
+
+PARSER_END(IDLParser)
+
+
+/*
+ * Tokens to ignore in the BNF follow.
+ */
+
+SKIP :
+{
+  < " " >
+| < "\t" >
+| < "\n" >
+| < "\r" >
+| < "//" (~["\n"])* "\n" >
+| <"/*" (~["*"])* "*" (~["/"] (~["*"])* "*")* "/">
+| < "#" ([" ","\t"])* (["0"-"9"])+
+    (([" ","\t"])* "\"" (~["\""])+ "\""
+           ([" ","\t"])* (["0"-"9"])* ([" ","\t"])* (["0"-"9"])*)? "\n" >
+}
+
+/* Production 1 */
+
+void specification() :
+{}
+{
+  ( definition() )+
+}
+
+/* Production 2 */
+
+void definition() :
+{}
+{
+  type_dcl() ";"
+|
+  const_dcl() ";"
+|
+  except_dcl() ";"
+|
+  interfacex() ";"
+|
+  module() ";"
+}
+
+/* Production 3 */
+
+void module() :
+{}
+{
+  "module" identifier() "{" ( definition() )+ "}"
+}
+
+/* Production 4 */
+
+void interfacex() :
+{}
+{
+  LOOKAHEAD(3)
+  interface_dcl()
+|
+  forward_dcl()
+}
+
+/* Production 5 */
+
+void interface_dcl() :
+{}
+{
+  interface_header() "{" interface_body() "}"
+}
+
+/* Production 6 */
+
+void forward_dcl() :
+{}
+{
+  "interface" identifier()
+}
+
+/* Production 7 */
+
+void interface_header() :
+{}
+{
+  "interface" identifier() [ inheritance_spec() ]
+}
+
+/* Production 8 */
+
+void interface_body() :
+{}
+{
+  ( export() )*
+}
+
+/* Production 9 */
+
+void export() :
+{}
+{
+  type_dcl() ";"
+|
+  const_dcl() ";"
+|
+  except_dcl() ";"
+|
+  attr_dcl() ";"
+|
+  op_dcl() ";"
+}
+
+/* Production 10 */
+
+void inheritance_spec() :
+{}
+{
+  ":" scoped_name() ( "," scoped_name() )*
+}
+
+/* Production 11 */
+
+void scoped_name() :
+{}
+{
+  [ "::" ] identifier() ( "::" identifier() )*
+}
+
+/* Production 12 */
+
+void const_dcl() :
+{}
+{
+  "const" const_type() identifier() "=" const_exp()
+}
+
+/* Production 13 */
+
+void const_type() :
+{}
+{
+  integer_type()
+|
+  char_type()
+|
+  boolean_type()
+|
+  floating_pt_type()
+|
+  string_type()
+|
+  scoped_name()
+}
+
+/* Production 14 */
+
+void const_exp() :
+{}
+{
+  or_expr()
+}
+
+/* Production 15 */
+
+void or_expr() :
+{}
+{
+  xor_expr() ( "|" xor_expr() )*
+}
+
+/* Production 16 */
+
+void xor_expr() :
+{}
+{
+  and_expr() ( "^" and_expr() )*
+}
+
+/* Production 17 */
+
+void and_expr() :
+{}
+{
+  shift_expr() ( "&" shift_expr() )*
+}
+
+/* Production 18 */
+
+void shift_expr() :
+{}
+{
+  add_expr() ( ( ">>" | "<<" ) add_expr() )*
+}
+
+/* Production 19 */
+
+void add_expr() :
+{}
+{
+  mult_expr() ( ( "+" | "-" ) mult_expr() )*
+}
+
+/* Production 20 */
+
+void mult_expr() :
+{}
+{
+  unary_expr() ( ( "*" | "/" | "%" ) unary_expr() )*
+}
+
+/* Production 21 */
+
+void unary_expr() :
+{}
+{
+  [ unary_operator() ] primary_expr()
+}
+
+/* Production 22 */
+void unary_operator() :
+{}
+{
+  "-"
+|
+  "+"
+|
+  "~"
+}
+
+/* Production 23 */
+
+void primary_expr() :
+{}
+{
+  scoped_name()
+|
+  literal()
+|
+  "(" const_exp() ")"
+}
+
+/* Production 24 */
+
+void literal() :
+{}
+{
+  integer_literal()
+|
+  string_literal()
+|
+  character_literal()
+|
+  floating_pt_literal()
+|
+  boolean_literal()
+}
+
+/* Production 25 */
+
+void boolean_literal() :
+{}
+{
+  "TRUE"
+|
+  "FALSE"
+}
+
+/* Production 26 */
+
+void positive_int_const() :
+{}
+{
+  const_exp()
+}
+
+/* Production 27 */
+
+void type_dcl() :
+{}
+{
+  "typedef" type_declarator()
+|
+  struct_type()
+|
+  union_type()
+|
+  enum_type()
+}
+
+/* Production 28 */
+
+void type_declarator() :
+{}
+{
+  type_spec() declarators()
+}
+
+/* Production 29 */
+
+void type_spec() :
+{}
+{
+  simple_type_spec()
+|
+  constr_type_spec()
+}
+
+/* Production 30 */
+
+void simple_type_spec() :
+{}
+{
+  base_type_spec()
+|
+  template_type_spec()
+|
+  scoped_name()
+}
+
+/* Production 31 */
+
+void base_type_spec() :
+{}
+{
+  floating_pt_type()
+|
+  integer_type()
+|
+  char_type()
+|
+  boolean_type()
+|
+  octet_type()
+|
+  any_type()
+}
+
+/* Production 32 */
+
+void template_type_spec() :
+{}
+{
+  sequence_type()
+|
+  string_type()
+}
+
+/* Production 33 */
+
+void constr_type_spec() :
+{}
+{
+  struct_type()
+|
+  union_type()
+|
+  enum_type()
+}
+
+/* Production 34 */
+
+void declarators() :
+{}
+{
+  declarator() ( "," declarator() )*
+}
+
+/* Production 35 */
+
+void declarator() :
+{}
+{
+  LOOKAHEAD(2)
+  complex_declarator()
+|
+  simple_declarator()
+}
+
+/* Production 36 */
+
+void simple_declarator() :
+{}
+{
+  identifier()
+}
+
+/* Production 37 */
+
+void complex_declarator() :
+{}
+{
+  array_declarator()
+}
+
+/* Production 38 */
+
+void floating_pt_type() :
+{}
+{
+  "float"
+|
+  "double"
+}
+
+/* Production 39 */
+
+void integer_type() :
+{}
+{
+  signed_int()
+|
+  unsigned_int()
+}
+
+/* Production 40 */
+
+void signed_int() :
+{}
+{
+  signed_long_int()
+|
+  signed_short_int()
+}
+
+/* Production 41 */
+
+void signed_long_int() :
+{}
+{
+  "long"
+}
+
+/* Production 42 */
+
+void signed_short_int() :
+{}
+{
+  "short"
+}
+
+/* Production 43 */
+
+void unsigned_int() :
+{}
+{
+  LOOKAHEAD(2)
+  unsigned_long_int()
+|
+  unsigned_short_int()
+}
+
+/* Production 44 */
+
+void unsigned_long_int() :
+{}
+{
+  "unsigned" "long"
+}
+
+/* Production 45 */
+
+void unsigned_short_int() :
+{}
+{
+  "unsigned" "short"
+}
+
+/* Production 46 */
+
+void char_type() :
+{}
+{
+  "char"
+}
+
+/* Production 47 */
+
+void boolean_type() :
+{}
+{
+  "boolean"
+}
+
+/* Production 48 */
+
+void octet_type() :
+{}
+{
+  "octet"
+}
+
+/* Production 49 */
+
+void any_type() :
+{}
+{
+  "any"
+}
+
+/* Production 50 */
+
+void struct_type() :
+{}
+{
+  "struct" identifier() "{" member_list() "}"
+}
+
+/* Production 51 */
+
+void member_list() :
+{}
+{
+  ( member() )+
+}
+
+/* Production 52 */
+
+void member() :
+{}
+{
+  type_spec() declarators() ";"
+}
+
+/* Production 53 */
+
+void union_type() :
+{}
+{
+  "union" identifier() "switch" "(" switch_type_spec() ")" "{" switch_body() "}"
+}
+
+/* Production 54 */
+
+void switch_type_spec() :
+{}
+{
+  integer_type()
+|
+  char_type()
+|
+  boolean_type()
+|
+  enum_type()
+|
+  scoped_name()
+}
+
+/* Production 55 */
+
+void switch_body() :
+{}
+{
+  ( casex() )+
+}
+
+/* Production 56 */
+
+void casex() :
+{}
+{
+  ( case_label() )+ element_spec() ";"
+}
+
+/* Production 57 */
+
+void case_label() :
+{}
+{
+  "case" const_exp() ":"
+|
+  "default" ":"
+}
+
+/* Production 58 */
+
+void element_spec() :
+{}
+{
+  type_spec() declarator()
+}
+
+/* Production 59 */
+
+void enum_type() :
+{}
+{
+  "enum" identifier() "{" enumerator() ( "," enumerator() )* "}"
+}
+
+/* Production 60 */
+
+void enumerator() :
+{}
+{
+  identifier()
+}
+
+/* Production 61 */
+
+void sequence_type() :
+{}
+{
+  "sequence" "<" simple_type_spec() [ "," positive_int_const() ] ">"
+}
+
+/* Production 62 */
+
+void string_type() :
+{}
+{
+  "string" [ "<" positive_int_const() ">" ]
+}
+
+/* Production 63 */
+
+void array_declarator() :
+{}
+{
+  identifier() ( fixed_array_size() )+
+}
+
+/* Production 64 */
+
+void fixed_array_size() :
+{}
+{
+  "[" positive_int_const() "]"
+}
+
+/* Production 65 */
+
+void attr_dcl() :
+{}
+{
+  [ "readonly" ] "attribute" param_type_spec() simple_declarator() ( "," simple_declarator() )*
+}
+
+/* Production 66 */
+
+void except_dcl() :
+{}
+{
+  "exception" identifier() "{" ( member() )* "}"
+}
+
+/* Production 67 */
+
+void op_dcl() :
+{}
+{
+  [ op_attribute() ] op_type_spec() identifier() parameter_dcls() [ raises_expr() ] [ context_expr() ]
+}
+
+/* Production 68 */
+
+void op_attribute() :
+{}
+{
+  "oneway"
+}
+
+/* Production 69 */
+
+void op_type_spec() :
+{}
+{
+  param_type_spec()
+|
+  "void"
+}
+
+/* Production 70 */
+
+void parameter_dcls() :
+{}
+{
+  "(" [ param_dcl() ( "," param_dcl() )* ] ")"
+}
+
+/* Production 71 */
+
+void param_dcl() :
+{}
+{
+  param_attribute() param_type_spec() simple_declarator()
+}
+
+/* Production 72 */
+
+void param_attribute() :
+{}
+{
+  "in"
+|
+  "out"
+|
+  "inout"
+}
+
+/* Production 73 */
+
+void raises_expr() :
+{}
+{
+  "raises" "(" scoped_name() ( "," scoped_name() )* ")"
+}
+
+/* Production 74 */
+
+void context_expr() :
+{}
+{
+  "context" "(" string_literal() ( "," string_literal() )* ")"
+}
+
+/* Production 75 */
+
+void param_type_spec() :
+{}
+{
+  base_type_spec()
+|
+  string_type()
+|
+  scoped_name()
+}
+
+/* Definitions of complex regular expressions follow */
+
+void identifier() :
+{}
+{
+  <ID>
+}
+
+void integer_literal() :
+{}
+{
+  <OCTALINT>
+|
+  <DECIMALINT>
+|
+  <HEXADECIMALINT>
+}
+
+void string_literal() :
+{}
+{
+  <STRING>
+}
+
+void character_literal() :
+{}
+{
+  <CHARACTER>
+}
+
+void floating_pt_literal() :
+{}
+{
+  <FLOATONE>
+|
+  <FLOATTWO>
+}
+
+TOKEN :
+{
+  <  ID : ["a"-"z","A"-"Z", "_"] (["a"-"z","A"-"Z","0"-"9","_"])* >
+| <  OCTALINT : "0" (["0"-"7"])* (["u","U","l","L"])? >
+| <  DECIMALINT : ["1"-"9"] (["0"-"9"])* (["u","U","l","L"])? >
+| <  HEXADECIMALINT : ("0x"|"0X") (["0"-"9","a"-"f","A"-"F"])+ (["u","U","l","L"])? >
+| <  FLOATONE : ((["0"-"9"])+ "." (["0"-"9"])* | (["0"-"9"])* "." (["0"-"9"])+)
+   (["e","E"] (["-","+"])? (["0"-"9"])+)? (["f","F","l","L"])? >
+| <  FLOATTWO : (["0"-"9"])+ ["e","E"] (["-","+"])?
+   (["0"-"9"])+ (["f","F","l","L"])? >
+| <  CHARACTER : "'"
+   (   (~["'","\\","\n","\r"])
+   | ("\\" (
+             ["n","t","v","b","r","f","a","\\","?","'","\""]
+            |
+             "0" (["0"-"7"])*
+            |
+             ["1"-"9"] (["0"-"9"])*
+            |
+             ("0x" | "0X") (["0"-"9","a"-"f","A"-"F"])+
+           )
+     )
+   )
+   "'" >
+| <  STRING : "\""
+   ( ( ~["\"","\\","\n","\r"])
+   | ("\\" (
+             ["n","t","v","b","r","f","a","\\","?","'","\""]
+            |
+             "0" (["0"-"7"])*
+            |
+             ["1"-"9"] (["0"-"9"])*
+            |
+             ("0x" | "0X") (["0"-"9","a"-"f","A"-"F"])+
+           )
+     )
+   )*
+   "\"" >
+}
diff --git a/tools/javacc-4.0/examples/CORBA-IDL/README b/tools/javacc-4.0/examples/CORBA-IDL/README
new file mode 100644
index 0000000000000000000000000000000000000000..1e3cb1fbf253790d3ac5edd43d81793f9fecbc1f
--- /dev/null
+++ b/tools/javacc-4.0/examples/CORBA-IDL/README
@@ -0,0 +1,29 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+This directory contains an CORBA 2.0 grammar for IDL.  Build it in the
+usual manner and try it out.
+
+	javacc IDL.jj
+	javac *.java
+	java IDLParser <idlfile>
diff --git a/tools/javacc-4.0/examples/GUIParsing/ParserVersion/CalcGUI.java b/tools/javacc-4.0/examples/GUIParsing/ParserVersion/CalcGUI.java
new file mode 100644
index 0000000000000000000000000000000000000000..e0b18c0d09db24d835413c9126aef1bcfc540c11
--- /dev/null
+++ b/tools/javacc-4.0/examples/GUIParsing/ParserVersion/CalcGUI.java
@@ -0,0 +1,232 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+
+import java.awt.*;
+
+public class CalcGUI extends Frame implements CalcInputParserConstants {
+
+  /**
+   * A button object is created for each calculator button.  Since
+   * there is going to be only one calculator GUI, these objects can
+   * be static.
+   */
+  static Button one = new Button("1");
+  static Button two = new Button("2");
+  static Button three = new Button("3");
+  static Button four = new Button("4");
+  static Button five = new Button("5");
+  static Button six = new Button("6");
+  static Button seven = new Button("7");
+  static Button eight = new Button("8");
+  static Button nine = new Button("9");
+  static Button zero = new Button("0");
+  static Button dot = new Button(".");
+  static Button equal = new Button("=");
+  static Button add = new Button("+");
+  static Button sub = new Button("-");
+  static Button mul = new Button("*");
+  static Button div = new Button("/");
+  static Button quit = new Button("QUIT");
+
+  /**
+   * The display window with its initial setting.
+   */
+  static Label display = new Label("0 ");
+
+  /**
+   * Constructor that creates the full GUI.  This is called by the
+   * main program to create one calculator GUI.
+   */
+  public CalcGUI() {
+
+    super("Calculator");
+    GridBagLayout gb = new GridBagLayout();
+    setLayout(gb);
+    GridBagConstraints gbc = new GridBagConstraints();
+
+    display.setFont(new Font("TimesRoman", Font.BOLD, 18));
+    display.setAlignment(Label.RIGHT);
+    gbc.gridwidth = GridBagConstraints.REMAINDER;
+    gbc.fill = GridBagConstraints.BOTH;
+    gbc.weightx = 1.0;
+    gbc.weighty = 0.0;
+    gb.setConstraints(display, gbc);
+    add(display);
+
+    Panel buttonPanel = new Panel();
+    buttonPanel.setFont(new Font("TimesRoman", Font.BOLD, 14));
+    buttonPanel.setLayout(new GridLayout(4,4));
+    buttonPanel.add(one); buttonPanel.add(two); buttonPanel.add(three); buttonPanel.add(four);
+    buttonPanel.add(five); buttonPanel.add(six); buttonPanel.add(seven); buttonPanel.add(eight);
+    buttonPanel.add(nine); buttonPanel.add(zero); buttonPanel.add(dot);  buttonPanel.add(equal);
+    buttonPanel.add(add); buttonPanel.add(sub); buttonPanel.add(mul); buttonPanel.add(div);
+    gbc.weighty = 1.0;
+    gb.setConstraints(buttonPanel, gbc);
+    add(buttonPanel);
+
+    quit.setFont(new Font("TimesRoman", Font.BOLD, 14));
+    gbc.gridheight = GridBagConstraints.REMAINDER;
+    gbc.weighty = 0.0;
+    gb.setConstraints(quit, gbc);
+    add(quit);
+    pack();
+    show();
+  }
+
+  /**
+   * Note how handleEvent creates tokens and sends them to the parser
+   * through the producer-consumer.
+   */
+  public boolean handleEvent(Event evt) {
+    Token t;
+    if (evt.id != Event.ACTION_EVENT) {
+      return false;
+    }
+    if (evt.target == one) {
+      t = new Token();
+      t.kind = DIGIT;
+      t.image = "1";
+      ProducerConsumer.pc.addToken(t);
+      return true;
+    }
+    if (evt.target == two) {
+      t = new Token();
+      t.kind = DIGIT;
+      t.image = "2";
+      ProducerConsumer.pc.addToken(t);
+      return true;
+    }
+    if (evt.target == three) {
+      t = new Token();
+      t.kind = DIGIT;
+      t.image = "3";
+      ProducerConsumer.pc.addToken(t);
+      return true;
+    }
+    if (evt.target == four) {
+      t = new Token();
+      t.kind = DIGIT;
+      t.image = "4";
+      ProducerConsumer.pc.addToken(t);
+      return true;
+    }
+    if (evt.target == five) {
+      t = new Token();
+      t.kind = DIGIT;
+      t.image = "5";
+      ProducerConsumer.pc.addToken(t);
+      return true;
+    }
+    if (evt.target == six) {
+      t = new Token();
+      t.kind = DIGIT;
+      t.image = "6";
+      ProducerConsumer.pc.addToken(t);
+      return true;
+    }
+    if (evt.target == seven) {
+      t = new Token();
+      t.kind = DIGIT;
+      t.image = "7";
+      ProducerConsumer.pc.addToken(t);
+      return true;
+    }
+    if (evt.target == eight) {
+      t = new Token();
+      t.kind = DIGIT;
+      t.image = "8";
+      ProducerConsumer.pc.addToken(t);
+      return true;
+    }
+    if (evt.target == nine) {
+      t = new Token();
+      t.kind = DIGIT;
+      t.image = "9";
+      ProducerConsumer.pc.addToken(t);
+      return true;
+    }
+    if (evt.target == zero) {
+      t = new Token();
+      t.kind = DIGIT;
+      t.image = "0";
+      ProducerConsumer.pc.addToken(t);
+      return true;
+    }
+    if (evt.target == dot) {
+      t = new Token();
+      t.kind = DOT;
+      t.image = ".";
+      ProducerConsumer.pc.addToken(t);
+      return true;
+    }
+    if (evt.target == equal) {
+      t = new Token();
+      t.kind = EQ;
+      t.image = "=";
+      ProducerConsumer.pc.addToken(t);
+      return true;
+    }
+    if (evt.target == add) {
+      t = new Token();
+      t.kind = ADD;
+      t.image = "+";
+      ProducerConsumer.pc.addToken(t);
+      return true;
+    }
+    if (evt.target == sub) {
+      t = new Token();
+      t.kind = SUB;
+      t.image = "-";
+      ProducerConsumer.pc.addToken(t);
+      return true;
+    }
+    if (evt.target == mul) {
+      t = new Token();
+      t.kind = MUL;
+      t.image = "*";
+      ProducerConsumer.pc.addToken(t);
+      return true;
+    }
+    if (evt.target == div) {
+      t = new Token();
+      t.kind = DIV;
+      t.image = "/";
+      ProducerConsumer.pc.addToken(t);
+      return true;
+    }
+    if (evt.target == quit) {
+      System.exit(0);
+    }
+    return false;
+  }
+
+  public static void print(double value) {
+    display.setText(Double.toString(value) + " ");
+  }
+
+  public static void print(String image) {
+    display.setText(image + " ");
+  }
+
+}
diff --git a/tools/javacc-4.0/examples/GUIParsing/ParserVersion/CalcInput.jj b/tools/javacc-4.0/examples/GUIParsing/ParserVersion/CalcInput.jj
new file mode 100644
index 0000000000000000000000000000000000000000..09a493ab50f943725292e8830f11bab601113220
--- /dev/null
+++ b/tools/javacc-4.0/examples/GUIParsing/ParserVersion/CalcInput.jj
@@ -0,0 +1,135 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+
+options {
+  USER_TOKEN_MANAGER = true;
+}
+
+PARSER_BEGIN(CalcInputParser)
+
+public class CalcInputParser {
+}
+
+PARSER_END(CalcInputParser)
+
+void Input() :
+	{
+	  double larg = 0.0;
+	  double rarg;
+	}
+{
+  ( 
+    [
+      larg=Number() 
+	{
+	  CalcGUI.print(larg);
+	}
+    ]
+    (
+      <ADD>
+      rarg=Number()
+	{
+	  larg = larg + rarg;
+	  CalcGUI.print(larg);
+	}
+    |
+      <SUB>
+      rarg=Number()
+	{
+	  larg = larg - rarg;
+	  CalcGUI.print(larg);
+	}
+    |
+      <MUL>
+      rarg=Number()
+	{
+	  larg = larg * rarg;
+	  CalcGUI.print(larg);
+	}
+    |
+      <DIV>
+      rarg=Number()
+	{
+	  larg = (rarg==0) ? Float.POSITIVE_INFINITY : (larg / rarg);
+	  CalcGUI.print(larg);
+	}
+    )*
+    <EQ: "=" >
+  )*
+}
+
+double Number() :
+	{
+	  Token t;
+	  String image = "";
+	  double value = 0.0;
+	  double decimalPlace = 1.0;
+	}
+{
+  (
+    t=<DIGIT>
+	{
+	  image += t.image;
+	  value = value*10 + Integer.parseInt(t.image);
+	  CalcGUI.print(image);
+	}
+  )+
+  [
+    <DOT>
+	{
+	  image += ".";
+	  CalcGUI.print(image);
+	}
+    (
+      t=<DIGIT>
+	{
+	  image += t.image;
+	  decimalPlace *= 0.1;
+	  value = value + Integer.parseInt(t.image)*decimalPlace;
+	  CalcGUI.print(image);
+	}
+    )+
+  ]
+	{
+	  return value;
+	}
+|
+  <DOT>
+	{
+	  image = "0.";
+	  CalcGUI.print(image);
+	}
+  (
+    t=<DIGIT>
+	{
+	  image += t.image;
+	  decimalPlace *= 0.1;
+	  value = value + Integer.parseInt(t.image)*decimalPlace;
+	  CalcGUI.print(image);
+	}
+  )+
+	{
+	  return value;
+	}
+}
diff --git a/tools/javacc-4.0/examples/GUIParsing/ParserVersion/Main.java b/tools/javacc-4.0/examples/GUIParsing/ParserVersion/Main.java
new file mode 100644
index 0000000000000000000000000000000000000000..5468e9e2bd579e8b990c1e3d2da7474ff4052c7b
--- /dev/null
+++ b/tools/javacc-4.0/examples/GUIParsing/ParserVersion/Main.java
@@ -0,0 +1,40 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+
+public class Main {
+
+  public static void main(String[] args) {
+    new CalcGUI();
+    TokenManager tm = new TokenCollector();
+    CalcInputParser cp = new CalcInputParser(tm);
+    while (true) {
+      try {
+        cp.Input();
+      } catch (ParseException e) {
+        CalcGUI.print("ERROR (click 0)");
+      }
+    }
+  }
+
+}
diff --git a/tools/javacc-4.0/examples/GUIParsing/ParserVersion/ProducerConsumer.java b/tools/javacc-4.0/examples/GUIParsing/ParserVersion/ProducerConsumer.java
new file mode 100644
index 0000000000000000000000000000000000000000..6e4dc07dee9fdfc0c54a763e6dcb03565f90e5b5
--- /dev/null
+++ b/tools/javacc-4.0/examples/GUIParsing/ParserVersion/ProducerConsumer.java
@@ -0,0 +1,64 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+
+public class ProducerConsumer {
+
+  /**
+   * A single producer-consumer instance that is used by others.
+   */
+  public static ProducerConsumer pc = new ProducerConsumer();
+
+  /**
+   * The data structure where the tokens are stored.
+   */
+  private java.util.Vector queue = new java.util.Vector();
+
+  /**
+   * The producer calls this method to add a new token
+   * whenever it is available.
+   */
+  synchronized public void addToken(Token token) {
+    queue.addElement(token);
+    notify();
+  }
+
+  /**
+   * The consumer calls this method to get the next token
+   * in the queue.  If the queue is empty, this method
+   * blocks until a token becomes available.
+   */
+  synchronized public Token getToken() {
+    if (queue.size() == 0) {
+      try {
+        wait();
+      } catch (InterruptedException willNotHappen) {
+        throw new Error();
+      }
+    }
+    Token retval = (Token)(queue.elementAt(0));
+    queue.removeElementAt(0);
+    return retval;
+  }
+
+}
diff --git a/tools/javacc-4.0/examples/GUIParsing/ParserVersion/README b/tools/javacc-4.0/examples/GUIParsing/ParserVersion/README
new file mode 100644
index 0000000000000000000000000000000000000000..5138c61835c037ee9990f6ee0008f76bd0631da2
--- /dev/null
+++ b/tools/javacc-4.0/examples/GUIParsing/ParserVersion/README
@@ -0,0 +1,46 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+This version of the GUI parsing example defines the GUI interaction as
+a JavaCC grammar using tokens that are generated by a user built token
+manager.  Note that these tokens appear in the parser (CalcInput.jj)
+without definitions (such as <DIGIT>, <DOT>, etc.).  JavaCC does not
+require token definitions when USER_TOKEN_MANAGER is set to true.  The
+token manager is implemented in TokenCollector.java to extract tokens
+from a producer-consumer object in ProducerConsumer.java.  The tokens
+are stuffed into ProducerConsumer.java by the GUI which is defined in
+CalcGUI.java.  The whole system is invoked through Main.java.
+
+The point of this example is to illustrate:
+
+. How a parser can be used without the standard token manager.
+. The fact that tokens can be generated by entities that are not even
+  streams (a GUI in this example).
+. That GUI interaction can be modeled as a grammar and this grammar
+  can then be used to implement the innards of a GUI based tool.
+
+To run the calculator (which is what this example implements), do:
+
+	javacc CalcInput.jj
+	javac *.java
+	java Main
diff --git a/tools/javacc-4.0/examples/GUIParsing/ParserVersion/TokenCollector.java b/tools/javacc-4.0/examples/GUIParsing/ParserVersion/TokenCollector.java
new file mode 100644
index 0000000000000000000000000000000000000000..a1a6a7616f8598ffacf6c494ed066e17aec01bcf
--- /dev/null
+++ b/tools/javacc-4.0/examples/GUIParsing/ParserVersion/TokenCollector.java
@@ -0,0 +1,31 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+
+public class TokenCollector implements TokenManager {
+
+  public Token getNextToken() {
+    return ProducerConsumer.pc.getToken();
+  }
+
+}
diff --git a/tools/javacc-4.0/examples/GUIParsing/README b/tools/javacc-4.0/examples/GUIParsing/README
new file mode 100644
index 0000000000000000000000000000000000000000..97503c55d6cb104c575535d43c2db958f393f583
--- /dev/null
+++ b/tools/javacc-4.0/examples/GUIParsing/README
@@ -0,0 +1,36 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+In this directory are two examples that illustrate the use of JavaCC
+generated parsers to collect input from a GUI and process it
+appropriately.  The example used is a simple calculator.  There are
+two versions of this example:
+
+. A version that uses a JavaCC parser without the JavaCC token manager
+  in directory ParserVersion.
+
+. A version that uses a JavaCC token manager without the JavaCC parser
+  in directory TokenMgrVersion.  This example also illustrates the
+  ability to build a state machine as a lexical specification.
+
+The README files in these directories provide more details.
diff --git a/tools/javacc-4.0/examples/GUIParsing/TokenMgrVersion/CalcGUI.java b/tools/javacc-4.0/examples/GUIParsing/TokenMgrVersion/CalcGUI.java
new file mode 100644
index 0000000000000000000000000000000000000000..21fa40481f9a030138fd1a749798f0e58b9491fd
--- /dev/null
+++ b/tools/javacc-4.0/examples/GUIParsing/TokenMgrVersion/CalcGUI.java
@@ -0,0 +1,249 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+
+import java.awt.*;
+
+public class CalcGUI extends Frame implements CalcInputParserConstants {
+
+  /**
+   * A button object is created for each calculator button.  Since
+   * there is going to be only one calculator GUI, these objects can
+   * be static.
+   */
+  static Button one = new Button("1");
+  static Button two = new Button("2");
+  static Button three = new Button("3");
+  static Button four = new Button("4");
+  static Button five = new Button("5");
+  static Button six = new Button("6");
+  static Button seven = new Button("7");
+  static Button eight = new Button("8");
+  static Button nine = new Button("9");
+  static Button zero = new Button("0");
+  static Button dot = new Button(".");
+  static Button equal = new Button("=");
+  static Button add = new Button("+");
+  static Button sub = new Button("-");
+  static Button mul = new Button("*");
+  static Button div = new Button("/");
+  static Button quit = new Button("QUIT");
+
+  /**
+   * The display window with its initial setting.
+   */
+  static Label display = new Label("0 ");
+
+  /**
+   * The class that collects the characters produced by the GUI
+   */
+  static final CharCollector collector = new CharCollector();
+
+  static final CharStream getCollector()
+  {
+     return collector;
+  }
+
+  /**
+   * string that holds what the calculator displays
+   */
+  static String label = "0";
+
+  /**
+   * flag to indicate if this is the first digit.
+   */
+  static boolean firstDigit = true;
+
+  /**
+   * Indicates an error has occured 
+   */
+  static boolean error = false;
+
+  /**
+   * Constructor that creates the full GUI.  This is called by the
+   * main program to create one calculator GUI.
+   */
+  public CalcGUI() {
+
+    super("Calculator");
+
+    GridBagLayout gb = new GridBagLayout();
+    setLayout(gb);
+    GridBagConstraints gbc = new GridBagConstraints();
+
+    display.setFont(new Font("TimesRoman", Font.BOLD, 18));
+    display.setAlignment(Label.RIGHT);
+    gbc.gridwidth = GridBagConstraints.REMAINDER;
+    gbc.fill = GridBagConstraints.BOTH;
+    gbc.weightx = 1.0;
+    gbc.weighty = 0.0;
+    gb.setConstraints(display, gbc);
+    add(display);
+
+    Panel buttonPanel = new Panel();
+    buttonPanel.setFont(new Font("TimesRoman", Font.BOLD, 14));
+    buttonPanel.setLayout(new GridLayout(4,4));
+    buttonPanel.add(one); buttonPanel.add(two); buttonPanel.add(three); buttonPanel.add(four);
+    buttonPanel.add(five); buttonPanel.add(six); buttonPanel.add(seven); buttonPanel.add(eight);
+    buttonPanel.add(nine); buttonPanel.add(zero); buttonPanel.add(dot);  buttonPanel.add(equal);
+    buttonPanel.add(add); buttonPanel.add(sub); buttonPanel.add(mul); buttonPanel.add(div);
+    gbc.weighty = 1.0;
+    gb.setConstraints(buttonPanel, gbc);
+    add(buttonPanel);
+
+    quit.setFont(new Font("TimesRoman", Font.BOLD, 14));
+    gbc.gridheight = GridBagConstraints.REMAINDER;
+    gbc.weighty = 0.0;
+    gb.setConstraints(quit, gbc);
+    add(quit);
+    pack();
+    show();
+  }
+
+  /**
+   * Here we just return the character that is input.
+   */
+  public boolean handleEvent(Event evt) {
+    char c = 0;
+ 
+    if (evt.id != Event.ACTION_EVENT) {
+      return false;
+    }
+
+    if (evt.target == quit) {
+      System.exit(0);
+    }
+
+    if (error)
+    {
+       if (evt.target == zero)
+       {
+          error = false;
+          print("0");
+          firstDigit = true;
+          return true;
+       }
+
+       return false;
+    }
+
+    if (evt.target == equal) {
+      c = '=';
+      firstDigit = true;
+    }
+    else if (evt.target == add) {
+      c = '+';
+      label = "0";
+      firstDigit = true;
+    }
+    else if (evt.target == sub) {
+      c = '-';
+      label = "0";
+      firstDigit = true;
+    }
+    else if (evt.target == mul) {
+      c = '*';
+      label = "0";
+      firstDigit = true;
+    }
+    else if (evt.target == div) {
+      c = '/';
+      label = "0";
+      firstDigit = true;
+    }
+    else 
+    {
+      if (firstDigit)
+         label = "";
+      firstDigit = false;
+
+      if (evt.target == one) {
+        c = '1';
+        label += c;
+      }
+      else if (evt.target == two) {
+        c = '2';
+        label += c;
+      }
+      else if (evt.target == three) {
+        c = '3';
+        label += c;
+      }
+      else if (evt.target == four) {
+        c = '4';
+        label += c;
+      }
+      else if (evt.target == five) {
+        c = '5';
+        label += c;
+      }
+      else if (evt.target == six) {
+        c = '6';
+        label += c;
+      }
+      else if (evt.target == seven) {
+        c = '7';
+        label += c;
+      }
+      else if (evt.target == eight) {
+        c = '8';
+        label += c;
+      }
+      else if (evt.target == nine) {
+        c = '9';
+        label += c;
+      }
+      else if (evt.target == zero) {
+        c = '0';
+        label += c;
+      }
+      else if (evt.target == dot) {
+        c = '.';
+        label += ".";
+      }
+      else
+        return false;
+    }
+
+    print(label);
+    collector.put(c);
+    return true;
+  }
+
+  public static void print(double value) {
+    display.setText(label = Double.toString(value));
+  }
+
+  public static void print(String image) {
+    display.setText(label = image);
+  }
+
+  public static void Error(String image) {
+     print(image);
+     Toolkit.getDefaultToolkit().beep();
+     collector.Clear();
+     label = "0";
+     error = true;
+  }
+
+}
diff --git a/tools/javacc-4.0/examples/GUIParsing/TokenMgrVersion/CalcInput.jj b/tools/javacc-4.0/examples/GUIParsing/TokenMgrVersion/CalcInput.jj
new file mode 100644
index 0000000000000000000000000000000000000000..0e47aa4ac8b37d75200281bf4a150d3b01b18d84
--- /dev/null
+++ b/tools/javacc-4.0/examples/GUIParsing/TokenMgrVersion/CalcInput.jj
@@ -0,0 +1,215 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+
+options {
+  USER_CHAR_STREAM = true;
+  BUILD_PARSER = false;
+}
+
+PARSER_BEGIN(CalcInputParser)
+
+public class CalcInputParser {
+}
+
+PARSER_END(CalcInputParser)
+
+/**
+ * This example shows an elaborate example to construct a Finite Automaton
+ * where for every character, there is a move.
+ */
+TOKEN_MGR_DECLS:
+{
+   /**
+    * A pointer to the GUI object.
+    */
+   static CalcGUI gui;
+
+   /**
+    * Holds the result of the expression evaluation so far.
+    */
+   static double result = 0.0;
+
+   /**
+    * Flag to indiate the very first operand so that the correct result
+    * is displayed in this case.
+    */
+   static boolean firstOperand = true;
+
+   /**
+    * Shows the result after a particular operation.
+    */
+   private static void ShowResult()
+   {
+      if (firstOperand)
+      {
+         image.setLength(image.length() - 1);
+         if (image.length() > 0)
+            result = Double.valueOf(image.toString()).doubleValue();
+         else
+            result = 0.0;
+
+         firstOperand = false;
+      }
+
+      gui.print(result);
+   }
+}
+
+/**
+ * The first operand
+ */
+<OPERAND> MORE :
+{
+   < ["0"-"9"] >
+ |
+   "."  : REQUIRED_DIGIT
+}
+
+/**
+ * This state is entered when we need to get at least one digit (after a .)
+ */
+<REQUIRED_DIGIT> MORE:
+{
+   < ["0"-"9"] > : OPTIONAL_DIGIT
+}
+
+/**
+ * FA for (["0"-"9"])*.
+ */
+<OPTIONAL_DIGIT> MORE:
+{
+   < ["0"-"9"] >
+}
+
+/**
+ * You can get an operator at any time (in any lexical state), except when
+ * a digit is required (afdter a .). Then just go to a state where the next
+ * operand is scanned (for that particular operator).
+ */
+<OP_OR_OPERAND, OPERAND, OPTIONAL_DIGIT, OP_LOOP> SKIP:
+{
+   <PLUS: "+"> { ShowResult(); } : SEEN_PLUS
+ |
+   <MINUS: "-"> { ShowResult(); } : SEEN_MINUS
+ |
+   <STAR: "*"> { ShowResult(); } : SEEN_STAR
+ |
+   <SLASH: "/"> { ShowResult(); } : SEEN_SLASH
+}
+
+/**
+ * If you get a = in any state, just display the current result.
+ */
+<OPERAND, OPTIONAL_DIGIT, OP_LOOP> SKIP:
+{
+   <EQ: "="> { ShowResult(); } : OP_OR_OPERAND
+}
+
+/**
+ * Here you can either give an operand (to start a new expression) or give
+ * an operator that works on the current result.
+ */
+<OP_OR_OPERAND> SKIP:
+{
+   <"=">
+}
+
+<OP_OR_OPERAND> MORE:
+{
+   < ["0"-"9"] > { firstOperand = true; } : OPERAND
+ |
+   "." { firstOperand = true; } : REQUIRED_DIGIT
+}
+
+<SEEN_PLUS, ADD_RIGHT_OPERAND> MORE:
+{
+   < ["0"-"9"] > : ADD_RIGHT_OPERAND
+ |
+   "."  : ADD_REQUIRED_DIGIT
+}
+
+<DO_ADD, ADD_REQUIRED_DIGIT> MORE:
+{
+   < ["0"-"9"] > : DO_ADD
+}
+
+<DO_ADD, ADD_RIGHT_OPERAND> SKIP:
+{
+   < "" >
+      { result += Double.valueOf(image.toString()).doubleValue(); } : OP_LOOP
+}
+
+<SEEN_MINUS, SUB_RIGHT_OPERAND> MORE:
+{
+   < ["0"-"9"] > : SUB_RIGHT_OPERAND
+ |
+   "."  : SUB_REQUIRED_DIGIT
+}
+
+<DO_SUB, SUB_REQUIRED_DIGIT> MORE:
+{
+   < ["0"-"9"] > : DO_SUB
+}
+
+<DO_SUB, SUB_RIGHT_OPERAND> SKIP:
+{
+   < "" >
+      { result -= Double.valueOf(image.toString()).doubleValue(); } : OP_LOOP
+}
+
+<SEEN_STAR, MUL_RIGHT_OPERAND> MORE:
+{
+   < ["0"-"9"] > : MUL_RIGHT_OPERAND
+ |
+   "."  : MUL_REQUIRED_DIGIT
+}
+
+<DO_MUL, MUL_REQUIRED_DIGIT> MORE:
+{
+   < ["0"-"9"] > : DO_MUL
+}
+
+<DO_MUL, MUL_RIGHT_OPERAND> SKIP:
+{
+   < "" >
+      { result *= Double.valueOf(image.toString()).doubleValue(); } : OP_LOOP
+}
+
+<SEEN_SLASH, DIV_RIGHT_OPERAND> MORE:
+{
+   < ["0"-"9"] > : DIV_RIGHT_OPERAND
+ |
+   "."  : DIV_REQUIRED_DIGIT
+}
+
+<DO_DIV, DIV_REQUIRED_DIGIT> MORE:
+{
+   < ["0"-"9"] > : DO_DIV
+}
+
+<DO_DIV, DIV_RIGHT_OPERAND> SKIP:
+{
+   < "" >
+      { result /= Double.valueOf(image.toString()).doubleValue(); } : OP_LOOP
+}
diff --git a/tools/javacc-4.0/examples/GUIParsing/TokenMgrVersion/CharCollector.java b/tools/javacc-4.0/examples/GUIParsing/TokenMgrVersion/CharCollector.java
new file mode 100644
index 0000000000000000000000000000000000000000..2826de75db43ec383eac9cffee6e79e30070aee3
--- /dev/null
+++ b/tools/javacc-4.0/examples/GUIParsing/TokenMgrVersion/CharCollector.java
@@ -0,0 +1,218 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+
+public class CharCollector implements CharStream {
+
+  int bufsize;
+  int available;
+  int tokenBegin;
+  public int bufpos = -1;
+  private char[] buffer;
+  private int maxNextCharInd = 0;
+
+  private final void ExpandBuff(boolean wrapAround)
+  {
+     char[] newbuffer = new char[bufsize + 2048];
+
+     try
+     {
+        if (wrapAround)
+        {
+           System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin);
+           System.arraycopy(buffer, 0, newbuffer, bufsize - tokenBegin, bufpos);
+           buffer = newbuffer;
+           maxNextCharInd = (bufpos += (bufsize - tokenBegin));
+        }
+        else
+        {
+           System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin);
+           buffer = newbuffer;
+           maxNextCharInd = (bufpos -= tokenBegin);
+        }
+     }
+     catch (Throwable t)
+     {
+        System.out.println("Error : " + t.getClass().getName());
+        throw new Error();
+     }
+
+     bufsize += 2048;
+     available = bufsize;
+     tokenBegin = 0;
+  }
+
+  private final void FillBuff()
+  {
+     if (maxNextCharInd == available)
+     {
+        if (available == bufsize)
+        {
+           if (tokenBegin > 2048)
+           {
+              bufpos = maxNextCharInd = 0;
+              available = tokenBegin;
+           }
+           else if (tokenBegin < 0)
+              bufpos = maxNextCharInd = 0;
+           else
+              ExpandBuff(false);
+        }
+        else if (available > tokenBegin)
+           available = bufsize;
+        else if ((tokenBegin - available) < 2048)
+           ExpandBuff(true);
+        else
+           available = tokenBegin;
+     }
+
+     try {
+       wait();
+     } catch (InterruptedException willNotHappen) {
+       throw new Error();
+     }
+  }
+
+  /** 
+   * Puts a character into the buffer.
+   */
+  synchronized public final void put(char c)
+  {
+     buffer[maxNextCharInd++] = c;
+     notify();
+  }
+
+  public char BeginToken() throws java.io.IOException
+  {
+     tokenBegin = -1;
+     char c = readChar();
+     tokenBegin = bufpos;
+
+     return c;
+  }
+
+  private int inBuf = 0;
+  synchronized public final char readChar() throws java.io.IOException
+  {
+     if (inBuf > 0)
+     {
+        --inBuf;
+        return (char)((char)0xff & buffer[(bufpos == bufsize - 1) ? (bufpos = 0) : ++bufpos]);
+     }
+
+     if (++bufpos >= maxNextCharInd)
+        FillBuff();
+
+     return buffer[bufpos];
+  }
+
+  /**
+   * @deprecated 
+   * @see #getEndColumn
+   */
+
+  public final int getColumn() {
+      return 0;
+  }
+
+  /**
+   * @deprecated 
+   * @see #getEndLine
+   */
+
+  public final int getLine() {
+      return 0;
+  }
+
+  public final int getEndColumn() {
+      return 0;
+  }
+
+  public final int getEndLine() {
+      return 0;
+  }
+
+  public final int getBeginColumn() {
+      return 0;
+  }
+
+  public final int getBeginLine() {
+      return 0;
+  }
+
+  public final void backup(int amount) {
+
+    inBuf += amount;
+    if ((bufpos -= amount) < 0)
+       bufpos += bufsize;
+  }
+
+  public CharCollector(int buffersize)
+  {
+    available = bufsize = buffersize;
+    buffer = new char[buffersize];
+  }
+
+  public CharCollector()
+  {
+    available = bufsize = 4096;
+    buffer = new char[4096];
+  }
+
+  public void Clear()
+  {
+     bufpos = -1;
+     maxNextCharInd = 0;
+     inBuf = 0;
+  }
+
+  public final String GetImage()
+  {
+     if (bufpos >= tokenBegin)
+        return new String(buffer, tokenBegin, bufpos - tokenBegin + 1);
+     else
+        return new String(buffer, tokenBegin, bufsize - tokenBegin) +
+                              new String(buffer, 0, bufpos + 1);
+  }
+
+  public final char[] GetSuffix(int len)
+  {
+     char[] ret = new char[len];
+
+     if (bufpos + 1 >= len)
+        System.arraycopy(buffer, bufpos - len + 1, ret, 0, len);
+     else
+     {
+        System.arraycopy(buffer, bufsize - (len - bufpos - 1), ret, 0,
+                                                          len - bufpos - 1);
+        System.arraycopy(buffer, 0, ret, len - bufpos, bufpos + 1);
+     }
+
+     return ret;
+  }
+
+  public void Done()
+  {
+     buffer = null;
+  }
+}
diff --git a/tools/javacc-4.0/examples/GUIParsing/TokenMgrVersion/Main.java b/tools/javacc-4.0/examples/GUIParsing/TokenMgrVersion/Main.java
new file mode 100644
index 0000000000000000000000000000000000000000..94da424c46ab46124f116b68cbfb8f264eb7aebc
--- /dev/null
+++ b/tools/javacc-4.0/examples/GUIParsing/TokenMgrVersion/Main.java
@@ -0,0 +1,38 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+
+public class Main {
+
+  public static void main(String[] args) {
+    CalcGUI gui = new CalcGUI();
+    MyLexer lexer = new MyLexer(gui);
+    while (true) {
+      try {
+        lexer.getNextToken();
+      } catch (TokenMgrError e) {
+      }
+    }
+  }
+
+}
diff --git a/tools/javacc-4.0/examples/GUIParsing/TokenMgrVersion/MyLexer.java b/tools/javacc-4.0/examples/GUIParsing/TokenMgrVersion/MyLexer.java
new file mode 100644
index 0000000000000000000000000000000000000000..03cb3a429e576dd43b1b6cb58e9f0c3edfbeabbb
--- /dev/null
+++ b/tools/javacc-4.0/examples/GUIParsing/TokenMgrVersion/MyLexer.java
@@ -0,0 +1,47 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+
+
+/**
+ * A subclass of CalcInputTokenManager so that we can do better error reporting
+ * via the GUI object.
+ */
+class MyLexer extends CalcInputParserTokenManager {
+
+   /**
+    * We redefined the lexical error reporting function so that it beeps
+    * and displays a messgae thru the GUI.
+    */
+   protected void LexicalError() {
+     CalcGUI.Error("ERROR (click 0)");
+     ReInit(gui.getCollector(), OPERAND);
+     result = 0.0;
+   }
+
+   public MyLexer(CalcGUI guiObj)
+   {
+      super(guiObj.getCollector(), OPERAND);
+      gui = guiObj;
+   }
+}
diff --git a/tools/javacc-4.0/examples/GUIParsing/TokenMgrVersion/README b/tools/javacc-4.0/examples/GUIParsing/TokenMgrVersion/README
new file mode 100644
index 0000000000000000000000000000000000000000..7088be5af7c5f59188ecded30f08d865a4352a57
--- /dev/null
+++ b/tools/javacc-4.0/examples/GUIParsing/TokenMgrVersion/README
@@ -0,0 +1,58 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+This version of the GUI parsing example defines the GUI interaction as
+a JavaCC lexical specification where the characters are read from the
+GUI and there is an finite automaton (FA) built out of lexical states
+that have moves on these characters. In the grammar, the
+USER_CHAR_STREAM option is set to true and the BUILD_PARSER option has
+bee set to false.  The event handler method stuffs the characters into
+a buffer from which characters are returned to the lexical analyzer
+(by readChar). The whole system is invoked through Main.java.
+
+The point of this example is to illustrate:
+
+. A very detailed example of an FA simulation using lexical states
+  where every character moves the FA.
+
+. How a lexical analyzer can be used without a standard (JavaCC
+  generated) CharStream object.
+
+. How a lexical analyzer can be used without a parser.
+
+. The fact that input can come from entities that are not even streams
+  (a GUI in this example).
+
+. That GUI interaction can be modeled as a regular expression
+  specification.
+
+To run the calculator (which is what this example implements), do:
+
+	javacc CalcInput.jj
+	javac *.java
+	java Main
+
+Homework:
+
+   Simplify the grammar so that (["0"-"9"])* is treated as a single
+   entity for moving the FA.
diff --git a/tools/javacc-4.0/examples/Interpreter/ASTAddNode.java b/tools/javacc-4.0/examples/Interpreter/ASTAddNode.java
new file mode 100644
index 0000000000000000000000000000000000000000..1593cc3cdaf5c969c165a2b5c698e779a5950839
--- /dev/null
+++ b/tools/javacc-4.0/examples/Interpreter/ASTAddNode.java
@@ -0,0 +1,43 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+
+/* JJT: 0.2.2 */
+
+
+
+public class ASTAddNode extends SimpleNode {
+  ASTAddNode(int id) {
+    super(id);
+  }
+
+
+  public void interpret()
+  {
+     jjtGetChild(0).interpret();
+     jjtGetChild(1).interpret();
+
+     stack[--top] = new Integer(((Integer)stack[top]).intValue() +
+                                ((Integer)stack[top + 1]).intValue());
+  }
+}
diff --git a/tools/javacc-4.0/examples/Interpreter/ASTAndNode.java b/tools/javacc-4.0/examples/Interpreter/ASTAndNode.java
new file mode 100644
index 0000000000000000000000000000000000000000..0dc799354777966f30a92ef65873afdd0e2d64fa
--- /dev/null
+++ b/tools/javacc-4.0/examples/Interpreter/ASTAndNode.java
@@ -0,0 +1,51 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+
+
+/* JJT: 0.2.2 */
+
+
+
+public class ASTAndNode extends SimpleNode {
+  ASTAndNode(int id) {
+    super(id);
+  }
+
+
+  public void interpret()
+  {
+     jjtGetChild(0).interpret();
+
+     if (!((Boolean)stack[top]).booleanValue())
+     {
+        stack[top] = new Boolean(false);
+        return;
+     }
+
+     jjtGetChild(1).interpret();
+     stack[--top] = new Boolean(((Boolean)stack[top]).booleanValue() &&
+                                ((Boolean)stack[top + 1]).booleanValue());
+  }
+
+}
diff --git a/tools/javacc-4.0/examples/Interpreter/ASTAssignment.java b/tools/javacc-4.0/examples/Interpreter/ASTAssignment.java
new file mode 100644
index 0000000000000000000000000000000000000000..55181938b500fe233fc27775e3be5415cafaa95a
--- /dev/null
+++ b/tools/javacc-4.0/examples/Interpreter/ASTAssignment.java
@@ -0,0 +1,43 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+
+
+/* JJT: 0.2.2 */
+
+
+
+public class ASTAssignment extends SimpleNode {
+  ASTAssignment(int id) {
+    super(id);
+  }
+
+
+  public void interpret()
+  {
+     String name;
+
+     jjtGetChild(1).interpret();
+     symtab.put(name = ((ASTId)jjtGetChild(0)).name, stack[top]);
+  }
+}
diff --git a/tools/javacc-4.0/examples/Interpreter/ASTBitwiseAndNode.java b/tools/javacc-4.0/examples/Interpreter/ASTBitwiseAndNode.java
new file mode 100644
index 0000000000000000000000000000000000000000..c972a607c5d178545d89dbe8002412538f1334fa
--- /dev/null
+++ b/tools/javacc-4.0/examples/Interpreter/ASTBitwiseAndNode.java
@@ -0,0 +1,49 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+
+/* JJT: 0.2.2 */
+
+
+
+
+public class ASTBitwiseAndNode extends SimpleNode {
+  ASTBitwiseAndNode(int id) {
+    super(id);
+  }
+
+
+  public void interpret()
+  {
+     jjtGetChild(0).interpret();
+     jjtGetChild(1).interpret();
+
+     if (stack[top] instanceof Boolean)
+        stack[--top] = new Boolean(((Boolean)stack[top]).booleanValue() &
+                                ((Boolean)stack[top + 1]).booleanValue());
+     else if (stack[top] instanceof Integer)
+        stack[--top] = new Integer(((Integer)stack[top]).intValue() &
+                                ((Integer)stack[top + 1]).intValue());
+  }
+
+}
diff --git a/tools/javacc-4.0/examples/Interpreter/ASTBitwiseComplNode.java b/tools/javacc-4.0/examples/Interpreter/ASTBitwiseComplNode.java
new file mode 100644
index 0000000000000000000000000000000000000000..d3c3fe6c01ac4fbe202beac5d0647217beb97ad7
--- /dev/null
+++ b/tools/javacc-4.0/examples/Interpreter/ASTBitwiseComplNode.java
@@ -0,0 +1,42 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+
+
+/* JJT: 0.2.2 */
+
+
+
+public class ASTBitwiseComplNode extends SimpleNode {
+  ASTBitwiseComplNode(int id) {
+    super(id);
+  }
+
+
+  public void interpret()
+  {
+     jjtGetChild(0).interpret();
+
+     stack[top] = new Integer(~((Integer)stack[top]).intValue());
+  }
+}
diff --git a/tools/javacc-4.0/examples/Interpreter/ASTBitwiseOrNode.java b/tools/javacc-4.0/examples/Interpreter/ASTBitwiseOrNode.java
new file mode 100644
index 0000000000000000000000000000000000000000..31e3df7a18469cc620a2456919f5a0dc98c6a0d4
--- /dev/null
+++ b/tools/javacc-4.0/examples/Interpreter/ASTBitwiseOrNode.java
@@ -0,0 +1,48 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+
+
+/* JJT: 0.2.2 */
+
+
+
+public class ASTBitwiseOrNode extends SimpleNode {
+  ASTBitwiseOrNode(int id) {
+    super(id);
+  }
+
+
+  public void interpret()
+  {
+     jjtGetChild(0).interpret();
+     jjtGetChild(1).interpret();
+
+     if (stack[top] instanceof Boolean)
+        stack[--top] = new Boolean(((Boolean)stack[top]).booleanValue() |
+                                ((Boolean)stack[top + 1]).booleanValue());
+     else if (stack[top] instanceof Integer)
+        stack[--top] = new Integer(((Integer)stack[top]).intValue() |
+                                ((Integer)stack[top + 1]).intValue());
+  }
+}
diff --git a/tools/javacc-4.0/examples/Interpreter/ASTBitwiseXorNode.java b/tools/javacc-4.0/examples/Interpreter/ASTBitwiseXorNode.java
new file mode 100644
index 0000000000000000000000000000000000000000..ef2787120eb2db33853bd2557a3909d55567a91d
--- /dev/null
+++ b/tools/javacc-4.0/examples/Interpreter/ASTBitwiseXorNode.java
@@ -0,0 +1,48 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+
+
+/* JJT: 0.2.2 */
+
+
+
+public class ASTBitwiseXorNode extends SimpleNode {
+  ASTBitwiseXorNode(int id) {
+    super(id);
+  }
+
+
+  public void interpret()
+  {
+     jjtGetChild(0).interpret();
+     jjtGetChild(1).interpret();
+
+     if (stack[top] instanceof Boolean)
+        stack[--top] = new Boolean(((Boolean)stack[top]).booleanValue() ^
+                                ((Boolean)stack[top + 1]).booleanValue());
+     else if (stack[top] instanceof Integer)
+        stack[--top] = new Integer(((Integer)stack[top]).intValue() ^
+                                ((Integer)stack[top + 1]).intValue());
+  }
+}
diff --git a/tools/javacc-4.0/examples/Interpreter/ASTBlock.java b/tools/javacc-4.0/examples/Interpreter/ASTBlock.java
new file mode 100644
index 0000000000000000000000000000000000000000..454c497a4abd3b6a7077999f66652d165f75be28
--- /dev/null
+++ b/tools/javacc-4.0/examples/Interpreter/ASTBlock.java
@@ -0,0 +1,45 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+
+/* JJT: 0.2.2 */
+
+
+
+
+public class ASTBlock extends SimpleNode {
+  ASTBlock(int id) {
+    super(id);
+  }
+
+
+  public void interpret()
+  {
+     int i, k = jjtGetNumChildren();
+
+     for (i = 0; i < k; i++)
+        jjtGetChild(i).interpret();
+ 
+  }
+
+}
diff --git a/tools/javacc-4.0/examples/Interpreter/ASTCompilationUnit.java b/tools/javacc-4.0/examples/Interpreter/ASTCompilationUnit.java
new file mode 100644
index 0000000000000000000000000000000000000000..13e804f9186b4936658f4034a267e6c37d22dc6b
--- /dev/null
+++ b/tools/javacc-4.0/examples/Interpreter/ASTCompilationUnit.java
@@ -0,0 +1,45 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+
+/* JJT: 0.2.2 */
+
+
+
+
+public class ASTCompilationUnit extends SimpleNode {
+  ASTCompilationUnit(int id) {
+    super(id);
+  }
+
+
+  public void interpret()
+  {
+     int i, k = jjtGetNumChildren();
+
+     for (i = 0; i < k; i++)
+        jjtGetChild(i).interpret();
+ 
+  }
+
+}
diff --git a/tools/javacc-4.0/examples/Interpreter/ASTDivNode.java b/tools/javacc-4.0/examples/Interpreter/ASTDivNode.java
new file mode 100644
index 0000000000000000000000000000000000000000..fddc0e60d7674570c66c8581b808d6f821b515d7
--- /dev/null
+++ b/tools/javacc-4.0/examples/Interpreter/ASTDivNode.java
@@ -0,0 +1,45 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+
+/* JJT: 0.2.2 */
+
+
+
+
+public class ASTDivNode extends SimpleNode {
+  ASTDivNode(int id) {
+    super(id);
+  }
+
+
+  public void interpret()
+  {
+     jjtGetChild(0).interpret();
+     jjtGetChild(1).interpret();
+
+     stack[--top] = new Integer(((Integer)stack[top]).intValue() /
+                                ((Integer)stack[top + 1]).intValue());
+  }
+
+}
diff --git a/tools/javacc-4.0/examples/Interpreter/ASTEQNode.java b/tools/javacc-4.0/examples/Interpreter/ASTEQNode.java
new file mode 100644
index 0000000000000000000000000000000000000000..225310b7f8c54200196e24e0d6e9c68a2bc2fa40
--- /dev/null
+++ b/tools/javacc-4.0/examples/Interpreter/ASTEQNode.java
@@ -0,0 +1,49 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+
+/* JJT: 0.2.2 */
+
+
+
+
+public class ASTEQNode extends SimpleNode {
+  ASTEQNode(int id) {
+    super(id);
+  }
+
+
+  public void interpret()
+  {
+     jjtGetChild(0).interpret();
+     jjtGetChild(1).interpret();
+
+     if (stack[top] instanceof Boolean)
+        stack[--top] = new Boolean(((Boolean)stack[top]).booleanValue() ==
+                                ((Boolean)stack[top + 1]).booleanValue());
+     else
+        stack[--top] = new Boolean(((Integer)stack[top]).intValue() ==
+                                ((Integer)stack[top + 1]).intValue());
+  }
+
+}
diff --git a/tools/javacc-4.0/examples/Interpreter/ASTFalseNode.java b/tools/javacc-4.0/examples/Interpreter/ASTFalseNode.java
new file mode 100644
index 0000000000000000000000000000000000000000..8d33fe240347305b32851f3a082921e8e021f5f9
--- /dev/null
+++ b/tools/javacc-4.0/examples/Interpreter/ASTFalseNode.java
@@ -0,0 +1,41 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+
+/* JJT: 0.2.2 */
+
+
+
+
+public class ASTFalseNode extends SimpleNode {
+  ASTFalseNode(int id) {
+    super(id);
+  }
+
+
+  public void interpret()
+  {
+     stack[++top] = new Boolean(false);
+  }
+
+}
diff --git a/tools/javacc-4.0/examples/Interpreter/ASTGENode.java b/tools/javacc-4.0/examples/Interpreter/ASTGENode.java
new file mode 100644
index 0000000000000000000000000000000000000000..faf4388606582681f1066225cd044c8da28e2cf6
--- /dev/null
+++ b/tools/javacc-4.0/examples/Interpreter/ASTGENode.java
@@ -0,0 +1,45 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+
+/* JJT: 0.2.2 */
+
+
+
+
+public class ASTGENode extends SimpleNode {
+  ASTGENode(int id) {
+    super(id);
+  }
+
+
+  public void interpret()
+  {
+     jjtGetChild(0).interpret();
+     jjtGetChild(1).interpret();
+
+     stack[--top] = new Boolean(((Integer)stack[top]).intValue() >=
+                                ((Integer)stack[top + 1]).intValue());
+  }
+
+}
diff --git a/tools/javacc-4.0/examples/Interpreter/ASTGTNode.java b/tools/javacc-4.0/examples/Interpreter/ASTGTNode.java
new file mode 100644
index 0000000000000000000000000000000000000000..4348cf568c4d3b2bfca3d022653ebb82e7f65936
--- /dev/null
+++ b/tools/javacc-4.0/examples/Interpreter/ASTGTNode.java
@@ -0,0 +1,45 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+
+/* JJT: 0.2.2 */
+
+
+
+
+public class ASTGTNode extends SimpleNode {
+  ASTGTNode(int id) {
+    super(id);
+  }
+
+
+  public void interpret()
+  {
+     jjtGetChild(0).interpret();
+     jjtGetChild(1).interpret();
+
+     stack[--top] = new Boolean(((Integer)stack[top]).intValue() >
+                                ((Integer)stack[top + 1]).intValue());
+  }
+
+}
diff --git a/tools/javacc-4.0/examples/Interpreter/ASTId.java b/tools/javacc-4.0/examples/Interpreter/ASTId.java
new file mode 100644
index 0000000000000000000000000000000000000000..67cf22e507b1f52d8b4055737823e194c411f423
--- /dev/null
+++ b/tools/javacc-4.0/examples/Interpreter/ASTId.java
@@ -0,0 +1,44 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+
+/* JJT: 0.2.2 */
+
+
+
+
+public class ASTId extends SimpleNode {
+
+  String name;
+
+  ASTId(int id) {
+    super(id);
+  }
+
+
+  public void interpret()
+  {
+     stack[++top] = symtab.get(name);
+  }
+
+}
diff --git a/tools/javacc-4.0/examples/Interpreter/ASTIfStatement.java b/tools/javacc-4.0/examples/Interpreter/ASTIfStatement.java
new file mode 100644
index 0000000000000000000000000000000000000000..f03134d4250eb630f36945ebf00184d2161133b7
--- /dev/null
+++ b/tools/javacc-4.0/examples/Interpreter/ASTIfStatement.java
@@ -0,0 +1,47 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+
+/* JJT: 0.2.2 */
+
+
+
+
+public class ASTIfStatement extends SimpleNode {
+
+  ASTIfStatement(int id) {
+    super(id);
+  }
+
+
+  public void interpret()
+  {
+     jjtGetChild(0).interpret();
+
+     if (((Boolean)stack[top--]).booleanValue())
+        jjtGetChild(1).interpret();
+     else if (jjtGetNumChildren() == 3)
+        jjtGetChild(2).interpret();
+  }
+
+}
diff --git a/tools/javacc-4.0/examples/Interpreter/ASTIntConstNode.java b/tools/javacc-4.0/examples/Interpreter/ASTIntConstNode.java
new file mode 100644
index 0000000000000000000000000000000000000000..edd14d3d1faacbacd3520043cca52bb4af006587
--- /dev/null
+++ b/tools/javacc-4.0/examples/Interpreter/ASTIntConstNode.java
@@ -0,0 +1,44 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+
+/* JJT: 0.2.2 */
+
+
+
+
+public class ASTIntConstNode extends SimpleNode {
+
+  int val;
+
+  ASTIntConstNode(int id) {
+    super(id);
+  }
+
+
+  public void interpret()
+  {
+     stack[++top] = new Integer(val);
+  }
+
+}
diff --git a/tools/javacc-4.0/examples/Interpreter/ASTLENode.java b/tools/javacc-4.0/examples/Interpreter/ASTLENode.java
new file mode 100644
index 0000000000000000000000000000000000000000..6e8b616c6923bfff2cff3610dd36d2df1df2e5bd
--- /dev/null
+++ b/tools/javacc-4.0/examples/Interpreter/ASTLENode.java
@@ -0,0 +1,45 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+
+/* JJT: 0.2.2 */
+
+
+
+
+public class ASTLENode extends SimpleNode {
+  ASTLENode(int id) {
+    super(id);
+  }
+
+
+  public void interpret()
+  {
+     jjtGetChild(0).interpret();
+     jjtGetChild(1).interpret();
+
+     stack[--top] = new Boolean(((Integer)stack[top]).intValue() <=
+                                ((Integer)stack[top + 1]).intValue());
+  }
+
+}
diff --git a/tools/javacc-4.0/examples/Interpreter/ASTLTNode.java b/tools/javacc-4.0/examples/Interpreter/ASTLTNode.java
new file mode 100644
index 0000000000000000000000000000000000000000..ada9a6922b6c8665d43cbea4bc0293d84a639b75
--- /dev/null
+++ b/tools/javacc-4.0/examples/Interpreter/ASTLTNode.java
@@ -0,0 +1,45 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+
+/* JJT: 0.2.2 */
+
+
+
+
+public class ASTLTNode extends SimpleNode {
+  ASTLTNode(int id) {
+    super(id);
+  }
+
+
+  public void interpret()
+  {
+     jjtGetChild(0).interpret();
+     jjtGetChild(1).interpret();
+
+     stack[--top] = new Boolean(((Integer)stack[top]).intValue() <
+                                ((Integer)stack[top + 1]).intValue());
+  }
+
+}
diff --git a/tools/javacc-4.0/examples/Interpreter/ASTModNode.java b/tools/javacc-4.0/examples/Interpreter/ASTModNode.java
new file mode 100644
index 0000000000000000000000000000000000000000..4bf9e6bed68e6f099f7012db842e1b519cce645c
--- /dev/null
+++ b/tools/javacc-4.0/examples/Interpreter/ASTModNode.java
@@ -0,0 +1,45 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+
+/* JJT: 0.2.2 */
+
+
+
+
+public class ASTModNode extends SimpleNode {
+  ASTModNode(int id) {
+    super(id);
+  }
+
+
+  public void interpret()
+  {
+     jjtGetChild(0).interpret();
+     jjtGetChild(1).interpret();
+
+     stack[--top] = new Integer(((Integer)stack[top]).intValue() %
+                                ((Integer)stack[top + 1]).intValue());
+  }
+
+}
diff --git a/tools/javacc-4.0/examples/Interpreter/ASTMulNode.java b/tools/javacc-4.0/examples/Interpreter/ASTMulNode.java
new file mode 100644
index 0000000000000000000000000000000000000000..4ce074dd1fe0077c219d40c796e6af3fc79f0ddd
--- /dev/null
+++ b/tools/javacc-4.0/examples/Interpreter/ASTMulNode.java
@@ -0,0 +1,45 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+
+/* JJT: 0.2.2 */
+
+
+
+
+public class ASTMulNode extends SimpleNode {
+  ASTMulNode(int id) {
+    super(id);
+  }
+
+
+  public void interpret()
+  {
+     jjtGetChild(0).interpret();
+     jjtGetChild(1).interpret();
+
+     stack[--top] = new Integer(((Integer)stack[top]).intValue() *
+                                ((Integer)stack[top + 1]).intValue());
+  }
+
+}
diff --git a/tools/javacc-4.0/examples/Interpreter/ASTNENode.java b/tools/javacc-4.0/examples/Interpreter/ASTNENode.java
new file mode 100644
index 0000000000000000000000000000000000000000..ca2c659a6d967587c4c1fcf735ceed08163589bc
--- /dev/null
+++ b/tools/javacc-4.0/examples/Interpreter/ASTNENode.java
@@ -0,0 +1,49 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+
+/* JJT: 0.2.2 */
+
+
+
+
+public class ASTNENode extends SimpleNode {
+  ASTNENode(int id) {
+    super(id);
+  }
+
+
+  public void interpret()
+  {
+     jjtGetChild(0).interpret();
+     jjtGetChild(1).interpret();
+
+     if (stack[top] instanceof Boolean)
+        stack[--top] = new Boolean(((Boolean)stack[top]).booleanValue() !=
+                                ((Boolean)stack[top + 1]).booleanValue());
+     else
+        stack[--top] = new Boolean(((Integer)stack[top]).intValue() !=
+                                ((Integer)stack[top + 1]).intValue());
+  }
+
+}
diff --git a/tools/javacc-4.0/examples/Interpreter/ASTNotNode.java b/tools/javacc-4.0/examples/Interpreter/ASTNotNode.java
new file mode 100644
index 0000000000000000000000000000000000000000..f9630c2396b7673d0b105fb560672c270e705cac
--- /dev/null
+++ b/tools/javacc-4.0/examples/Interpreter/ASTNotNode.java
@@ -0,0 +1,41 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+
+/* JJT: 0.2.2 */
+
+
+
+
+public class ASTNotNode extends SimpleNode {
+  ASTNotNode(int id) {
+    super(id);
+  }
+
+
+  public void interpret()
+  {
+     jjtGetChild(0).interpret();
+     stack[top] = new Boolean(!((Boolean)stack[top]).booleanValue());
+  }
+}
diff --git a/tools/javacc-4.0/examples/Interpreter/ASTOrNode.java b/tools/javacc-4.0/examples/Interpreter/ASTOrNode.java
new file mode 100644
index 0000000000000000000000000000000000000000..12d93d7a56e62f7f0bf5ea9a81033c30fdc6f471
--- /dev/null
+++ b/tools/javacc-4.0/examples/Interpreter/ASTOrNode.java
@@ -0,0 +1,51 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+
+/* JJT: 0.2.2 */
+
+
+
+
+public class ASTOrNode extends SimpleNode {
+  ASTOrNode(int id) {
+    super(id);
+  }
+
+
+  public void interpret()
+  {
+     jjtGetChild(0).interpret();
+
+     if (((Boolean)stack[top]).booleanValue())
+     {
+        stack[top] = new Boolean(true);
+        return;
+     }
+
+     jjtGetChild(1).interpret();
+     stack[--top] = new Boolean(((Boolean)stack[top]).booleanValue() ||
+                                ((Boolean)stack[top + 1]).booleanValue());
+  }
+
+}
diff --git a/tools/javacc-4.0/examples/Interpreter/ASTReadStatement.java b/tools/javacc-4.0/examples/Interpreter/ASTReadStatement.java
new file mode 100644
index 0000000000000000000000000000000000000000..df16db1550f664c3d32e494909d24b2fd88c50d4
--- /dev/null
+++ b/tools/javacc-4.0/examples/Interpreter/ASTReadStatement.java
@@ -0,0 +1,71 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+
+/* JJT: 0.2.2 */
+
+
+
+
+public class ASTReadStatement extends SimpleNode {
+  String name;
+
+  ASTReadStatement(int id) {
+    super(id);
+  }
+
+
+  public void interpret()
+  {
+     Object o;
+     byte[] b = new byte[64];
+     int i;
+
+     if ((o = symtab.get(name)) == null)
+        System.err.println("Undefined variable : " + name);
+
+     if (o instanceof Boolean)
+     {
+        System.out.print("Enter a value for \'" + name + "\' (boolean) : ");
+        System.out.flush();
+        try
+        {
+           i = System.in.read(b);
+           symtab.put(name, new Boolean((new String(b, 0, 0, i - 1)).trim()));
+        } catch(Exception e) { System.exit(1); }
+     }
+     else if (o instanceof Integer)
+     {
+        System.out.print("Enter a value for \'" + name + "\' (int) : ");
+        System.out.flush();
+        try
+        {
+           i = System.in.read(b);
+           symtab.put(name, new Integer((new String(b, 0, 0, i - 1)).trim()));
+        } catch(Exception e) {
+           System.out.println("Exceptio : " + e.getClass().getName());
+           System.exit(1);
+        }
+     }
+  }
+}
diff --git a/tools/javacc-4.0/examples/Interpreter/ASTStatementExpression.java b/tools/javacc-4.0/examples/Interpreter/ASTStatementExpression.java
new file mode 100644
index 0000000000000000000000000000000000000000..249a4d3da41e43f7ffd710f965a958935a4ce32f
--- /dev/null
+++ b/tools/javacc-4.0/examples/Interpreter/ASTStatementExpression.java
@@ -0,0 +1,42 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+
+/* JJT: 0.2.2 */
+
+
+
+
+public class ASTStatementExpression extends SimpleNode {
+  ASTStatementExpression(int id) {
+    super(id);
+  }
+
+
+  public void interpret()
+  {
+     jjtGetChild(0).interpret();
+     top--; //just throw away the value.
+  }
+
+}
diff --git a/tools/javacc-4.0/examples/Interpreter/ASTSubtractNode.java b/tools/javacc-4.0/examples/Interpreter/ASTSubtractNode.java
new file mode 100644
index 0000000000000000000000000000000000000000..54290b68fd97b0021aed9924d348b0a626b68b39
--- /dev/null
+++ b/tools/javacc-4.0/examples/Interpreter/ASTSubtractNode.java
@@ -0,0 +1,45 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+
+/* JJT: 0.2.2 */
+
+
+
+
+public class ASTSubtractNode extends SimpleNode {
+  ASTSubtractNode(int id) {
+    super(id);
+  }
+
+
+  public void interpret()
+  {
+     jjtGetChild(0).interpret();
+     jjtGetChild(1).interpret();
+
+     stack[--top] = new Integer(((Integer)stack[top]).intValue() -
+                                ((Integer)stack[top + 1]).intValue());
+  }
+
+}
diff --git a/tools/javacc-4.0/examples/Interpreter/ASTTrueNode.java b/tools/javacc-4.0/examples/Interpreter/ASTTrueNode.java
new file mode 100644
index 0000000000000000000000000000000000000000..347ebbffd0bcf73d6e3e514e30dd64f0c4a88ff5
--- /dev/null
+++ b/tools/javacc-4.0/examples/Interpreter/ASTTrueNode.java
@@ -0,0 +1,41 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+
+/* JJT: 0.2.2 */
+
+
+
+
+public class ASTTrueNode extends SimpleNode {
+  ASTTrueNode(int id) {
+    super(id);
+  }
+
+
+  public void interpret()
+  {
+     stack[++top] = new Boolean(true);
+  }
+
+}
diff --git a/tools/javacc-4.0/examples/Interpreter/ASTVarDeclaration.java b/tools/javacc-4.0/examples/Interpreter/ASTVarDeclaration.java
new file mode 100644
index 0000000000000000000000000000000000000000..306ee522c540a5b353be5fdd615783fed20897b6
--- /dev/null
+++ b/tools/javacc-4.0/examples/Interpreter/ASTVarDeclaration.java
@@ -0,0 +1,48 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+
+/* JJT: 0.2.2 */
+
+
+
+
+public class ASTVarDeclaration extends SimpleNode
+                               implements SPLParserConstants {
+
+  int type;
+  String name;
+
+  ASTVarDeclaration(int id) {
+    super(id);
+  }
+
+
+  public void interpret()
+  {
+     if (type == BOOL)
+        symtab.put(name, new Boolean(false));
+     else
+        symtab.put(name, new Integer(0));
+  }
+}
diff --git a/tools/javacc-4.0/examples/Interpreter/ASTWhileStatement.java b/tools/javacc-4.0/examples/Interpreter/ASTWhileStatement.java
new file mode 100644
index 0000000000000000000000000000000000000000..edbd8f644b5e3e2a2c3c7fa6819d5250fc8f3bc7
--- /dev/null
+++ b/tools/javacc-4.0/examples/Interpreter/ASTWhileStatement.java
@@ -0,0 +1,48 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+
+/* JJT: 0.2.2 */
+
+
+
+
+public class ASTWhileStatement extends SimpleNode {
+  ASTWhileStatement(int id) {
+    super(id);
+  }
+
+
+  public void interpret()
+  {
+     do {
+       jjtGetChild(0).interpret();
+
+       if (((Boolean)stack[top--]).booleanValue())
+          jjtGetChild(1).interpret();
+       else
+          break;
+    } while (true);
+  }
+
+}
diff --git a/tools/javacc-4.0/examples/Interpreter/ASTWriteStatement.java b/tools/javacc-4.0/examples/Interpreter/ASTWriteStatement.java
new file mode 100644
index 0000000000000000000000000000000000000000..d10ae25330255064a8a8b3e57c61cce298563a33
--- /dev/null
+++ b/tools/javacc-4.0/examples/Interpreter/ASTWriteStatement.java
@@ -0,0 +1,49 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+
+/* JJT: 0.2.2 */
+
+
+
+
+public class ASTWriteStatement extends SimpleNode {
+  String name;
+
+  ASTWriteStatement(int id) {
+    super(id);
+  }
+
+
+  public void interpret()
+  {
+     Object o;
+     byte[] b = new byte[64];
+
+     if ((o = symtab.get(name)) == null)
+        System.err.println("Undefined variable : " + name);
+
+     System.out.println("Value of " + name + " : " + symtab.get(name));
+  }
+
+}
diff --git a/tools/javacc-4.0/examples/Interpreter/MyNode.java b/tools/javacc-4.0/examples/Interpreter/MyNode.java
new file mode 100644
index 0000000000000000000000000000000000000000..286051b08339b2babf760633dfed42336c8e900c
--- /dev/null
+++ b/tools/javacc-4.0/examples/Interpreter/MyNode.java
@@ -0,0 +1,14 @@
+public class MyNode
+{
+  /** Symbol table */
+  protected static java.util.Hashtable symtab = new java.util.Hashtable();
+
+  /** Stack for calculations. */
+  protected static Object[] stack = new Object[1024];
+  protected static int top = -1;
+
+  public void interpret()
+  {
+     throw new UnsupportedOperationException(); // It better not come here.
+  }
+}
diff --git a/tools/javacc-4.0/examples/Interpreter/Node.java b/tools/javacc-4.0/examples/Interpreter/Node.java
new file mode 100644
index 0000000000000000000000000000000000000000..18ccb9a9d2ab04d067abf1e9e68a5b60744b2302
--- /dev/null
+++ b/tools/javacc-4.0/examples/Interpreter/Node.java
@@ -0,0 +1,59 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+
+/* All AST nodes must implement this interface.  It provides basic
+   machinery for constructing the parent and child relationships
+   between nodes. */
+
+public interface Node {
+
+  /** This method is called after the node has been made the current
+    node.  It indicates that child nodes can now be added to it. */
+  public void jjtOpen();
+
+  /** This method is called after all the child nodes have been
+    added. */
+  public void jjtClose();
+
+  /** This pair of methods are used to inform the node of its
+    parent. */
+  public void jjtSetParent(Node n);
+  public Node jjtGetParent();
+
+  /** This method tells the node to add its argument to the node's
+    list of children.  */
+  public void jjtAddChild(Node n, int i);
+
+  /** This method returns a child node.  The children are numbered
+     from zero, left to right. */
+  public Node jjtGetChild(int i);
+
+  /** Return the number of children the node has. */
+  int jjtGetNumChildren();
+
+  /************************* Added by Sreeni. *******************/
+
+  /** Interpret method */
+  public void interpret();
+}
diff --git a/tools/javacc-4.0/examples/Interpreter/README b/tools/javacc-4.0/examples/Interpreter/README
new file mode 100644
index 0000000000000000000000000000000000000000..7840b72f8ef2ad85e191fc6fc099924734049554
--- /dev/null
+++ b/tools/javacc-4.0/examples/Interpreter/README
@@ -0,0 +1,40 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+This is an interpreter for SPL (Stupid Programming Language). It builds
+jjtree's for a given SPL program and interprets it. It shows how you can
+implement simple loop and conditional constructs.
+
+Note how easy it is to annotate a grammar file to build useful tree nodes
+and then extend these nodes for purposes of interpreting, etc.
+
+This example will be improved as JJTree evolves.
+
+To run it :
+
+     jjtree SPL.jjt
+     javacc SPL.jj
+     javac *.java
+     java SPL fact.spl
+     java SPL sqrt.spl
+     java SPL odd.spl
diff --git a/tools/javacc-4.0/examples/Interpreter/SPL.java b/tools/javacc-4.0/examples/Interpreter/SPL.java
new file mode 100644
index 0000000000000000000000000000000000000000..c1e7deb519ede89a5633fcd50eac23851682325c
--- /dev/null
+++ b/tools/javacc-4.0/examples/Interpreter/SPL.java
@@ -0,0 +1,54 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+
+
+class SPL {
+
+  public static void main(String args[]) {
+    SPLParser parser;
+    if (args.length == 1) {
+      System.out.println("Stupid Programming Language Interpreter Version 0.1:  Reading from file " + args[0] + " . . .");
+      try {
+        parser = new SPLParser(new java.io.FileInputStream(args[0]));
+      } catch (java.io.FileNotFoundException e) {
+        System.out.println("Stupid Programming Language Interpreter Version 0.1:  File " + args[0] + " not found.");
+        return;
+      }
+    } else {
+      System.out.println("Stupid Programming Language Interpreter Version 0.1:  Usage :");
+      System.out.println("         java SPL inputfile");
+      return;
+    }
+    try {
+      parser.CompilationUnit();
+      parser.jjtree.rootNode().interpret();
+    } catch (ParseException e) {
+      System.out.println("Stupid Programming Language Interpreter Version 0.1:  Encountered errors during parse.");
+      e.printStackTrace();
+    } catch (Exception e1) {
+      System.out.println("Stupid Programming Language Interpreter Version 0.1:  Encountered errors during interpretation/tree building.");
+      e1.printStackTrace();
+    }
+  }
+}
diff --git a/tools/javacc-4.0/examples/Interpreter/SPL.jjt b/tools/javacc-4.0/examples/Interpreter/SPL.jjt
new file mode 100644
index 0000000000000000000000000000000000000000..e76eaf4ba82b350ac9e8dbd7817e8cbd9946056c
--- /dev/null
+++ b/tools/javacc-4.0/examples/Interpreter/SPL.jjt
@@ -0,0 +1,336 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+
+options {
+   MULTI=true;
+	NODE_EXTENDS="MyNode";
+}
+
+PARSER_BEGIN(SPLParser)
+
+public class SPLParser {
+}
+
+PARSER_END(SPLParser)
+
+
+SKIP : /* WHITE SPACE */
+{
+  " "
+| "\t"
+| "\n"
+| "\r"
+| "\f"
+}
+
+TOKEN : /* Types */
+{
+   < INT: "int" >
+ |
+   < BOOL: "boolean" >
+}
+
+TOKEN : /* LITERALS */
+{
+  < INTEGER_LITERAL: (<DIGIT>)+ >
+}
+
+/*
+ * Program structuring syntax follows.
+ */
+
+void CompilationUnit() :
+{
+   String name;
+}
+{
+   (
+       VarDeclaration() ";"
+     |
+       Statement()
+   )*
+   <EOF>
+}
+
+void VarDeclaration() :
+{ Token t; }
+{
+  (
+    "boolean" { jjtThis.type = BOOL; }
+   |
+    "int" { jjtThis.type = INT; }
+  )
+  t = <IDENTIFIER> 
+  { jjtThis.name = t.image; }
+}
+
+/*
+ * Expression syntax follows.
+ */
+
+void Expression() #void:
+{}
+{
+  LOOKAHEAD( PrimaryExpression() "=" )
+  Assignment()
+|
+  ConditionalOrExpression()
+}
+
+void Assignment() #Assignment(2) :
+{}
+{
+  PrimaryExpression() "=" Expression()
+}
+
+void ConditionalOrExpression() #void :
+{}
+{
+  ConditionalAndExpression()
+  ( "||" ConditionalAndExpression() #OrNode(2) )*
+}
+
+void ConditionalAndExpression() #void :
+{}
+{
+  InclusiveOrExpression()
+  ( "&&" InclusiveOrExpression() #AndNode(2) )*
+}
+
+void InclusiveOrExpression() #void :
+{}
+{
+  ExclusiveOrExpression()
+  ( "|" ExclusiveOrExpression() #BitwiseOrNode(2) )*
+}
+
+void ExclusiveOrExpression() #void :
+{}
+{
+  AndExpression()
+  ( "^" AndExpression() #BitwiseXorNode(2) )*
+}
+
+void AndExpression() #void :
+{}
+{
+  EqualityExpression()
+  ( "&" EqualityExpression() #BitwiseAndNode(2) )*
+}
+
+void EqualityExpression() #void :
+{}
+{
+  RelationalExpression()
+  (
+     "==" RelationalExpression() #EQNode(2)
+   |
+     "!=" RelationalExpression() #NENode(2)
+  )*
+}
+
+void RelationalExpression() #void :
+{}
+{
+  AdditiveExpression()
+  (
+    "<" AdditiveExpression() #LTNode(2)
+   |
+    ">" AdditiveExpression() #GTNode(2)
+   |
+    "<=" AdditiveExpression() #LENode(2)
+   |
+    ">=" AdditiveExpression() #GENode(2)
+  )*
+}
+
+void AdditiveExpression() #void :
+{}
+{
+  MultiplicativeExpression()
+  (
+    "+" MultiplicativeExpression() #AddNode(2)
+   |
+    "-" MultiplicativeExpression() #SubtractNode(2)
+  )*
+}
+
+void MultiplicativeExpression() #void :
+{}
+{
+  UnaryExpression()
+  (
+    "*" UnaryExpression() #MulNode(2)
+   |
+    "/" UnaryExpression() #DivNode(2)
+   |
+    "%" UnaryExpression() #ModNode(2)
+  )*
+}
+
+void UnaryExpression() #void :
+{}
+{
+  "~" UnaryExpression() #BitwiseComplNode(1)
+|
+  "!" UnaryExpression() #NotNode(1)
+|
+  PrimaryExpression()
+}
+
+void PrimaryExpression() #void :
+{
+   String name;
+}
+{
+  Literal()
+|
+  Id() 
+|
+  "(" Expression() ")"
+}
+
+void Id() :
+{
+   Token t;
+}
+{
+   t = <IDENTIFIER>  { jjtThis.name = t.image; }
+}
+
+void Literal() #void :
+{
+   Token t;
+}
+{
+ (
+  t=<INTEGER_LITERAL>
+    {
+       jjtThis.val = Integer.parseInt(t.image);
+    }
+ )#IntConstNode
+|
+  BooleanLiteral()
+}
+
+void BooleanLiteral() #void :
+{}
+{
+  "true" #TrueNode
+|
+  "false" #FalseNode
+}
+
+/*
+ * Statement syntax follows.
+ */
+
+void Statement() #void :
+{}
+{
+  ";"
+|
+  LOOKAHEAD(2)
+  LabeledStatement()
+|
+  Block()
+|
+  StatementExpression()
+|
+  IfStatement()
+|
+  WhileStatement()
+|
+  IOStatement()
+}
+
+void LabeledStatement() #void :
+{}
+{
+  <IDENTIFIER> ":" Statement()
+}
+
+void Block() :
+{}
+{
+  "{" ( Statement() )* "}"
+}
+
+void StatementExpression() :
+/*
+ * The last expansion of this production accepts more than the legal
+ * SPL expansions for StatementExpression.
+ */
+{}
+{
+  Assignment() ";"
+}
+
+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" "(" Expression() ")" Statement() [ LOOKAHEAD(1) "else" Statement() ]
+}
+
+void WhileStatement() :
+{}
+{
+  "while" "(" Expression() ")" Statement()
+}
+
+void IOStatement() #void :
+{ String name; }
+{
+   ReadStatement()
+ |
+   WriteStatement()
+}
+
+void ReadStatement() :
+{ Token t; }
+{
+   "read" t = <IDENTIFIER>
+   { jjtThis.name = t.image; }
+}
+
+void WriteStatement() :
+{ Token t; }
+{
+   "write" t = <IDENTIFIER>
+   { jjtThis.name = t.image; }
+}
+
+TOKEN : /* IDENTIFIERS */
+{
+  < IDENTIFIER: <LETTER> (<LETTER>|<DIGIT>)* >
+|
+  < #LETTER: [ "a"-"z", "A"-"Z" ] >
+|
+  < #DIGIT: [ "0"-"9"] >
+}
diff --git a/tools/javacc-4.0/examples/Interpreter/fact.spl b/tools/javacc-4.0/examples/Interpreter/fact.spl
new file mode 100644
index 0000000000000000000000000000000000000000..38417a88d98a855ce1315e996971dbad84bc2977
--- /dev/null
+++ b/tools/javacc-4.0/examples/Interpreter/fact.spl
@@ -0,0 +1,14 @@
+int n;
+int fact;
+
+read n;
+
+fact = 1;
+
+while (n > 1)
+{
+   fact = fact * n;
+   n = n - 1;
+}
+
+write fact;
diff --git a/tools/javacc-4.0/examples/Interpreter/odd.spl b/tools/javacc-4.0/examples/Interpreter/odd.spl
new file mode 100644
index 0000000000000000000000000000000000000000..5f81dd7c78a0ce4fb36ab8bd8ab77f53eba979ba
--- /dev/null
+++ b/tools/javacc-4.0/examples/Interpreter/odd.spl
@@ -0,0 +1,13 @@
+int num;
+boolean odd;
+
+num = 10;
+
+read num;
+
+if (num % 2 != 0)
+   odd = true;
+else
+   odd = false;
+
+write odd;
diff --git a/tools/javacc-4.0/examples/Interpreter/sqrt.spl b/tools/javacc-4.0/examples/Interpreter/sqrt.spl
new file mode 100644
index 0000000000000000000000000000000000000000..c82568a000357cab6db3266b90effc06d8be79a9
--- /dev/null
+++ b/tools/javacc-4.0/examples/Interpreter/sqrt.spl
@@ -0,0 +1,12 @@
+
+int val;
+
+read val;
+int sqrt;
+
+sqrt = 1;
+
+while (sqrt * sqrt <= val && ((sqrt + 1) * (sqrt + 1)) <= val)
+  sqrt = sqrt + 1;
+
+write sqrt
diff --git a/tools/javacc-4.0/examples/JJTreeExamples/ASTMyID.java b/tools/javacc-4.0/examples/JJTreeExamples/ASTMyID.java
new file mode 100644
index 0000000000000000000000000000000000000000..7a74c089e6b010841c02de54094dd1d2820da34b
--- /dev/null
+++ b/tools/javacc-4.0/examples/JJTreeExamples/ASTMyID.java
@@ -0,0 +1,40 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+
+public class ASTMyID extends SimpleNode {
+  private String name;
+
+  ASTMyID(int id){
+    super(id);
+  }
+
+  public void setName(String n) {
+    name = n;
+  }
+
+  public String toString() {
+    return "Identifier: " + name;
+  }
+
+}
diff --git a/tools/javacc-4.0/examples/JJTreeExamples/ASTMyOtherID.java b/tools/javacc-4.0/examples/JJTreeExamples/ASTMyOtherID.java
new file mode 100644
index 0000000000000000000000000000000000000000..f0eec394af341c4c9a8f7ab69eb90b889d7bad86
--- /dev/null
+++ b/tools/javacc-4.0/examples/JJTreeExamples/ASTMyOtherID.java
@@ -0,0 +1,45 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+
+public class ASTMyOtherID extends SimpleNode {
+  private String name;
+
+  ASTMyOtherID(int id) {
+    super(id);
+  }
+
+  /** Accept the visitor. **/
+  public Object jjtAccept(eg4Visitor visitor, Object data) {
+    return visitor.visit(this, data);
+  }
+
+  public void setName(String n) {
+    name = n;
+  }
+
+  public String toString() {
+    return "Identifier: " + name;
+  }
+
+}
diff --git a/tools/javacc-4.0/examples/JJTreeExamples/README b/tools/javacc-4.0/examples/JJTreeExamples/README
new file mode 100644
index 0000000000000000000000000000000000000000..dc7f25bd035b8583b083ae4b9f69cd2448ad80a6
--- /dev/null
+++ b/tools/javacc-4.0/examples/JJTreeExamples/README
@@ -0,0 +1,191 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+JJTreeExamples
+
+This directory contains some simple JJTree input files intended to
+illustrate some of the basic ideas.  All of them are based on an
+grammar to recognize arithmetic expressions built out of identifiers
+and constants.
+
+eg1.jjt
+
+This example is just the JavaCC grammar, with a little extra code in
+the parser's main method to call the dump method on the generated
+tree.  It illustrates how the default behavior of JJTree will produce
+a tree of non-terminals.
+
+eg2.jjt
+
+This example is the same grammar as eg1.jjt with modifications to
+customize the generated tree.  It illustrates how unnecessary
+intermediate nodes can be suppressed, and how actions in the grammar
+can attach extra information to the nodes.
+
+eg3.jjt
+
+This example is a modification of eg2.jjt with the NODE_DEFAULT_VOID
+option set.  This instructs JJTree to treat all undecorated
+non-terminals as if they were decorated as #void. The default JJTree
+behavior is to treat such non-terminals as if they were decorated
+with the name of the non-terminal.
+
+eg4.jjt
+
+This is a modification of eg3.jjt with the VISITOR option set.  This
+instructs JJTree to insert a jjtAccept() method into all nodes it
+generates, and to produce a visitor class.  The visitor is used to
+dump the tree.
+
+Here are some instructions on how to run the examples using the Ant build scripts, and the output
+you can expect to see.
+
+eg1.jjt
+-------
+
+The only bit of JJTree-specific code is an action in the start
+production that dumps the constructed parse tree when the parse is
+complete.  It uses JJTree simple mode.
+
+The input file is eg1.jjt.
+
+$ ant eg1
+Buildfile: build.xml
+
+eg1:
+    [mkdir] Created dir: /home/tom/javacc/javacc/examples/JJTreeExamples/eg1
+     [copy] Copying 1 file to /home/tom/javacc/javacc/examples/JJTreeExamples/eg1
+   [jjtree] Java Compiler Compiler Version 3.2 (Tree Builder)
+   [jjtree] (type "jjtree" with no arguments for help)
+   [jjtree] Reading from file /home/tom/javacc/javacc/examples/JJTreeExamples/eg1.jjt . . .
+   [jjtree] File "/home/tom/javacc/javacc/examples/JJTreeExamples/eg1/Node.java" does not exist.  Will create one.
+   [jjtree] File "/home/tom/javacc/javacc/examples/JJTreeExamples/eg1/SimpleNode.java" does not exist.  Will create one.
+   [jjtree] Annotated grammar generated successfully in /home/tom/javacc/javacc/examples/JJTreeExamples/eg1/eg1.jj
+   [javacc] Java Compiler Compiler Version 3.2 (Parser Generator)
+   [javacc] (type "javacc" with no arguments for help)
+   [javacc] Reading from file /home/tom/javacc/javacc/examples/JJTreeExamples/eg1/eg1.jj . . .
+   [javacc] File "TokenMgrError.java" does not exist.  Will create one.
+   [javacc] File "ParseException.java" does not exist.  Will create one.
+   [javacc] File "Token.java" does not exist.  Will create one.
+   [javacc] File "SimpleCharStream.java" does not exist.  Will create one.
+   [javacc] Parser generated successfully.
+    [javac] Compiling 11 source files to /home/tom/javacc/javacc/examples/JJTreeExamples/eg1
+     [echo] *******
+     [echo] ******* Now cd into the eg1 directory and run 'java eg1' ******
+     [echo] *******
+
+BUILD SUCCESSFUL
+Total time: 3 seconds
+[tom@hal JJTreeExamples]$ cd eg1
+[tom@hal eg1]$ java eg1
+Reading from standard input...
+(a + b) * (c + 1);
+Start
+ Expression
+  AdditiveExpression
+   MultiplicativeExpression
+    UnaryExpression
+     Expression
+      AdditiveExpression
+       MultiplicativeExpression
+        UnaryExpression
+         Identifier
+       MultiplicativeExpression
+        UnaryExpression
+         Identifier
+    UnaryExpression
+     Expression
+      AdditiveExpression
+       MultiplicativeExpression
+        UnaryExpression
+         Identifier
+       MultiplicativeExpression
+        UnaryExpression
+         Integer
+Thank you.
+
+eg2.jjt
+-------
+
+This is a modification of the first example to illustrate how the
+parse tree can be customized:
+
+$ ant eg2
+Buildfile: build.xml
+
+eg2:
+    [mkdir] Created dir: /home/tom/javacc/javacc/examples/JJTreeExamples/eg2
+     [copy] Copying 1 file to /home/tom/javacc/javacc/examples/JJTreeExamples/eg2
+     [copy] Copying 1 file to /home/tom/javacc/javacc/examples/JJTreeExamples/eg2
+   [jjtree] Java Compiler Compiler Version 3.2 (Tree Builder)
+   [jjtree] (type "jjtree" with no arguments for help)
+   [jjtree] Reading from file /home/tom/javacc/javacc/examples/JJTreeExamples/eg2.jjt . . .
+   [jjtree] File "/home/tom/javacc/javacc/examples/JJTreeExamples/eg2/Node.java" does not exist.  Will create one.
+   [jjtree] File "/home/tom/javacc/javacc/examples/JJTreeExamples/eg2/SimpleNode.java" does not exist.  Will create one.
+   [jjtree] File "/home/tom/javacc/javacc/examples/JJTreeExamples/eg2/ASTStart.java" does not exist.  Will create one.
+   [jjtree] File "/home/tom/javacc/javacc/examples/JJTreeExamples/eg2/ASTAdd.java" does not exist.  Will create one.
+   [jjtree] File "/home/tom/javacc/javacc/examples/JJTreeExamples/eg2/ASTMult.java" does not exist.  Will create one.
+   [jjtree] File "/home/tom/javacc/javacc/examples/JJTreeExamples/eg2/ASTInteger.java" does not exist.  Will create one.
+   [jjtree] Annotated grammar generated successfully in /home/tom/javacc/javacc/examples/JJTreeExamples/eg2/eg2.jj
+   [javacc] Java Compiler Compiler Version 3.2 (Parser Generator)
+   [javacc] (type "javacc" with no arguments for help)
+   [javacc] Reading from file /home/tom/javacc/javacc/examples/JJTreeExamples/eg2/eg2.jj . . .
+   [javacc] File "TokenMgrError.java" does not exist.  Will create one.
+   [javacc] File "ParseException.java" does not exist.  Will create one.
+   [javacc] File "Token.java" does not exist.  Will create one.
+   [javacc] File "SimpleCharStream.java" does not exist.  Will create one.
+   [javacc] Parser generated successfully.
+    [javac] Compiling 16 source files to /home/tom/javacc/javacc/examples/JJTreeExamples/eg2
+     [echo] *******
+     [echo] ******* Now cd into the eg2 directory and run 'java eg2' ******
+     [echo] *******
+
+BUILD SUCCESSFUL
+Total time: 3 seconds
+[tom@hal JJTreeExamples]$ cd eg2
+[tom@hal eg2]$ java eg2
+Reading from standard input...
+(a + b) * (c + 1);
+Start
+ Mult
+  Add
+   Identifier: a
+   Identifier: b
+  Add
+   Identifier: c
+   Integer
+Thank you.
+
+Look at eg2.jjt to see how node annotations can be used to restructure
+the parse tree, and at ASTMyID.java to see how you can write your own
+node classes that maintain more information from the input stream.
+
+eg3.jjt
+-------
+
+This example can be run in the same manner as you ran eg2.jjt.
+
+eg4.jjt
+-------
+
+This example again can be run in the same manner as you ran eg2.jjt.
diff --git a/tools/javacc-4.0/examples/JJTreeExamples/build.xml b/tools/javacc-4.0/examples/JJTreeExamples/build.xml
new file mode 100644
index 0000000000000000000000000000000000000000..2f3ac28f271ab8e3c584fccba4176a75afc33b11
--- /dev/null
+++ b/tools/javacc-4.0/examples/JJTreeExamples/build.xml
@@ -0,0 +1,66 @@
+<project name="examples" default="eg1" basedir=".">
+
+  <property name="javacc.home" value="/usr/local/javacc/"/>
+
+  <target name="eg1" description="Builds example 'eg1'">
+    <delete dir="eg1"/>
+    <mkdir dir="eg1"/> 
+    <copy file="eg1.jjt" todir="eg1"/>
+    <jjtree target="eg1.jjt" outputdirectory="eg1" javacchome="${javacc.home}"/>
+    <javacc target="eg1/eg1.jj" outputdirectory="eg1" javacchome="${javacc.home}"/>
+    <javac deprecation="false" srcdir="eg1" destdir="eg1"/>
+    <echo message="*******"/>
+    <echo message="******* Now cd into the eg1 directory and run 'java eg1' ******"/>
+    <echo message="*******"/>
+  </target>
+
+  <target name="eg2" description="Builds example 'eg2'">
+    <delete dir="eg2"/>
+    <mkdir dir="eg2"/> 
+    <copy file="eg2.jjt" todir="eg2"/>
+    <copy file="ASTMyID.java" todir="eg2"/>
+    <jjtree target="eg2.jjt" outputdirectory="eg2" javacchome="${javacc.home}"/>
+    <javacc target="eg2/eg2.jj" outputdirectory="eg2" javacchome="${javacc.home}"/>
+    <javac deprecation="false" srcdir="eg2" destdir="eg2"/>
+    <echo message="*******"/>
+    <echo message="******* Now cd into the eg2 directory and run 'java eg2' ******"/>
+    <echo message="*******"/>
+  </target>
+
+  <target name="eg3" description="Builds example 'eg3'">
+    <delete dir="eg3"/>
+    <mkdir dir="eg3"/> 
+    <copy file="eg3.jjt" todir="eg3"/>
+    <copy file="ASTMyID.java" todir="eg3"/>
+    <jjtree target="eg3.jjt" outputdirectory="eg3" javacchome="${javacc.home}"/>
+    <javacc target="eg3/eg3.jj" outputdirectory="eg3" javacchome="${javacc.home}"/>
+    <javac deprecation="false" srcdir="eg3" destdir="eg3"/>
+    <echo message="*******"/>
+    <echo message="******* Now cd into the eg3 directory and run 'java eg3' ******"/>
+    <echo message="*******"/>
+  </target>
+
+  <target name="eg4" description="Builds example 'eg4'">
+    <delete dir="eg4"/>
+    <mkdir dir="eg4"/> 
+    <copy file="eg4.jjt" todir="eg4"/>
+    <copy file="ASTMyID.java" todir="eg4"/>
+    <copy file="ASTMyOtherID.java" todir="eg4"/>
+    <copy file="eg4DumpVisitor.java" todir="eg4"/>
+    <jjtree target="eg4.jjt" outputdirectory="eg4" javacchome="${javacc.home}"/>
+    <javacc target="eg4/eg4.jj" outputdirectory="eg4" javacchome="${javacc.home}"/>
+    <javac deprecation="false" srcdir="eg4" destdir="eg4"/>
+    <echo message="*******"/>
+    <echo message="******* Now cd into the eg4 directory and run 'java eg4' ******"/>
+    <echo message="*******"/>
+  </target>
+
+  <target name="clean" description="Cleans up any example directories">
+    <delete dir="eg1"/>
+    <delete dir="eg2"/>
+    <delete dir="eg3"/>
+    <delete dir="eg4"/>
+  </target>
+    
+
+</project>
diff --git a/tools/javacc-4.0/examples/JJTreeExamples/eg1.jjt b/tools/javacc-4.0/examples/JJTreeExamples/eg1.jjt
new file mode 100644
index 0000000000000000000000000000000000000000..5adbf207d163deefbba78dc03084b4042fa7edc6
--- /dev/null
+++ b/tools/javacc-4.0/examples/JJTreeExamples/eg1.jjt
@@ -0,0 +1,115 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+
+PARSER_BEGIN(eg1)
+
+class eg1 {
+  public static void main(String args[]) {
+    System.out.println("Reading from standard input...");
+    eg1 t = new eg1(System.in);
+    try {
+      SimpleNode n = t.Start();
+      n.dump("");
+      System.out.println("Thank you.");
+    } catch (Exception e) {
+      System.out.println("Oops.");
+      System.out.println(e.getMessage());
+      e.printStackTrace();
+    }
+  }
+}
+
+PARSER_END(eg1)
+
+
+SKIP :
+{
+  " "
+| "\t"
+| "\n"
+| "\r"
+| <"//" (~["\n","\r"])* ("\n"|"\r"|"\r\n")>
+| <"/*" (~["*"])* "*" (~["/"] (~["*"])* "*")* "/">
+}
+
+TOKEN : /* LITERALS */
+{
+  < 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"])* >
+}
+
+TOKEN : /* IDENTIFIERS */
+{
+  < IDENTIFIER: <LETTER> (<LETTER>|<DIGIT>)* >
+|
+  < #LETTER: ["_","a"-"z","A"-"Z"] >
+|
+  < #DIGIT: ["0"-"9"] >
+}
+
+SimpleNode Start() : {}
+{
+  Expression() ";"
+  { return jjtThis; }
+}
+
+
+void Expression() : {}
+{
+  AdditiveExpression()
+}
+
+void AdditiveExpression() : {}
+{
+  MultiplicativeExpression() ( ( "+" | "-" ) MultiplicativeExpression() )*
+}
+
+void MultiplicativeExpression() : {}
+{
+  UnaryExpression() ( ( "*" | "/" | "%" ) UnaryExpression() )*
+}
+
+void UnaryExpression() : {}
+{
+  "(" Expression() ")" | Identifier() | Integer()
+}
+
+void Identifier() : {}
+{
+  <IDENTIFIER>
+}
+
+void Integer() : {}
+{
+  <INTEGER_LITERAL>
+}
diff --git a/tools/javacc-4.0/examples/JJTreeExamples/eg2.jjt b/tools/javacc-4.0/examples/JJTreeExamples/eg2.jjt
new file mode 100644
index 0000000000000000000000000000000000000000..a9f2ceb72912ac3beec504f2b596fe0d162ffeaf
--- /dev/null
+++ b/tools/javacc-4.0/examples/JJTreeExamples/eg2.jjt
@@ -0,0 +1,129 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+
+options {
+  MULTI=true;
+}
+
+PARSER_BEGIN(eg2)
+
+class eg2 {
+  public static void main(String args[]) {
+    System.out.println("Reading from standard input...");
+    eg2 t = new eg2(System.in);
+    try {
+      ASTStart n = t.Start();
+      n.dump("");
+      System.out.println("Thank you.");
+    } catch (Exception e) {
+      System.out.println("Oops.");
+      System.out.println(e.getMessage());
+      e.printStackTrace();
+    }
+  }
+}
+
+PARSER_END(eg2)
+
+
+SKIP :
+{
+  " "
+| "\t"
+| "\n"
+| "\r"
+| <"//" (~["\n","\r"])* ("\n"|"\r"|"\r\n")>
+| <"/*" (~["*"])* "*" (~["/"] (~["*"])* "*")* "/">
+}
+
+TOKEN : /* LITERALS */
+{
+  < 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"])* >
+}
+
+TOKEN : /* IDENTIFIERS */
+{
+  < IDENTIFIER: <LETTER> (<LETTER>|<DIGIT>)* >
+|
+  < #LETTER: ["_","a"-"z","A"-"Z"] >
+|
+  < #DIGIT: ["0"-"9"] >
+}
+
+ASTStart Start() : {}
+{
+  Expression() ";"
+  { return jjtThis; }
+}
+
+
+void Expression() #void : {}
+{
+  AdditiveExpression()
+}
+
+void AdditiveExpression() #void : {}
+{
+  (
+    MultiplicativeExpression() ( ( "+" | "-" ) MultiplicativeExpression() )*
+  ) #Add(>1)
+}
+
+void MultiplicativeExpression() #void : {}
+{
+  (
+    UnaryExpression() ( ( "*" | "/" | "%" ) UnaryExpression() )*
+  ) #Mult(>1)
+}
+
+void UnaryExpression() #void : {}
+{
+  "(" Expression() ")" | MyID() | Integer()
+}
+
+void MyID() :
+{
+  Token t;
+}
+{
+  t=<IDENTIFIER>
+  {
+    jjtThis.setName(t.image);
+  }
+}
+
+void Integer() : {}
+{
+  <INTEGER_LITERAL>
+}
diff --git a/tools/javacc-4.0/examples/JJTreeExamples/eg3.jjt b/tools/javacc-4.0/examples/JJTreeExamples/eg3.jjt
new file mode 100644
index 0000000000000000000000000000000000000000..87da4460dba925a325e6b41996e2750b126d22b0
--- /dev/null
+++ b/tools/javacc-4.0/examples/JJTreeExamples/eg3.jjt
@@ -0,0 +1,130 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+
+options {
+  MULTI=true;
+  NODE_DEFAULT_VOID=true;
+}
+
+PARSER_BEGIN(eg3)
+
+class eg3 {
+  public static void main(String args[]) {
+    System.out.println("Reading from standard input...");
+    eg3 t = new eg3(System.in);
+    try {
+      ASTStart n = t.Start();
+      n.dump("");
+      System.out.println("Thank you.");
+    } catch (Exception e) {
+      System.out.println("Oops.");
+      System.out.println(e.getMessage());
+      e.printStackTrace();
+    }
+  }
+}
+
+PARSER_END(eg3)
+
+
+SKIP :
+{
+  " "
+| "\t"
+| "\n"
+| "\r"
+| <"//" (~["\n","\r"])* ("\n"|"\r"|"\r\n")>
+| <"/*" (~["*"])* "*" (~["/"] (~["*"])* "*")* "/">
+}
+
+TOKEN : /* LITERALS */
+{
+  < 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"])* >
+}
+
+TOKEN : /* IDENTIFIERS */
+{
+  < IDENTIFIER: <LETTER> (<LETTER>|<DIGIT>)* >
+|
+  < #LETTER: ["_","a"-"z","A"-"Z"] >
+|
+  < #DIGIT: ["0"-"9"] >
+}
+
+ASTStart Start() #Start : {}
+{
+  Expression() ";"
+  { return jjtThis; }
+}
+
+
+void Expression() : {}
+{
+  AdditiveExpression()
+}
+
+void AdditiveExpression() : {}
+{
+  (
+    MultiplicativeExpression() ( ( "+" | "-" ) MultiplicativeExpression() )*
+  ) #Add(>1)
+}
+
+void MultiplicativeExpression() : {}
+{
+  (
+    UnaryExpression() ( ( "*" | "/" | "%" ) UnaryExpression() )*
+  ) #Mult(>1)
+}
+
+void UnaryExpression() : {}
+{
+  "(" Expression() ")" | Identifier() | Integer()
+}
+
+void Identifier() #MyID :
+{
+  Token t;
+}
+{
+  t=<IDENTIFIER>
+  {
+    jjtThis.setName(t.image);
+  }
+}
+
+void Integer() #Integer : {}
+{
+  <INTEGER_LITERAL>
+}
diff --git a/tools/javacc-4.0/examples/JJTreeExamples/eg4.jjt b/tools/javacc-4.0/examples/JJTreeExamples/eg4.jjt
new file mode 100644
index 0000000000000000000000000000000000000000..b300b00fe0a9f2a2aff74a5fadbaeddadfde7380
--- /dev/null
+++ b/tools/javacc-4.0/examples/JJTreeExamples/eg4.jjt
@@ -0,0 +1,132 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+
+options {
+  MULTI=true;
+  VISITOR=true;
+  NODE_DEFAULT_VOID=true;
+}
+
+PARSER_BEGIN(eg4)
+
+class eg4 {
+  public static void main(String args[]) {
+    System.out.println("Reading from standard input...");
+    eg4 t = new eg4(System.in);
+    try {
+      ASTStart n = t.Start();
+      eg4Visitor v = new eg4DumpVisitor();
+      n.jjtAccept(v, null);
+      System.out.println("Thank you.");
+    } catch (Exception e) {
+      System.out.println("Oops.");
+      System.out.println(e.getMessage());
+      e.printStackTrace();
+    }
+  }
+}
+
+PARSER_END(eg4)
+
+
+SKIP :
+{
+  " "
+| "\t"
+| "\n"
+| "\r"
+| <"//" (~["\n","\r"])* ("\n"|"\r"|"\r\n")>
+| <"/*" (~["*"])* "*" (~["/"] (~["*"])* "*")* "/">
+}
+
+TOKEN : /* LITERALS */
+{
+  < 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"])* >
+}
+
+TOKEN : /* IDENTIFIERS */
+{
+  < IDENTIFIER: <LETTER> (<LETTER>|<DIGIT>)* >
+|
+  < #LETTER: ["_","a"-"z","A"-"Z"] >
+|
+  < #DIGIT: ["0"-"9"] >
+}
+
+ASTStart Start() #Start : {}
+{
+  Expression() ";"
+  { return jjtThis; }
+}
+
+
+void Expression() : {}
+{
+  AdditiveExpression()
+}
+
+void AdditiveExpression() : {}
+{
+  (
+    MultiplicativeExpression() ( ( "+" | "-" ) MultiplicativeExpression() )*
+  ) #Add(>1)
+}
+
+void MultiplicativeExpression() : {}
+{
+  (
+    UnaryExpression() ( ( "*" | "/" | "%" ) UnaryExpression() )*
+  ) #Mult(>1)
+}
+
+void UnaryExpression() : {}
+{
+  "(" Expression() ")" | Identifier() | Integer()
+}
+
+void Identifier() #MyOtherID :
+{
+  Token t;
+}
+{
+  t=<IDENTIFIER>
+  {
+    jjtThis.setName(t.image);
+  }
+}
+
+void Integer() #Integer : {}
+{
+  <INTEGER_LITERAL>
+}
diff --git a/tools/javacc-4.0/examples/JJTreeExamples/eg4DumpVisitor.java b/tools/javacc-4.0/examples/JJTreeExamples/eg4DumpVisitor.java
new file mode 100644
index 0000000000000000000000000000000000000000..fbb880163b1da560a2a429a8d957b2531013bbee
--- /dev/null
+++ b/tools/javacc-4.0/examples/JJTreeExamples/eg4DumpVisitor.java
@@ -0,0 +1,102 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+
+/* This is an example of how the Visitor pattern might be used to
+   implement the dumping code that comes with SimpleNode.  It's a bit
+   long-winded, but it does illustrate a couple of the main points.
+
+   1) the visitor can maintain state between the nodes that it visits
+   (for example the current indentation level).
+
+   2) if you don't implement a jjtAccept() method for a subclass of
+   SimpleNode, then SimpleNode's acceptor will get called.
+
+   3) the utility method childrenAccept() can be useful when
+   implementing preorder or postorder tree walks.
+
+*/
+
+public class eg4DumpVisitor implements eg4Visitor
+{
+  private int indent = 0;
+
+  private String indentString() {
+    StringBuffer sb = new StringBuffer();
+    for (int i = 0; i < indent; ++i) {
+      sb.append(" ");
+    }
+    return sb.toString();
+  }
+
+  public Object visit(SimpleNode node, Object data) {
+    System.out.println(indentString() + node +
+		       ": acceptor not unimplemented in subclass?");
+    ++indent;
+    data = node.childrenAccept(this, data);
+    --indent;
+    return data;
+  }
+
+  public Object visit(ASTStart node, Object data) {
+    System.out.println(indentString() + node);
+    ++indent;
+    data = node.childrenAccept(this, data);
+    --indent;
+    return data;
+  }
+
+  public Object visit(ASTAdd node, Object data) {
+    System.out.println(indentString() + node);
+    ++indent;
+    data = node.childrenAccept(this, data);
+    --indent;
+    return data;
+  }
+
+  public Object visit(ASTMult node, Object data) {
+    System.out.println(indentString() + node);
+    ++indent;
+    data = node.childrenAccept(this, data);
+    --indent;
+    return data;
+  }
+
+  public Object visit(ASTMyOtherID node, Object data) {
+    System.out.println(indentString() + node);
+    ++indent;
+    data = node.childrenAccept(this, data);
+    --indent;
+    return data;
+  }
+
+  public Object visit(ASTInteger node, Object data) {
+    System.out.println(indentString() + node);
+    ++indent;
+    data = node.childrenAccept(this, data);
+    --indent;
+    return data;
+  }
+}
+
+/*end*/
diff --git a/tools/javacc-4.0/examples/JavaCCGrammar/JavaCC.jj b/tools/javacc-4.0/examples/JavaCCGrammar/JavaCC.jj
new file mode 100644
index 0000000000000000000000000000000000000000..1cc1b425f6ec59712be808eeec8403ba8131c600
--- /dev/null
+++ b/tools/javacc-4.0/examples/JavaCCGrammar/JavaCC.jj
@@ -0,0 +1,1504 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+
+options {
+  JAVA_UNICODE_ESCAPE = true;
+}
+
+PARSER_BEGIN(JavaCCParser)
+
+public class JavaCCParser {
+
+  public static void main(String args[]) {
+    JavaCCParser parser;
+    if (args.length == 0) {
+      System.out.println("JavaCC Parser:  Reading from standard input . . .");
+      parser = new JavaCCParser(System.in);
+    } else if (args.length == 1) {
+      System.out.println("JavaCC Parser:  Reading from file " + args[0] + " . . .");
+      try {
+        parser = new JavaCCParser(new java.io.FileInputStream(args[0]));
+      } catch (java.io.FileNotFoundException e) {
+        System.out.println("JavaCC Parser:  File " + args[0] + " not found.");
+        return;
+      }
+    } else {
+      System.out.println("JavaCC Parser:  Usage is one of:");
+      System.out.println("         java JavaCCParser < inputfile");
+      System.out.println("OR");
+      System.out.println("         java JavaCCParser inputfile");
+      return;
+    }
+    try {
+      parser.javacc_input();
+      System.out.println("JavaCC Parser:  Java program parsed successfully.");
+    } catch (ParseException e) {
+      System.out.println(e.getMessage());
+      System.out.println("JavaCC Parser:  Encountered errors during parse.");
+    }
+  }
+
+  /*
+   * Returns true if the next token is not in the FOLLOW list of "expansion".
+   * It is used to decide when the end of an "expansion" has been reached.
+   */
+  static private boolean notTailOfExpansionUnit() {
+    Token t;
+    t = getToken(1);
+    if (t.kind == BIT_OR || t.kind == COMMA || t.kind == RPAREN || t.kind == RBRACE || t.kind == RBRACKET) return false;
+    return true;
+  }
+
+}
+
+PARSER_END(JavaCCParser)
+
+
+/**********************************************
+ * THE JAVACC TOKEN SPECIFICATION STARTS HERE *
+ **********************************************/
+
+/* JAVACC RESERVED WORDS: These are the only tokens in JavaCC but not in Java */
+
+TOKEN :
+{
+  < _OPTIONS: "options" >
+| < _LOOKAHEAD: "LOOKAHEAD" >
+| < _IGNORE_CASE: "IGNORE_CASE" >
+| < _PARSER_BEGIN: "PARSER_BEGIN" >
+| < _PARSER_END: "PARSER_END" >
+| < _JAVACODE: "JAVACODE" >
+| < _TOKEN: "TOKEN" >
+| < _SPECIAL_TOKEN: "SPECIAL_TOKEN" >
+| < _MORE: "MORE" >
+| < _SKIP: "SKIP" >
+| < _TOKEN_MGR_DECLS: "TOKEN_MGR_DECLS" >
+| < _EOF: "EOF" >
+}
+
+/*
+ * The remainder of the tokens are exactly (except for the removal of tokens
+ * containing ">>" and "<<") as in the Java grammar and must be diff equivalent
+ * (again with the exceptions above) to it.
+ */
+
+/* WHITE SPACE */
+
+SKIP :
+{
+  " "
+| "\t"
+| "\n"
+| "\r"
+| "\f"
+}
+
+/* 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 :
+{
+  < ~[] >
+}
+
+/* JAVA 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" >
+}
+
+/* JAVA 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 JAVACC GRAMMAR SPECIFICATION STARTS HERE *
+ ************************************************/
+
+void javacc_input() :
+{}
+{
+  javacc_options()
+  "PARSER_BEGIN" "(" identifier() ")"
+  CompilationUnit()
+  "PARSER_END" "(" identifier() ")"
+  ( production() )+
+  <EOF>
+}
+
+void javacc_options() :
+{}
+{
+  [ "options" "{" ( option_binding() )+ "}" ]
+}
+
+void option_binding() :
+{}
+{
+  ( <IDENTIFIER> | "LOOKAHEAD" | "IGNORE_CASE" | "static" )
+  "="
+  ( IntegerLiteral() | BooleanLiteral() | StringLiteral() )
+  ";"
+}
+
+void production() :
+{}
+{
+  LOOKAHEAD(1)
+  /*
+   * Since JAVACODE is both a JavaCC reserved word and a Java identifier,
+   * we need to give preference to "javacode_production" over
+   * "bnf_production".
+   */
+  javacode_production()
+|
+  LOOKAHEAD(1)
+  /*
+   * Since SKIP, TOKEN, etc. are both JavaCC reserved words and Java
+   * identifiers, we need to give preference to "regular_expression_production"
+   * over "bnf_production".
+   */
+  regular_expr_production()
+|
+  LOOKAHEAD(1)
+  /*
+   * Since TOKEN_MGR_DECLS is both a JavaCC reserved word and a Java identifier,
+   * we need to give preference to "token_manager_decls" over
+   * "bnf_production".
+   */
+  token_manager_decls()
+|
+  bnf_production()
+}
+
+void javacode_production() :
+{}
+{
+  "JAVACODE"
+  ResultType() identifier() FormalParameters()
+  [ "throws" Name() ( "," Name() )* ]
+  [ node_descriptor() ]
+  Block()
+}
+
+void bnf_production() :
+{}
+{
+  ResultType() identifier() FormalParameters()
+  [ "throws" Name() ( "," Name() )* ]
+  [ node_descriptor() ]
+  ":"
+  Block()
+  "{" expansion_choices() "}"
+}
+
+void regular_expr_production() :
+{}
+{
+  [
+    LOOKAHEAD(2) "<" "*" ">"
+  |
+    "<" <IDENTIFIER> ( "," <IDENTIFIER> )* ">"
+  ]
+  regexpr_kind() [ "[" "IGNORE_CASE" "]" ] ":"
+  "{" regexpr_spec() ( "|" regexpr_spec() )* "}"
+}
+
+void token_manager_decls() :
+{}
+{
+  "TOKEN_MGR_DECLS" ":" ClassBody()
+}
+
+void regexpr_kind() :
+{}
+{
+  "TOKEN"
+|
+  "SPECIAL_TOKEN"
+|
+  "SKIP"
+|
+  "MORE"
+}
+
+void regexpr_spec() :
+{}
+{
+  regular_expression() [ Block() ] [ ":" <IDENTIFIER> ]
+}
+
+void expansion_choices() :
+{}
+{
+  expansion() ( "|" expansion() )*
+}
+
+void expansion() :
+{}
+{
+  ( LOOKAHEAD(1)
+    "LOOKAHEAD" "(" local_lookahead() ")"
+  )?
+  ( LOOKAHEAD(0, { notTailOfExpansionUnit() } )
+    expansion_unit()
+    [ node_descriptor() ]
+  )+
+}
+
+void local_lookahead() :
+	{
+	  boolean commaAtEnd = false, emptyLA = true;
+	}
+{
+  [
+    /*
+     * The lookahead of 1 is to turn off the warning message that lets
+     * us know that an expansion choice can also start with an integer
+     * literal because a primary expression can do the same.  But we
+     * know that this is what we want.
+     */
+    LOOKAHEAD(1)
+    IntegerLiteral()
+	{
+	  emptyLA = false;
+	}
+  ]
+  [ LOOKAHEAD(0, { !emptyLA && (getToken(1).kind != RPAREN) } )
+    ","
+	{
+	  commaAtEnd = true;
+	}
+  ]
+  [ LOOKAHEAD(0, { getToken(1).kind != RPAREN && getToken(1).kind != LBRACE } )
+    expansion_choices()
+	{
+	  emptyLA = false; commaAtEnd = false;
+	}
+  ]
+  [ LOOKAHEAD(0, { !emptyLA && !commaAtEnd && (getToken(1).kind != RPAREN) } )
+    ","
+	{
+	  commaAtEnd = true;
+	}
+  ]
+  [ LOOKAHEAD(0, { emptyLA || commaAtEnd } )
+    "{" Expression() "}"
+  ]
+}
+
+void expansion_unit() :
+{}
+{
+  LOOKAHEAD(1)
+  /*
+   * We give this priority over primary expressions which use LOOKAHEAD as the
+   * name of its identifier.
+   */
+  "LOOKAHEAD" "(" local_lookahead() ")"
+|
+  Block()
+|
+  "[" expansion_choices() "]"
+|
+  "try" "{" expansion_choices() "}"
+  ( "catch" "(" Name() <IDENTIFIER> ")" Block() )*
+  [ "finally" Block() ]
+|
+  LOOKAHEAD( identifier() | StringLiteral() | "<" | PrimaryExpression() "=" )
+  [
+    LOOKAHEAD(PrimaryExpression() "=")
+    PrimaryExpression() "="
+  ]
+  ( regular_expression() | identifier() Arguments() )
+|
+  "(" expansion_choices() ")" ( "+" | "*" | "?" )?
+}
+
+void regular_expression() :
+{}
+{
+  StringLiteral()
+|
+  LOOKAHEAD(3)
+  "<" [ [ "#" ] identifier() ":" ] complex_regular_expression_choices() ">"
+|
+  LOOKAHEAD(2)
+  "<" identifier() ">"
+|
+  "<" "EOF" ">"
+}
+
+void complex_regular_expression_choices() :
+{}
+{
+  complex_regular_expression() ( "|" complex_regular_expression() )*
+}
+
+void complex_regular_expression() :
+{}
+{
+  ( complex_regular_expression_unit() )+
+}
+
+void complex_regular_expression_unit() :
+{}
+{
+  StringLiteral()
+|
+  "<" identifier() ">"
+|
+  character_list()
+|
+  "(" complex_regular_expression_choices() ")" ( "+" | "*" | "?" )?
+}
+
+void character_list() :
+{}
+{
+  [ "~" ] "[" [ character_descriptor() ( "," character_descriptor() )* ] "]"
+}
+
+void character_descriptor() :
+{}
+{
+  StringLiteral() [ "-" StringLiteral() ]
+}
+
+void identifier() :
+{}
+{
+  <IDENTIFIER>
+}
+
+
+/**********************************************
+ * THE JJTREE PRODUCTIONS START HERE          *
+ **********************************************/
+
+void node_descriptor() :
+{}
+{
+  "#" ( <IDENTIFIER> | <VOID> )
+  [
+   LOOKAHEAD(1)
+   "(" [ ">" ] node_descriptor_expression() ")"
+  ]
+}
+
+
+JAVACODE
+void node_descriptor_expression()
+{
+  Token tok;
+  int nesting = 1;
+  while (true) {
+    tok = getToken(1);
+    if (tok.kind == 0) {
+      throw new ParseException();
+    }
+    if (tok.kind == LPAREN) nesting++;
+    if (tok.kind == RPAREN) {
+      nesting--;
+      if (nesting == 0) break;
+    }
+    tok = getNextToken();
+  }
+}
+
+
+/**********************************************
+ * THE JAVA GRAMMAR SPECIFICATION STARTS HERE *
+ **********************************************/
+
+/*
+ * The Java grammar is modified to use sequences of tokens
+ * for the missing tokens - those that include "<<" and ">>".
+ */
+
+/*
+ * The following production defines Java identifiers - it
+ * includes the reserved words of JavaCC also.
+ */
+
+void JavaIdentifier() :
+{}
+{
+  <IDENTIFIER>
+| "options"
+| "LOOKAHEAD"
+| "IGNORE_CASE"
+| "PARSER_BEGIN"
+| "PARSER_END"
+| "JAVACODE"
+| "TOKEN"
+| "SPECIAL_TOKEN"
+| "MORE"
+| "SKIP"
+| "TOKEN_MGR_DECLS"
+| "EOF"
+}
+
+/*
+ * The productions for the missing code follows.  Obviously
+ * these productions accept more than what is legal in Java,
+ * but that is OK for our purposes.
+ */
+
+void ShiftOps() :
+{}
+{
+  "<" "<"
+|
+  ">" ">" [ ">" ]
+}
+
+void OtherAssignmentOps() :
+{}
+{
+  "<" "<="
+|
+  ">" [ ">" ] ">="
+}
+
+/*
+ * Program structuring syntax follows.
+ */
+
+void CompilationUnit() :
+/*
+ * The <EOF> is deleted since the compilation unit is embedded
+ * within grammar code.  To parse to CompilationUnit, we use
+ * a special production JavaCompilationUnit below.
+ */
+{}
+{
+  [ PackageDeclaration() ]
+  ( ImportDeclaration() )*
+  ( TypeDeclaration() )*
+}
+
+void JavaCompilationUnit() :
+/*
+ * Use this to parse a Java compilation unit.
+ */
+{}
+{
+  CompilationUnit() <EOF>
+}
+
+void PackageDeclaration() :
+{}
+{
+  "package" Name() ";"
+}
+
+void ImportDeclaration() :
+{}
+{
+  "import" Name() [ "." "*" ] ";"
+}
+
+void TypeDeclaration() :
+{}
+{
+  LOOKAHEAD( ( "abstract" | "final" | "public" )* "class" )
+  ClassDeclaration()
+|
+  InterfaceDeclaration()
+|
+  ";"
+}
+
+
+/*
+ * Declaration syntax follows.
+ */
+
+void ClassDeclaration() :
+{}
+{
+  ( "abstract" | "final" | "public" )*
+  UnmodifiedClassDeclaration()
+}
+
+void UnmodifiedClassDeclaration() :
+{}
+{
+  "class" JavaIdentifier() [ "extends" Name() ] [ "implements" NameList() ]
+  ClassBody()
+}
+
+void ClassBody() :
+{}
+{
+  "{" ( ClassBodyDeclaration() )* "}"
+}
+
+void NestedClassDeclaration() :
+{}
+{
+  ( "static" | "abstract" | "final" | "public" | "protected" | "private" )*
+  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() JavaIdentifier() "("
+}
+
+void InterfaceDeclaration() :
+{}
+{
+  ( "abstract" | "public" )*
+  UnmodifiedInterfaceDeclaration()
+}
+
+void NestedInterfaceDeclaration() :
+{}
+{
+  ( "static" | "abstract" | "final" | "public" | "protected" | "private" )*
+  UnmodifiedInterfaceDeclaration()
+}
+
+void UnmodifiedInterfaceDeclaration() :
+{}
+{
+  "interface" JavaIdentifier() [ "extends" NameList() ]
+  "{" ( InterfaceMemberDeclaration() )* "}"
+}
+
+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" | "protected" | "private" | "static" | "final" | "transient" | "volatile" )*
+  Type() VariableDeclarator() ( "," VariableDeclarator() )* ";"
+}
+
+void VariableDeclarator() :
+{}
+{
+  VariableDeclaratorId() [ "=" VariableInitializer() ]
+}
+
+void VariableDeclaratorId() :
+{}
+{
+  JavaIdentifier() ( "[" "]" )*
+}
+
+void VariableInitializer() :
+{}
+{
+  ArrayInitializer()
+|
+  Expression()
+}
+
+void ArrayInitializer() :
+{}
+{
+  "{" [ VariableInitializer() ( LOOKAHEAD(2) "," VariableInitializer() )* ] [ "," ] "}"
+}
+
+void MethodDeclaration() :
+{}
+{
+  ( "public" | "protected" | "private" | "static" | "abstract" | "final" | "native" | "synchronized" )*
+  ResultType() MethodDeclarator() [ "throws" NameList() ]
+  ( Block() | ";" )
+}
+
+void MethodDeclarator() :
+{}
+{
+  JavaIdentifier() FormalParameters() ( "[" "]" )*
+}
+
+void FormalParameters() :
+{}
+{
+  "(" [ FormalParameter() ( "," FormalParameter() )* ] ")"
+}
+
+void FormalParameter() :
+{}
+{
+  [ "final" ] Type() VariableDeclaratorId()
+}
+
+void ConstructorDeclaration() :
+{}
+{
+  [ "public" | "protected" | "private" ]
+  JavaIdentifier() FormalParameters() [ "throws" NameList() ]
+  "{"
+    [ LOOKAHEAD(ExplicitConstructorInvocation()) ExplicitConstructorInvocation() ]
+    ( BlockStatement() )*
+  "}"
+}
+
+void ExplicitConstructorInvocation() :
+{}
+{
+  LOOKAHEAD("this" Arguments() ";")
+  "this" Arguments() ";"
+|
+  [ LOOKAHEAD(2) PrimaryExpression() "." ] "super" Arguments() ";"
+}
+
+void Initializer() :
+{}
+{
+  [ "static" ] Block()
+}
+
+
+/*
+ * Type, name and expression syntax follows.
+ */
+
+void Type() :
+{}
+{
+  ( PrimitiveType() | Name() ) ( "[" "]" )*
+}
+
+void PrimitiveType() :
+{}
+{
+  "boolean"
+|
+  "char"
+|
+  "byte"
+|
+  "short"
+|
+  "int"
+|
+  "long"
+|
+  "float"
+|
+  "double"
+}
+
+void ResultType() :
+{}
+{
+  "void"
+|
+  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".
+ */
+{}
+{
+  JavaIdentifier()
+  ( LOOKAHEAD(2) "." JavaIdentifier() )*
+}
+
+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() :
+{}
+{
+  "=" | "*=" | "/=" | "%=" | "+=" | "-=" | "&=" | "^=" | "|="
+|
+  OtherAssignmentOps()
+}
+
+void ConditionalExpression() :
+{}
+{
+  ConditionalOrExpression() [ "?" Expression() ":" ConditionalExpression() ]
+}
+
+void ConditionalOrExpression() :
+{}
+{
+  ConditionalAndExpression() ( "||" ConditionalAndExpression() )*
+}
+
+void ConditionalAndExpression() :
+{}
+{
+  InclusiveOrExpression() ( "&&" InclusiveOrExpression() )*
+}
+
+void InclusiveOrExpression() :
+{}
+{
+  ExclusiveOrExpression() ( "|" ExclusiveOrExpression() )*
+}
+
+void ExclusiveOrExpression() :
+{}
+{
+  AndExpression() ( "^" AndExpression() )*
+}
+
+void AndExpression() :
+{}
+{
+  EqualityExpression() ( "&" EqualityExpression() )*
+}
+
+void EqualityExpression() :
+{}
+{
+  InstanceOfExpression() ( ( "==" | "!=" ) InstanceOfExpression() )*
+}
+
+void InstanceOfExpression() :
+{}
+{
+  RelationalExpression() [ "instanceof" Type() ]
+}
+
+void RelationalExpression() :
+{}
+{
+  /*
+   * The lookahead of 2 below is due to the fact that we have split
+   * the shift and shift assignment operator into multiple tokens that
+   * now clash with these tokens.
+   */
+  ShiftExpression() ( LOOKAHEAD(2) ( "<" | ">" | "<=" | ">=" ) ShiftExpression() )*
+}
+
+void ShiftExpression() :
+{}
+{
+  /*
+   * The lookahead of 3 below is due to the fact that we have split
+   * the shift and shift assignment operator into multiple tokens that
+   * now clash with these tokens and the relational operators.
+   */
+  AdditiveExpression() ( LOOKAHEAD(3) ( ShiftOps() ) AdditiveExpression() )*
+}
+
+void AdditiveExpression() :
+{}
+{
+  MultiplicativeExpression() ( ( "+" | "-" ) MultiplicativeExpression() )*
+}
+
+void MultiplicativeExpression() :
+{}
+{
+  UnaryExpression() ( ( "*" | "/" | "%" ) UnaryExpression() )*
+}
+
+void UnaryExpression() :
+{}
+{
+  ( "+" | "-" ) UnaryExpression()
+|
+  PreIncrementExpression()
+|
+  PreDecrementExpression()
+|
+  UnaryExpressionNotPlusMinus()
+}
+
+void PreIncrementExpression() :
+{}
+{
+  "++" PrimaryExpression()
+}
+
+void PreDecrementExpression() :
+{}
+{
+  "--" PrimaryExpression()
+}
+
+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() ")" ( "~" | "!" | "(" | JavaIdentifier() | "this" | "super" | "new" | Literal() )
+}
+
+void PostfixExpression() :
+{}
+{
+  PrimaryExpression() [ "++" | "--" ]
+}
+
+void CastExpression() :
+{}
+{
+  LOOKAHEAD("(" PrimitiveType())
+  "(" Type() ")" UnaryExpression()
+|
+  LOOKAHEAD("(" Name())
+  "(" Type() ")" UnaryExpressionNotPlusMinus()
+}
+
+void PrimaryExpression() :
+{}
+{
+  PrimaryPrefix() ( LOOKAHEAD(2) PrimarySuffix() )*
+}
+
+void PrimaryPrefix() :
+{}
+{
+  Literal()
+|
+  "this"
+|
+  "super" "." JavaIdentifier()
+|
+  "(" Expression() ")"
+|
+  AllocationExpression()
+|
+  LOOKAHEAD( ResultType() "." "class" )
+  ResultType() "." "class"
+|
+  Name()
+}
+
+void PrimarySuffix() :
+{}
+{
+  LOOKAHEAD(2)
+  "." "this"
+|
+  LOOKAHEAD(2)
+  "." AllocationExpression()
+|
+  "[" Expression() "]"
+|
+  "." JavaIdentifier()
+|
+  Arguments()
+}
+
+void Literal() :
+{}
+{
+  <INTEGER_LITERAL>
+|
+  <FLOATING_POINT_LITERAL>
+|
+  <CHARACTER_LITERAL>
+|
+  <STRING_LITERAL>
+|
+  BooleanLiteral()
+|
+  NullLiteral()
+}
+
+void IntegerLiteral() :
+{}
+{
+  <INTEGER_LITERAL>
+}
+
+void BooleanLiteral() :
+{}
+{
+  "true"
+|
+  "false"
+}
+
+void StringLiteral() :
+{}
+{
+  <STRING_LITERAL>
+}
+
+void NullLiteral() :
+{}
+{
+  "null"
+}
+
+void Arguments() :
+{}
+{
+  "(" [ ArgumentList() ] ")"
+}
+
+void ArgumentList() :
+{}
+{
+  Expression() ( "," Expression() )*
+}
+
+void AllocationExpression() :
+{}
+{
+  LOOKAHEAD(2)
+  "new" PrimitiveType() ArrayDimsAndInits()
+|
+  "new" Name()
+    (
+      ArrayDimsAndInits()
+    |
+      Arguments() [ ClassBody() ]
+    )
+}
+
+/*
+ * The second 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() ";"
+|
+  SwitchStatement()
+|
+  IfStatement()
+|
+  WhileStatement()
+|
+  DoStatement()
+|
+  ForStatement()
+|
+  BreakStatement()
+|
+  ContinueStatement()
+|
+  ReturnStatement()
+|
+  ThrowStatement()
+|
+  SynchronizedStatement()
+|
+  TryStatement()
+}
+
+void LabeledStatement() :
+{}
+{
+  JavaIdentifier() ":" Statement()
+}
+
+void Block() :
+{}
+{
+  "{" ( BlockStatement() )* "}"
+}
+
+void BlockStatement() :
+{}
+{
+  LOOKAHEAD([ "final" ] Type() JavaIdentifier())
+  LocalVariableDeclaration() ";"
+|
+  Statement()
+|
+  UnmodifiedClassDeclaration()
+|
+  UnmodifiedInterfaceDeclaration()
+}
+
+void LocalVariableDeclaration() :
+{}
+{
+  [ "final" ] 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()
+  [
+    "++"
+  |
+    "--"
+  |
+    AssignmentOperator() Expression()
+  ]
+}
+
+void SwitchStatement() :
+{}
+{
+  "switch" "(" Expression() ")" "{"
+    ( SwitchLabel() ( BlockStatement() )* )*
+  "}"
+}
+
+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" "(" Expression() ")" Statement() [ LOOKAHEAD(1) "else" Statement() ]
+}
+
+void WhileStatement() :
+{}
+{
+  "while" "(" Expression() ")" Statement()
+}
+
+void DoStatement() :
+{}
+{
+  "do" Statement() "while" "(" Expression() ")" ";"
+}
+
+void ForStatement() :
+{}
+{
+  "for" "(" [ ForInit() ] ";" [ Expression() ] ";" [ ForUpdate() ] ")" Statement()
+}
+
+void ForInit() :
+{}
+{
+  LOOKAHEAD( [ "final" ] Type() JavaIdentifier() )
+  LocalVariableDeclaration()
+|
+  StatementExpressionList()
+}
+
+void StatementExpressionList() :
+{}
+{
+  StatementExpression() ( "," StatementExpression() )*
+}
+
+void ForUpdate() :
+{}
+{
+  StatementExpressionList()
+}
+
+void BreakStatement() :
+{}
+{
+  "break" [ JavaIdentifier() ] ";"
+}
+
+void ContinueStatement() :
+{}
+{
+  "continue" [ JavaIdentifier() ] ";"
+}
+
+void ReturnStatement() :
+{}
+{
+  "return" [ Expression() ] ";"
+}
+
+void ThrowStatement() :
+{}
+{
+  "throw" Expression() ";"
+}
+
+void SynchronizedStatement() :
+{}
+{
+  "synchronized" "(" Expression() ")" Block()
+}
+
+void TryStatement() :
+/*
+ * Semantic check required here to make sure that at least one
+ * finally/catch is present.
+ */
+{}
+{
+  "try" Block()
+  ( "catch" "(" FormalParameter() ")" Block() )*
+  [ "finally" Block() ]
+}
diff --git a/tools/javacc-4.0/examples/JavaGrammars/1.5/Java1.5.jj b/tools/javacc-4.0/examples/JavaGrammars/1.5/Java1.5.jj
new file mode 100644
index 0000000000000000000000000000000000000000..d88241074f4708b7666c5f3b4c45efd37dd3cc6c
--- /dev/null
+++ b/tools/javacc-4.0/examples/JavaGrammars/1.5/Java1.5.jj
@@ -0,0 +1,2095 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+options {
+  JAVA_UNICODE_ESCAPE = true;
+  ERROR_REPORTING = false;
+  STATIC = false;
+  JDK_VERSION = "1.5";
+}
+
+PARSER_BEGIN(JavaParser)
+
+import java.io.*;
+
+/**
+ * Grammar to parse Java version 1.5
+ * @author Sreenivasa Viswanadha - Simplified and enhanced for 1.5
+ */
+public class JavaParser
+{
+   /**
+    * Class to hold modifiers.
+    */
+   static public final class ModifierSet
+   {
+     /* Definitions of the bits in the modifiers field.  */
+     public static final int PUBLIC = 0x0001;
+     public static final int PROTECTED = 0x0002;
+     public static final int PRIVATE = 0x0004;
+     public static final int ABSTRACT = 0x0008;
+     public static final int STATIC = 0x0010;
+     public static final int FINAL = 0x0020;
+     public static final int SYNCHRONIZED = 0x0040;
+     public static final int NATIVE = 0x0080;
+     public static final int TRANSIENT = 0x0100;
+     public static final int VOLATILE = 0x0200;
+     public static final int STRICTFP = 0x1000;
+
+     /** A set of accessors that indicate whether the specified modifier
+         is in the set. */
+
+     public boolean isPublic(int modifiers)
+     {
+       return (modifiers & PUBLIC) != 0;
+     }
+
+     public boolean isProtected(int modifiers)
+     {
+       return (modifiers & PROTECTED) != 0;
+     }
+
+     public boolean isPrivate(int modifiers)
+     {
+       return (modifiers & PRIVATE) != 0;
+     }
+
+     public boolean isStatic(int modifiers)
+     {
+       return (modifiers & STATIC) != 0;
+     }
+
+     public boolean isAbstract(int modifiers)
+     {
+       return (modifiers & ABSTRACT) != 0;
+     }
+
+     public boolean isFinal(int modifiers)
+     {
+       return (modifiers & FINAL) != 0;
+     }
+
+     public boolean isNative(int modifiers)
+     {
+       return (modifiers & NATIVE) != 0;
+     }
+
+     public boolean isStrictfp(int modifiers)
+     {
+       return (modifiers & STRICTFP) != 0;
+     }
+
+     public boolean isSynchronized(int modifiers)
+     {
+       return (modifiers & SYNCHRONIZED) != 0;
+     }
+
+     public boolean isTransient(int modifiers)
+      {
+       return (modifiers & TRANSIENT) != 0;
+     }
+
+     public boolean isVolatile(int modifiers)
+     {
+       return (modifiers & VOLATILE) != 0;
+     }
+
+     /**
+      * Removes the given modifier.
+      */
+     static int removeModifier(int modifiers, int mod)
+     {
+        return modifiers & ~mod;
+     }
+   }
+
+   public JavaParser(String fileName)
+   {
+      this(System.in);
+      try { ReInit(new FileInputStream(new File(fileName))); }
+      catch(Exception e) { e.printStackTrace(); }
+   }
+
+  public static void main(String args[]) {
+    JavaParser parser;
+    if (args.length == 0) {
+      System.out.println("Java Parser Version 1.1:  Reading from standard input . . .");
+      parser = new JavaParser(System.in);
+    } else if (args.length == 1) {
+      System.out.println("Java Parser Version 1.1:  Reading from file " + args[0] + " . . .");
+      try {
+        parser = new JavaParser(new java.io.FileInputStream(args[0]));
+      } catch (java.io.FileNotFoundException e) {
+        System.out.println("Java Parser Version 1.1:  File " + args[0] + " not found.");
+        return;
+      }
+    } else {
+      System.out.println("Java Parser Version 1.1:  Usage is one of:");
+      System.out.println("         java JavaParser < inputfile");
+      System.out.println("OR");
+      System.out.println("         java JavaParser inputfile");
+      return;
+    }
+    try {
+      parser.CompilationUnit();
+      System.out.println("Java Parser Version 1.1:  Java program parsed successfully.");
+    } catch (ParseException e) {
+      System.out.println(e.getMessage());
+      System.out.println("Java Parser Version 1.1:  Encountered errors during parse.");
+    }
+  }
+
+}
+
+PARSER_END(JavaParser)
+
+/* WHITE SPACE */
+
+SKIP :
+{
+  " "
+| "\t"
+| "\n"
+| "\r"
+| "\f"
+}
+
+/* COMMENTS */
+
+MORE :
+{
+  <"/**" ~["/"]> { input_stream.backup(1); } : IN_FORMAL_COMMENT
+|
+  "/*" : IN_MULTI_LINE_COMMENT
+}
+
+SPECIAL_TOKEN :
+{
+  <SINGLE_LINE_COMMENT: "//" (~["\n", "\r"])* ("\n" | "\r" | "\r\n")?>
+}
+
+<IN_FORMAL_COMMENT>
+SPECIAL_TOKEN :
+{
+  <FORMAL_COMMENT: "*/" > : DEFAULT
+}
+
+<IN_MULTI_LINE_COMMENT>
+SPECIAL_TOKEN :
+{
+  <MULTI_LINE_COMMENT: "*/" > : DEFAULT
+}
+
+<IN_FORMAL_COMMENT,IN_MULTI_LINE_COMMENT>
+MORE :
+{
+  < ~[] >
+}
+
+/* RESERVED WORDS AND LITERALS */
+
+TOKEN :
+{
+  < ABSTRACT: "abstract" >
+| < ASSERT: "assert" >
+| < 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" >
+| < ENUM: "enum" >
+| < 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" >
+| < STRICTFP: "strictfp" >
+| < 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:
+        <DECIMAL_FLOATING_POINT_LITERAL>
+      | <HEXADECIMAL_FLOATING_POINT_LITERAL>
+  >
+|
+  < #DECIMAL_FLOATING_POINT_LITERAL:
+        (["0"-"9"])+ "." (["0"-"9"])* (<DECIMAL_EXPONENT>)? (["f","F","d","D"])?
+      | "." (["0"-"9"])+ (<DECIMAL_EXPONENT>)? (["f","F","d","D"])?
+      | (["0"-"9"])+ <DECIMAL_EXPONENT> (["f","F","d","D"])?
+      | (["0"-"9"])+ (<DECIMAL_EXPONENT>)? ["f","F","d","D"]
+  >
+|
+  < #DECIMAL_EXPONENT: ["e","E"] (["+","-"])? (["0"-"9"])+ >
+|
+  < #HEXADECIMAL_FLOATING_POINT_LITERAL:
+        "0" ["x", "X"] (["0"-"9","a"-"f","A"-"F"])+ (".")? <HEXADECIMAL_EXPONENT> (["f","F","d","D"])?
+      | "0" ["x", "X"] (["0"-"9","a"-"f","A"-"F"])* "." (["0"-"9","a"-"f","A"-"F"])+ <HEXADECIMAL_EXPONENT> (["f","F","d","D"])?
+  >
+|
+  < #HEXADECIMAL_EXPONENT: ["p","P"] (["+","-"])? (["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> (<PART_LETTER>)* >
+|
+  < #LETTER:
+      [  // all chars for which Character.isIdentifierStart is true
+         "$",
+         "A"-"Z",
+         "_",
+         "a"-"z",
+         "\u00a2"-"\u00a5",
+         "\u00aa",
+         "\u00b5",
+         "\u00ba",
+         "\u00c0"-"\u00d6",
+         "\u00d8"-"\u00f6",
+         "\u00f8"-"\u021f",
+         "\u0222"-"\u0233",
+         "\u0250"-"\u02ad",
+         "\u02b0"-"\u02b8",
+         "\u02bb"-"\u02c1",
+         "\u02d0"-"\u02d1",
+         "\u02e0"-"\u02e4",
+         "\u02ee",
+         "\u037a",
+         "\u0386",
+         "\u0388"-"\u038a",
+         "\u038c",
+         "\u038e"-"\u03a1",
+         "\u03a3"-"\u03ce",
+         "\u03d0"-"\u03d7",
+         "\u03da"-"\u03f3",
+         "\u0400"-"\u0481",
+         "\u048c"-"\u04c4",
+         "\u04c7"-"\u04c8",
+         "\u04cb"-"\u04cc",
+         "\u04d0"-"\u04f5",
+         "\u04f8"-"\u04f9",
+         "\u0531"-"\u0556",
+         "\u0559",
+         "\u0561"-"\u0587",
+         "\u05d0"-"\u05ea",
+         "\u05f0"-"\u05f2",
+         "\u0621"-"\u063a",
+         "\u0640"-"\u064a",
+         "\u0671"-"\u06d3",
+         "\u06d5",
+         "\u06e5"-"\u06e6",
+         "\u06fa"-"\u06fc",
+         "\u0710",
+         "\u0712"-"\u072c",
+         "\u0780"-"\u07a5",
+         "\u0905"-"\u0939",
+         "\u093d",
+         "\u0950",
+         "\u0958"-"\u0961",
+         "\u0985"-"\u098c",
+         "\u098f"-"\u0990",
+         "\u0993"-"\u09a8",
+         "\u09aa"-"\u09b0",
+         "\u09b2",
+         "\u09b6"-"\u09b9",
+         "\u09dc"-"\u09dd",
+         "\u09df"-"\u09e1",
+         "\u09f0"-"\u09f3",
+         "\u0a05"-"\u0a0a",
+         "\u0a0f"-"\u0a10",
+         "\u0a13"-"\u0a28",
+         "\u0a2a"-"\u0a30",
+         "\u0a32"-"\u0a33",
+         "\u0a35"-"\u0a36",
+         "\u0a38"-"\u0a39",
+         "\u0a59"-"\u0a5c",
+         "\u0a5e",
+         "\u0a72"-"\u0a74",
+         "\u0a85"-"\u0a8b",
+         "\u0a8d",
+         "\u0a8f"-"\u0a91",
+         "\u0a93"-"\u0aa8",
+         "\u0aaa"-"\u0ab0",
+         "\u0ab2"-"\u0ab3",
+         "\u0ab5"-"\u0ab9",
+         "\u0abd",
+         "\u0ad0",
+         "\u0ae0",
+         "\u0b05"-"\u0b0c",
+         "\u0b0f"-"\u0b10",
+         "\u0b13"-"\u0b28",
+         "\u0b2a"-"\u0b30",
+         "\u0b32"-"\u0b33",
+         "\u0b36"-"\u0b39",
+         "\u0b3d",
+         "\u0b5c"-"\u0b5d",
+         "\u0b5f"-"\u0b61",
+         "\u0b85"-"\u0b8a",
+         "\u0b8e"-"\u0b90",
+         "\u0b92"-"\u0b95",
+         "\u0b99"-"\u0b9a",
+         "\u0b9c",
+         "\u0b9e"-"\u0b9f",
+         "\u0ba3"-"\u0ba4",
+         "\u0ba8"-"\u0baa",
+         "\u0bae"-"\u0bb5",
+         "\u0bb7"-"\u0bb9",
+         "\u0c05"-"\u0c0c",
+         "\u0c0e"-"\u0c10",
+         "\u0c12"-"\u0c28",
+         "\u0c2a"-"\u0c33",
+         "\u0c35"-"\u0c39",
+         "\u0c60"-"\u0c61",
+         "\u0c85"-"\u0c8c",
+         "\u0c8e"-"\u0c90",
+         "\u0c92"-"\u0ca8",
+         "\u0caa"-"\u0cb3",
+         "\u0cb5"-"\u0cb9",
+         "\u0cde",
+         "\u0ce0"-"\u0ce1",
+         "\u0d05"-"\u0d0c",
+         "\u0d0e"-"\u0d10",
+         "\u0d12"-"\u0d28",
+         "\u0d2a"-"\u0d39",
+         "\u0d60"-"\u0d61",
+         "\u0d85"-"\u0d96",
+         "\u0d9a"-"\u0db1",
+         "\u0db3"-"\u0dbb",
+         "\u0dbd",
+         "\u0dc0"-"\u0dc6",
+         "\u0e01"-"\u0e30",
+         "\u0e32"-"\u0e33",
+         "\u0e3f"-"\u0e46",
+         "\u0e81"-"\u0e82",
+         "\u0e84",
+         "\u0e87"-"\u0e88",
+         "\u0e8a",
+         "\u0e8d",
+         "\u0e94"-"\u0e97",
+         "\u0e99"-"\u0e9f",
+         "\u0ea1"-"\u0ea3",
+         "\u0ea5",
+         "\u0ea7",
+         "\u0eaa"-"\u0eab",
+         "\u0ead"-"\u0eb0",
+         "\u0eb2"-"\u0eb3",
+         "\u0ebd",
+         "\u0ec0"-"\u0ec4",
+         "\u0ec6",
+         "\u0edc"-"\u0edd",
+         "\u0f00",
+         "\u0f40"-"\u0f47",
+         "\u0f49"-"\u0f6a",
+         "\u0f88"-"\u0f8b",
+         "\u1000"-"\u1021",
+         "\u1023"-"\u1027",
+         "\u1029"-"\u102a",
+         "\u1050"-"\u1055",
+         "\u10a0"-"\u10c5",
+         "\u10d0"-"\u10f6",
+         "\u1100"-"\u1159",
+         "\u115f"-"\u11a2",
+         "\u11a8"-"\u11f9",
+         "\u1200"-"\u1206",
+         "\u1208"-"\u1246",
+         "\u1248",
+         "\u124a"-"\u124d",
+         "\u1250"-"\u1256",
+         "\u1258",
+         "\u125a"-"\u125d",
+         "\u1260"-"\u1286",
+         "\u1288",
+         "\u128a"-"\u128d",
+         "\u1290"-"\u12ae",
+         "\u12b0",
+         "\u12b2"-"\u12b5",
+         "\u12b8"-"\u12be",
+         "\u12c0",
+         "\u12c2"-"\u12c5",
+         "\u12c8"-"\u12ce",
+         "\u12d0"-"\u12d6",
+         "\u12d8"-"\u12ee",
+         "\u12f0"-"\u130e",
+         "\u1310",
+         "\u1312"-"\u1315",
+         "\u1318"-"\u131e",
+         "\u1320"-"\u1346",
+         "\u1348"-"\u135a",
+         "\u13a0"-"\u13f4",
+         "\u1401"-"\u166c",
+         "\u166f"-"\u1676",
+         "\u1681"-"\u169a",
+         "\u16a0"-"\u16ea",
+         "\u1780"-"\u17b3",
+         "\u17db",
+         "\u1820"-"\u1877",
+         "\u1880"-"\u18a8",
+         "\u1e00"-"\u1e9b",
+         "\u1ea0"-"\u1ef9",
+         "\u1f00"-"\u1f15",
+         "\u1f18"-"\u1f1d",
+         "\u1f20"-"\u1f45",
+         "\u1f48"-"\u1f4d",
+         "\u1f50"-"\u1f57",
+         "\u1f59",
+         "\u1f5b",
+         "\u1f5d",
+         "\u1f5f"-"\u1f7d",
+         "\u1f80"-"\u1fb4",
+         "\u1fb6"-"\u1fbc",
+         "\u1fbe",
+         "\u1fc2"-"\u1fc4",
+         "\u1fc6"-"\u1fcc",
+         "\u1fd0"-"\u1fd3",
+         "\u1fd6"-"\u1fdb",
+         "\u1fe0"-"\u1fec",
+         "\u1ff2"-"\u1ff4",
+         "\u1ff6"-"\u1ffc",
+         "\u203f"-"\u2040",
+         "\u207f",
+         "\u20a0"-"\u20af",
+         "\u2102",
+         "\u2107",
+         "\u210a"-"\u2113",
+         "\u2115",
+         "\u2119"-"\u211d",
+         "\u2124",
+         "\u2126",
+         "\u2128",
+         "\u212a"-"\u212d",
+         "\u212f"-"\u2131",
+         "\u2133"-"\u2139",
+         "\u2160"-"\u2183",
+         "\u3005"-"\u3007",
+         "\u3021"-"\u3029",
+         "\u3031"-"\u3035",
+         "\u3038"-"\u303a",
+         "\u3041"-"\u3094",
+         "\u309d"-"\u309e",
+         "\u30a1"-"\u30fe",
+         "\u3105"-"\u312c",
+         "\u3131"-"\u318e",
+         "\u31a0"-"\u31b7",
+         "\u3400"-"\u4db5",
+         "\u4e00"-"\u9fa5",
+         "\ua000"-"\ua48c",
+         "\uac00"-"\ud7a3",
+         "\uf900"-"\ufa2d",
+         "\ufb00"-"\ufb06",
+         "\ufb13"-"\ufb17",
+         "\ufb1d",
+         "\ufb1f"-"\ufb28",
+         "\ufb2a"-"\ufb36",
+         "\ufb38"-"\ufb3c",
+         "\ufb3e",
+         "\ufb40"-"\ufb41",
+         "\ufb43"-"\ufb44",
+         "\ufb46"-"\ufbb1",
+         "\ufbd3"-"\ufd3d",
+         "\ufd50"-"\ufd8f",
+         "\ufd92"-"\ufdc7",
+         "\ufdf0"-"\ufdfb",
+         "\ufe33"-"\ufe34",
+         "\ufe4d"-"\ufe4f",
+         "\ufe69",
+         "\ufe70"-"\ufe72",
+         "\ufe74",
+         "\ufe76"-"\ufefc",
+         "\uff04",
+         "\uff21"-"\uff3a",
+         "\uff3f",
+         "\uff41"-"\uff5a",
+         "\uff65"-"\uffbe",
+         "\uffc2"-"\uffc7",
+         "\uffca"-"\uffcf",
+         "\uffd2"-"\uffd7",
+         "\uffda"-"\uffdc",
+         "\uffe0"-"\uffe1",
+         "\uffe5"-"\uffe6"
+      ]
+  >
+|
+  < #PART_LETTER:
+      [  // all chars for which Character.isIdentifierPart is true
+         "\u0000"-"\u0008",
+         "\u000e"-"\u001b",
+         "$",
+         "0"-"9",
+         "A"-"Z",
+         "_",
+         "a"-"z",
+         "\u007f"-"\u009f",
+         "\u00a2"-"\u00a5",
+         "\u00aa",
+         "\u00b5",
+         "\u00ba",
+         "\u00c0"-"\u00d6",
+         "\u00d8"-"\u00f6",
+         "\u00f8"-"\u021f",
+         "\u0222"-"\u0233",
+         "\u0250"-"\u02ad",
+         "\u02b0"-"\u02b8",
+         "\u02bb"-"\u02c1",
+         "\u02d0"-"\u02d1",
+         "\u02e0"-"\u02e4",
+         "\u02ee",
+         "\u0300"-"\u034e",
+         "\u0360"-"\u0362",
+         "\u037a",
+         "\u0386",
+         "\u0388"-"\u038a",
+         "\u038c",
+         "\u038e"-"\u03a1",
+         "\u03a3"-"\u03ce",
+         "\u03d0"-"\u03d7",
+         "\u03da"-"\u03f3",
+         "\u0400"-"\u0481",
+         "\u0483"-"\u0486",
+         "\u048c"-"\u04c4",
+         "\u04c7"-"\u04c8",
+         "\u04cb"-"\u04cc",
+         "\u04d0"-"\u04f5",
+         "\u04f8"-"\u04f9",
+         "\u0531"-"\u0556",
+         "\u0559",
+         "\u0561"-"\u0587",
+         "\u0591"-"\u05a1",
+         "\u05a3"-"\u05b9",
+         "\u05bb"-"\u05bd",
+         "\u05bf",
+         "\u05c1"-"\u05c2",
+         "\u05c4",
+         "\u05d0"-"\u05ea",
+         "\u05f0"-"\u05f2",
+         "\u0621"-"\u063a",
+         "\u0640"-"\u0655",
+         "\u0660"-"\u0669",
+         "\u0670"-"\u06d3",
+         "\u06d5"-"\u06dc",
+         "\u06df"-"\u06e8",
+         "\u06ea"-"\u06ed",
+         "\u06f0"-"\u06fc",
+         "\u070f"-"\u072c",
+         "\u0730"-"\u074a",
+         "\u0780"-"\u07b0",
+         "\u0901"-"\u0903",
+         "\u0905"-"\u0939",
+         "\u093c"-"\u094d",
+         "\u0950"-"\u0954",
+         "\u0958"-"\u0963",
+         "\u0966"-"\u096f",
+         "\u0981"-"\u0983",
+         "\u0985"-"\u098c",
+         "\u098f"-"\u0990",
+         "\u0993"-"\u09a8",
+         "\u09aa"-"\u09b0",
+         "\u09b2",
+         "\u09b6"-"\u09b9",
+         "\u09bc",
+         "\u09be"-"\u09c4",
+         "\u09c7"-"\u09c8",
+         "\u09cb"-"\u09cd",
+         "\u09d7",
+         "\u09dc"-"\u09dd",
+         "\u09df"-"\u09e3",
+         "\u09e6"-"\u09f3",
+         "\u0a02",
+         "\u0a05"-"\u0a0a",
+         "\u0a0f"-"\u0a10",
+         "\u0a13"-"\u0a28",
+         "\u0a2a"-"\u0a30",
+         "\u0a32"-"\u0a33",
+         "\u0a35"-"\u0a36",
+         "\u0a38"-"\u0a39",
+         "\u0a3c",
+         "\u0a3e"-"\u0a42",
+         "\u0a47"-"\u0a48",
+         "\u0a4b"-"\u0a4d",
+         "\u0a59"-"\u0a5c",
+         "\u0a5e",
+         "\u0a66"-"\u0a74",
+         "\u0a81"-"\u0a83",
+         "\u0a85"-"\u0a8b",
+         "\u0a8d",
+         "\u0a8f"-"\u0a91",
+         "\u0a93"-"\u0aa8",
+         "\u0aaa"-"\u0ab0",
+         "\u0ab2"-"\u0ab3",
+         "\u0ab5"-"\u0ab9",
+         "\u0abc"-"\u0ac5",
+         "\u0ac7"-"\u0ac9",
+         "\u0acb"-"\u0acd",
+         "\u0ad0",
+         "\u0ae0",
+         "\u0ae6"-"\u0aef",
+         "\u0b01"-"\u0b03",
+         "\u0b05"-"\u0b0c",
+         "\u0b0f"-"\u0b10",
+         "\u0b13"-"\u0b28",
+         "\u0b2a"-"\u0b30",
+         "\u0b32"-"\u0b33",
+         "\u0b36"-"\u0b39",
+         "\u0b3c"-"\u0b43",
+         "\u0b47"-"\u0b48",
+         "\u0b4b"-"\u0b4d",
+         "\u0b56"-"\u0b57",
+         "\u0b5c"-"\u0b5d",
+         "\u0b5f"-"\u0b61",
+         "\u0b66"-"\u0b6f",
+         "\u0b82"-"\u0b83",
+         "\u0b85"-"\u0b8a",
+         "\u0b8e"-"\u0b90",
+         "\u0b92"-"\u0b95",
+         "\u0b99"-"\u0b9a",
+         "\u0b9c",
+         "\u0b9e"-"\u0b9f",
+         "\u0ba3"-"\u0ba4",
+         "\u0ba8"-"\u0baa",
+         "\u0bae"-"\u0bb5",
+         "\u0bb7"-"\u0bb9",
+         "\u0bbe"-"\u0bc2",
+         "\u0bc6"-"\u0bc8",
+         "\u0bca"-"\u0bcd",
+         "\u0bd7",
+         "\u0be7"-"\u0bef",
+         "\u0c01"-"\u0c03",
+         "\u0c05"-"\u0c0c",
+         "\u0c0e"-"\u0c10",
+         "\u0c12"-"\u0c28",
+         "\u0c2a"-"\u0c33",
+         "\u0c35"-"\u0c39",
+         "\u0c3e"-"\u0c44",
+         "\u0c46"-"\u0c48",
+         "\u0c4a"-"\u0c4d",
+         "\u0c55"-"\u0c56",
+         "\u0c60"-"\u0c61",
+         "\u0c66"-"\u0c6f",
+         "\u0c82"-"\u0c83",
+         "\u0c85"-"\u0c8c",
+         "\u0c8e"-"\u0c90",
+         "\u0c92"-"\u0ca8",
+         "\u0caa"-"\u0cb3",
+         "\u0cb5"-"\u0cb9",
+         "\u0cbe"-"\u0cc4",
+         "\u0cc6"-"\u0cc8",
+         "\u0cca"-"\u0ccd",
+         "\u0cd5"-"\u0cd6",
+         "\u0cde",
+         "\u0ce0"-"\u0ce1",
+         "\u0ce6"-"\u0cef",
+         "\u0d02"-"\u0d03",
+         "\u0d05"-"\u0d0c",
+         "\u0d0e"-"\u0d10",
+         "\u0d12"-"\u0d28",
+         "\u0d2a"-"\u0d39",
+         "\u0d3e"-"\u0d43",
+         "\u0d46"-"\u0d48",
+         "\u0d4a"-"\u0d4d",
+         "\u0d57",
+         "\u0d60"-"\u0d61",
+         "\u0d66"-"\u0d6f",
+         "\u0d82"-"\u0d83",
+         "\u0d85"-"\u0d96",
+         "\u0d9a"-"\u0db1",
+         "\u0db3"-"\u0dbb",
+         "\u0dbd",
+         "\u0dc0"-"\u0dc6",
+         "\u0dca",
+         "\u0dcf"-"\u0dd4",
+         "\u0dd6",
+         "\u0dd8"-"\u0ddf",
+         "\u0df2"-"\u0df3",
+         "\u0e01"-"\u0e3a",
+         "\u0e3f"-"\u0e4e",
+         "\u0e50"-"\u0e59",
+         "\u0e81"-"\u0e82",
+         "\u0e84",
+         "\u0e87"-"\u0e88",
+         "\u0e8a",
+         "\u0e8d",
+         "\u0e94"-"\u0e97",
+         "\u0e99"-"\u0e9f",
+         "\u0ea1"-"\u0ea3",
+         "\u0ea5",
+         "\u0ea7",
+         "\u0eaa"-"\u0eab",
+         "\u0ead"-"\u0eb9",
+         "\u0ebb"-"\u0ebd",
+         "\u0ec0"-"\u0ec4",
+         "\u0ec6",
+         "\u0ec8"-"\u0ecd",
+         "\u0ed0"-"\u0ed9",
+         "\u0edc"-"\u0edd",
+         "\u0f00",
+         "\u0f18"-"\u0f19",
+         "\u0f20"-"\u0f29",
+         "\u0f35",
+         "\u0f37",
+         "\u0f39",
+         "\u0f3e"-"\u0f47",
+         "\u0f49"-"\u0f6a",
+         "\u0f71"-"\u0f84",
+         "\u0f86"-"\u0f8b",
+         "\u0f90"-"\u0f97",
+         "\u0f99"-"\u0fbc",
+         "\u0fc6",
+         "\u1000"-"\u1021",
+         "\u1023"-"\u1027",
+         "\u1029"-"\u102a",
+         "\u102c"-"\u1032",
+         "\u1036"-"\u1039",
+         "\u1040"-"\u1049",
+         "\u1050"-"\u1059",
+         "\u10a0"-"\u10c5",
+         "\u10d0"-"\u10f6",
+         "\u1100"-"\u1159",
+         "\u115f"-"\u11a2",
+         "\u11a8"-"\u11f9",
+         "\u1200"-"\u1206",
+         "\u1208"-"\u1246",
+         "\u1248",
+         "\u124a"-"\u124d",
+         "\u1250"-"\u1256",
+         "\u1258",
+         "\u125a"-"\u125d",
+         "\u1260"-"\u1286",
+         "\u1288",
+         "\u128a"-"\u128d",
+         "\u1290"-"\u12ae",
+         "\u12b0",
+         "\u12b2"-"\u12b5",
+         "\u12b8"-"\u12be",
+         "\u12c0",
+         "\u12c2"-"\u12c5",
+         "\u12c8"-"\u12ce",
+         "\u12d0"-"\u12d6",
+         "\u12d8"-"\u12ee",
+         "\u12f0"-"\u130e",
+         "\u1310",
+         "\u1312"-"\u1315",
+         "\u1318"-"\u131e",
+         "\u1320"-"\u1346",
+         "\u1348"-"\u135a",
+         "\u1369"-"\u1371",
+         "\u13a0"-"\u13f4",
+         "\u1401"-"\u166c",
+         "\u166f"-"\u1676",
+         "\u1681"-"\u169a",
+         "\u16a0"-"\u16ea",
+         "\u1780"-"\u17d3",
+         "\u17db",
+         "\u17e0"-"\u17e9",
+         "\u180b"-"\u180e",
+         "\u1810"-"\u1819",
+         "\u1820"-"\u1877",
+         "\u1880"-"\u18a9",
+         "\u1e00"-"\u1e9b",
+         "\u1ea0"-"\u1ef9",
+         "\u1f00"-"\u1f15",
+         "\u1f18"-"\u1f1d",
+         "\u1f20"-"\u1f45",
+         "\u1f48"-"\u1f4d",
+         "\u1f50"-"\u1f57",
+         "\u1f59",
+         "\u1f5b",
+         "\u1f5d",
+         "\u1f5f"-"\u1f7d",
+         "\u1f80"-"\u1fb4",
+         "\u1fb6"-"\u1fbc",
+         "\u1fbe",
+         "\u1fc2"-"\u1fc4",
+         "\u1fc6"-"\u1fcc",
+         "\u1fd0"-"\u1fd3",
+         "\u1fd6"-"\u1fdb",
+         "\u1fe0"-"\u1fec",
+         "\u1ff2"-"\u1ff4",
+         "\u1ff6"-"\u1ffc",
+         "\u200c"-"\u200f",
+         "\u202a"-"\u202e",
+         "\u203f"-"\u2040",
+         "\u206a"-"\u206f",
+         "\u207f",
+         "\u20a0"-"\u20af",
+         "\u20d0"-"\u20dc",
+         "\u20e1",
+         "\u2102",
+         "\u2107",
+         "\u210a"-"\u2113",
+         "\u2115",
+         "\u2119"-"\u211d",
+         "\u2124",
+         "\u2126",
+         "\u2128",
+         "\u212a"-"\u212d",
+         "\u212f"-"\u2131",
+         "\u2133"-"\u2139",
+         "\u2160"-"\u2183",
+         "\u3005"-"\u3007",
+         "\u3021"-"\u302f",
+         "\u3031"-"\u3035",
+         "\u3038"-"\u303a",
+         "\u3041"-"\u3094",
+         "\u3099"-"\u309a",
+         "\u309d"-"\u309e",
+         "\u30a1"-"\u30fe",
+         "\u3105"-"\u312c",
+         "\u3131"-"\u318e",
+         "\u31a0"-"\u31b7",
+         "\u3400"-"\u4db5",
+         "\u4e00"-"\u9fa5",
+         "\ua000"-"\ua48c",
+         "\uac00"-"\ud7a3",
+         "\uf900"-"\ufa2d",
+         "\ufb00"-"\ufb06",
+         "\ufb13"-"\ufb17",
+         "\ufb1d"-"\ufb28",
+         "\ufb2a"-"\ufb36",
+         "\ufb38"-"\ufb3c",
+         "\ufb3e",
+         "\ufb40"-"\ufb41",
+         "\ufb43"-"\ufb44",
+         "\ufb46"-"\ufbb1",
+         "\ufbd3"-"\ufd3d",
+         "\ufd50"-"\ufd8f",
+         "\ufd92"-"\ufdc7",
+         "\ufdf0"-"\ufdfb",
+         "\ufe20"-"\ufe23",
+         "\ufe33"-"\ufe34",
+         "\ufe4d"-"\ufe4f",
+         "\ufe69",
+         "\ufe70"-"\ufe72",
+         "\ufe74",
+         "\ufe76"-"\ufefc",
+         "\ufeff",
+         "\uff04",
+         "\uff10"-"\uff19",
+         "\uff21"-"\uff3a",
+         "\uff3f",
+         "\uff41"-"\uff5a",
+         "\uff65"-"\uffbe",
+         "\uffc2"-"\uffc7",
+         "\uffca"-"\uffcf",
+         "\uffd2"-"\uffd7",
+         "\uffda"-"\uffdc",
+         "\uffe0"-"\uffe1",
+         "\uffe5"-"\uffe6",
+         "\ufff9"-"\ufffb"
+      ]
+  >
+}
+
+/* SEPARATORS */
+
+TOKEN :
+{
+  < LPAREN: "(" >
+| < RPAREN: ")" >
+| < LBRACE: "{" >
+| < RBRACE: "}" >
+| < LBRACKET: "[" >
+| < RBRACKET: "]" >
+| < SEMICOLON: ";" >
+| < COMMA: "," >
+| < DOT: "." >
+| < AT: "@" >
+}
+
+/* OPERATORS */
+
+TOKEN :
+{
+  < ASSIGN: "=" >
+| < 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: "<<" >
+| < PLUSASSIGN: "+=" >
+| < MINUSASSIGN: "-=" >
+| < STARASSIGN: "*=" >
+| < SLASHASSIGN: "/=" >
+| < ANDASSIGN: "&=" >
+| < ORASSIGN: "|=" >
+| < XORASSIGN: "^=" >
+| < REMASSIGN: "%=" >
+| < LSHIFTASSIGN: "<<=" >
+| < RSIGNEDSHIFTASSIGN: ">>=" >
+| < RUNSIGNEDSHIFTASSIGN: ">>>=" >
+| < ELLIPSIS: "..." >
+}
+
+/* >'s need special attention due to generics syntax. */
+TOKEN :
+{
+  < RUNSIGNEDSHIFT: ">>>" >
+  {
+     matchedToken.kind = GT;
+     ((Token.GTToken)matchedToken).realKind = RUNSIGNEDSHIFT;
+     input_stream.backup(2);
+     matchedToken.image = ">";
+  }
+| < RSIGNEDSHIFT: ">>" >
+  {
+     matchedToken.kind = GT;
+     ((Token.GTToken)matchedToken).realKind = RSIGNEDSHIFT;
+     input_stream.backup(1);
+     matchedToken.image = ">";
+  }
+| < GT: ">" >
+}
+
+
+/*****************************************
+ * THE JAVA LANGUAGE GRAMMAR STARTS HERE *
+ *****************************************/
+
+/*
+ * Program structuring syntax follows.
+ */
+
+void CompilationUnit():
+{}
+{
+  [ LOOKAHEAD( ( Annotation() )* "package" ) PackageDeclaration() ]
+  ( ImportDeclaration() )*
+  ( TypeDeclaration() )*
+  ( < "\u001a" > )?
+  ( <STUFF_TO_IGNORE: ~[]> )?
+  <EOF>
+}
+
+void PackageDeclaration():
+{}
+{
+  Modifiers() "package" Name() ";"
+}
+
+void ImportDeclaration():
+{}
+{
+  "import" [ "static" ] Name() [ "." "*" ] ";"
+}
+
+/*
+ * Modifiers. We match all modifiers in a single rule to reduce the chances of
+ * syntax errors for simple modifier mistakes. It will also enable us to give
+ * better error messages.
+ */
+
+int Modifiers():
+{
+   int modifiers = 0;
+}
+{
+ (
+  LOOKAHEAD(2)
+  (
+   "public" { modifiers |= ModifierSet.PUBLIC; }
+  |
+   "static" { modifiers |= ModifierSet.STATIC; }
+  |
+   "protected" { modifiers |= ModifierSet.PROTECTED; }
+  |
+   "private" { modifiers |= ModifierSet.PRIVATE; }
+  |
+   "final" { modifiers |= ModifierSet.FINAL; }
+  |
+   "abstract" { modifiers |= ModifierSet.ABSTRACT; }
+  |
+   "synchronized" { modifiers |= ModifierSet.SYNCHRONIZED; }
+  |
+   "native" { modifiers |= ModifierSet.NATIVE; }
+  |
+   "transient" { modifiers |= ModifierSet.TRANSIENT; }
+  |
+   "volatile" { modifiers |= ModifierSet.VOLATILE; }
+  |
+   "strictfp" { modifiers |= ModifierSet.STRICTFP; }
+  |
+   Annotation()
+  )
+ )*
+
+ {
+    return modifiers;
+ }
+}
+
+/*
+ * Declaration syntax follows.
+ */
+void TypeDeclaration():
+{
+   int modifiers;
+}
+{
+  ";"
+|
+  modifiers = Modifiers()
+  (
+     ClassOrInterfaceDeclaration(modifiers)
+   |
+     EnumDeclaration(modifiers)
+   |
+     AnnotationTypeDeclaration(modifiers)
+  )
+}
+
+
+void ClassOrInterfaceDeclaration(int modifiers):
+{
+   boolean isInterface = false;
+}
+{
+  ( "class" | "interface" { isInterface = true; } )
+  <IDENTIFIER>
+  [ TypeParameters() ]
+  [ ExtendsList(isInterface) ]
+  [ ImplementsList(isInterface) ]
+  ClassOrInterfaceBody(isInterface)
+}
+
+void ExtendsList(boolean isInterface):
+{
+   boolean extendsMoreThanOne = false;
+}
+{
+   "extends" ClassOrInterfaceType()
+   ( "," ClassOrInterfaceType() { extendsMoreThanOne = true; } )*
+   {
+      if (extendsMoreThanOne && !isInterface)
+         throw new ParseException("A class cannot extend more than one other class");
+   }
+}
+
+void ImplementsList(boolean isInterface):
+{}
+{
+   "implements" ClassOrInterfaceType()
+   ( "," ClassOrInterfaceType() )*
+   {
+      if (isInterface)
+         throw new ParseException("An interface cannot implement other interfaces");
+   }
+}
+
+void EnumDeclaration(int modifiers):
+{}
+{
+  "enum" <IDENTIFIER>
+  [ ImplementsList(false) ]
+  EnumBody()
+}
+
+void EnumBody():
+{}
+{
+   "{"
+   [ EnumConstant() ( LOOKAHEAD(2) "," EnumConstant() )* ]
+	[ "," ]
+   [ ";" ( ClassOrInterfaceBodyDeclaration(false) )* ]
+   "}"
+}
+
+void EnumConstant():
+{}
+{
+  Modifiers() <IDENTIFIER> [ Arguments() ] [ ClassOrInterfaceBody(false) ]
+}
+
+void TypeParameters():
+{}
+{
+   "<" TypeParameter() ( "," TypeParameter() )* ">"
+}
+
+void TypeParameter():
+{}
+{
+   <IDENTIFIER> [ TypeBound() ]
+}
+
+void TypeBound():
+{}
+{
+   "extends" ClassOrInterfaceType() ( "&" ClassOrInterfaceType() )*
+}
+
+void ClassOrInterfaceBody(boolean isInterface):
+{}
+{
+  "{" ( ClassOrInterfaceBodyDeclaration(isInterface) )* "}"
+}
+
+void ClassOrInterfaceBodyDeclaration(boolean isInterface):
+{
+   boolean isNestedInterface = false;
+   int modifiers;
+}
+{
+  LOOKAHEAD(2)
+  Initializer()
+  {
+     if (isInterface)
+        throw new ParseException("An interface cannot have initializers");
+  }
+|
+  modifiers = Modifiers() // Just get all the modifiers out of the way. If you want to do
+              // more checks, pass the modifiers down to the member
+  (
+      ClassOrInterfaceDeclaration(modifiers)
+    |
+      EnumDeclaration(modifiers)
+    |
+      LOOKAHEAD( [ TypeParameters() ] <IDENTIFIER> "(" )
+      ConstructorDeclaration()
+    |
+      LOOKAHEAD( Type() <IDENTIFIER> ( "[" "]" )* ( "," | "=" | ";" ) )
+      FieldDeclaration(modifiers)
+    |
+      MethodDeclaration(modifiers)
+  )
+|
+  ";"
+}
+
+void FieldDeclaration(int modifiers):
+{}
+{
+  // Modifiers are already matched in the caller
+  Type() VariableDeclarator() ( "," VariableDeclarator() )* ";"
+}
+
+void VariableDeclarator():
+{}
+{
+  VariableDeclaratorId() [ "=" VariableInitializer() ]
+}
+
+void VariableDeclaratorId():
+{}
+{
+  <IDENTIFIER> ( "[" "]" )*
+}
+
+void VariableInitializer():
+{}
+{
+  ArrayInitializer()
+|
+  Expression()
+}
+
+void ArrayInitializer():
+{}
+{
+  "{" [ VariableInitializer() ( LOOKAHEAD(2) "," VariableInitializer() )* ] [ "," ] "}"
+}
+
+void MethodDeclaration(int modifiers):
+{}
+{
+  // Modifiers already matched in the caller!
+  [ TypeParameters() ]
+  ResultType()
+  MethodDeclarator() [ "throws" NameList() ]
+  ( Block() | ";" )
+}
+
+void MethodDeclarator():
+{}
+{
+  <IDENTIFIER> FormalParameters() ( "[" "]" )*
+}
+
+void FormalParameters():
+{}
+{
+  "(" [ FormalParameter() ( "," FormalParameter() )* ] ")"
+}
+
+void FormalParameter():
+{}
+{
+  Modifiers() Type() [ "..." ] VariableDeclaratorId()
+}
+
+void ConstructorDeclaration():
+{}
+{
+  [ TypeParameters() ]
+  // Modifiers matched in the caller
+  <IDENTIFIER> FormalParameters() [ "throws" NameList() ]
+  "{"
+    [ LOOKAHEAD(ExplicitConstructorInvocation())
+         ExplicitConstructorInvocation()
+    ]
+    ( BlockStatement() )*
+  "}"
+}
+
+void ExplicitConstructorInvocation():
+{}
+{
+  ( <IDENTIFIER> "." )* [ LOOKAHEAD(2) "this" "." ]
+  [ TypeArguments() ] ("this"|"super") Arguments() ";"
+}
+
+void Initializer():
+{}
+{
+  [ "static" ] Block()
+}
+
+
+/*
+ * Type, name and expression syntax follows.
+ */
+
+void Type():
+{}
+{
+   LOOKAHEAD(2) ReferenceType()
+ |
+   PrimitiveType()
+}
+
+void ReferenceType():
+{}
+{
+   PrimitiveType() ( LOOKAHEAD(2) "[" "]" )+
+  |
+   ( ClassOrInterfaceType() ) ( LOOKAHEAD(2) "[" "]" )*
+}
+
+void ClassOrInterfaceType():
+{}
+{
+  <IDENTIFIER> [ LOOKAHEAD(2) TypeArguments() ]
+  ( LOOKAHEAD(2) "." <IDENTIFIER> [ LOOKAHEAD(2) TypeArguments() ] )*
+}
+
+void TypeArguments():
+{}
+{
+   "<" TypeArgument() ( "," TypeArgument() )* ">"
+}
+
+void TypeArgument():
+{}
+{
+   ReferenceType()
+ |
+   "?" [ WildcardBounds() ]
+}
+
+void WildcardBounds():
+{}
+{
+   "extends" ReferenceType()
+ |
+   "super" ReferenceType()
+}
+
+
+void PrimitiveType():
+{}
+{
+  "boolean"
+|
+  "char"
+|
+  "byte"
+|
+  "short"
+|
+  "int"
+|
+  "long"
+|
+  "float"
+|
+  "double"
+}
+
+void ResultType():
+{}
+{
+  "void"
+|
+  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()
+  [
+    LOOKAHEAD(2)
+    AssignmentOperator() Expression()
+  ]
+}
+
+void AssignmentOperator():
+{}
+{
+  "=" | "*=" | "/=" | "%=" | "+=" | "-=" | "<<=" | ">>=" | ">>>=" | "&=" | "^=" | "|="
+}
+
+void ConditionalExpression():
+{}
+{
+  ConditionalOrExpression() [ "?" Expression() ":" Expression() ]
+}
+
+void ConditionalOrExpression():
+{}
+{
+  ConditionalAndExpression() ( "||" ConditionalAndExpression() )*
+}
+
+void ConditionalAndExpression():
+{}
+{
+  InclusiveOrExpression() ( "&&" InclusiveOrExpression() )*
+}
+
+void InclusiveOrExpression():
+{}
+{
+  ExclusiveOrExpression() ( "|" ExclusiveOrExpression() )*
+}
+
+void ExclusiveOrExpression():
+{}
+{
+  AndExpression() ( "^" AndExpression() )*
+}
+
+void AndExpression():
+{}
+{
+  EqualityExpression() ( "&" EqualityExpression() )*
+}
+
+void EqualityExpression():
+{}
+{
+  InstanceOfExpression() ( ( "==" | "!=" ) InstanceOfExpression() )*
+}
+
+void InstanceOfExpression():
+{}
+{
+  RelationalExpression() [ "instanceof" Type() ]
+}
+
+void RelationalExpression():
+{}
+{
+  ShiftExpression() ( ( "<" | ">" | "<=" | ">=" ) ShiftExpression() )*
+}
+
+void ShiftExpression():
+{}
+{
+  AdditiveExpression() ( ( "<<" | RSIGNEDSHIFT() | RUNSIGNEDSHIFT() ) AdditiveExpression() )*
+}
+
+void AdditiveExpression():
+{}
+{
+  MultiplicativeExpression() ( ( "+" | "-" ) MultiplicativeExpression() )*
+}
+
+void MultiplicativeExpression():
+{}
+{
+  UnaryExpression() ( ( "*" | "/" | "%" ) UnaryExpression() )*
+}
+
+void UnaryExpression():
+{}
+{
+  ( "+" | "-" ) UnaryExpression()
+|
+  PreIncrementExpression()
+|
+  PreDecrementExpression()
+|
+  UnaryExpressionNotPlusMinus()
+}
+
+void PreIncrementExpression():
+{}
+{
+  "++" PrimaryExpression()
+}
+
+void PreDecrementExpression():
+{}
+{
+  "--" PrimaryExpression()
+}
+
+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("(" Type() "[")
+  "(" Type() "[" "]"
+|
+  "(" Type() ")" ( "~" | "!" | "(" | <IDENTIFIER> | "this" | "super" | "new" | Literal() )
+}
+
+void PostfixExpression():
+{}
+{
+  PrimaryExpression() [ "++" | "--" ]
+}
+
+void CastExpression():
+{}
+{
+  LOOKAHEAD("(" PrimitiveType())
+  "(" Type() ")" UnaryExpression()
+|
+  "(" Type() ")" UnaryExpressionNotPlusMinus()
+}
+
+void PrimaryExpression():
+{}
+{
+  PrimaryPrefix() ( LOOKAHEAD(2) PrimarySuffix() )*
+}
+
+void MemberSelector():
+{}
+{
+  "." TypeArguments() <IDENTIFIER>
+}
+
+void PrimaryPrefix():
+{}
+{
+  Literal()
+|
+  LOOKAHEAD( ( <IDENTIFIER> "." )* "this" )
+  ( <IDENTIFIER> "." )*
+  "this"
+|
+  "super" "." <IDENTIFIER>
+|
+  "(" Expression() ")"
+|
+  AllocationExpression()
+|
+  LOOKAHEAD( ResultType() "." "class" )
+  ResultType() "." "class"
+|
+  Name()
+}
+
+void PrimarySuffix():
+{}
+{
+  LOOKAHEAD("." "super" ".")
+  "." "super"
+|
+  LOOKAHEAD("." "this")
+  "." "this"
+|
+  LOOKAHEAD(2)
+  "." AllocationExpression()
+|
+  LOOKAHEAD(3)
+  MemberSelector()
+|
+  "[" Expression() "]"
+|
+  "." <IDENTIFIER>
+|
+  Arguments()
+}
+
+void Literal():
+{}
+{
+  <INTEGER_LITERAL>
+|
+  <FLOATING_POINT_LITERAL>
+|
+  <CHARACTER_LITERAL>
+|
+  <STRING_LITERAL>
+|
+  BooleanLiteral()
+|
+  NullLiteral()
+}
+
+void BooleanLiteral():
+{}
+{
+  "true"
+|
+  "false"
+}
+
+void NullLiteral():
+{}
+{
+  "null"
+}
+
+void Arguments():
+{}
+{
+  "(" [ ArgumentList() ] ")"
+}
+
+void ArgumentList():
+{}
+{
+  Expression() ( "," Expression() )*
+}
+
+void AllocationExpression():
+{}
+{
+  LOOKAHEAD(2)
+  "new" PrimitiveType() ArrayDimsAndInits()
+|
+  "new" ClassOrInterfaceType() [ TypeArguments() ]
+    (
+      ArrayDimsAndInits()
+    |
+      Arguments() [ ClassOrInterfaceBody(false) ]
+    )
+}
+
+/*
+ * 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()
+|
+  AssertStatement()
+|
+  Block()
+|
+  EmptyStatement()
+|
+  StatementExpression() ";"
+|
+  SwitchStatement()
+|
+  IfStatement()
+|
+  WhileStatement()
+|
+  DoStatement()
+|
+  ForStatement()
+|
+  BreakStatement()
+|
+  ContinueStatement()
+|
+  ReturnStatement()
+|
+  ThrowStatement()
+|
+  SynchronizedStatement()
+|
+  TryStatement()
+}
+
+void AssertStatement():
+{}
+{
+  "assert" Expression() [ ":" Expression() ] ";"
+}
+
+void LabeledStatement():
+{}
+{
+  <IDENTIFIER> ":" Statement()
+}
+
+void Block():
+{}
+{
+  "{" ( BlockStatement() )* "}"
+}
+
+void BlockStatement():
+{}
+{
+  LOOKAHEAD( Modifiers() Type() <IDENTIFIER> )
+  LocalVariableDeclaration() ";"
+|
+  Statement()
+|
+  ClassOrInterfaceDeclaration(0)
+}
+
+void LocalVariableDeclaration():
+{}
+{
+  Modifiers() 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()
+  [
+    "++"
+  |
+    "--"
+  |
+    AssignmentOperator() Expression()
+  ]
+}
+
+void SwitchStatement():
+{}
+{
+  "switch" "(" Expression() ")" "{"
+    ( SwitchLabel() ( BlockStatement() )* )*
+  "}"
+}
+
+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" "(" Expression() ")" Statement() [ LOOKAHEAD(1) "else" Statement() ]
+}
+
+void WhileStatement():
+{}
+{
+  "while" "(" Expression() ")" Statement()
+}
+
+void DoStatement():
+{}
+{
+  "do" Statement() "while" "(" Expression() ")" ";"
+}
+
+void ForStatement():
+{}
+{
+  "for" "("
+
+  (
+      LOOKAHEAD(Modifiers() Type() <IDENTIFIER> ":")
+      Modifiers() Type() <IDENTIFIER> ":" Expression() 
+    |
+     [ ForInit() ] ";" [ Expression() ] ";" [ ForUpdate() ]
+  )
+
+  ")" Statement()
+}
+
+void ForInit():
+{}
+{
+  LOOKAHEAD( Modifiers() Type() <IDENTIFIER> )
+  LocalVariableDeclaration()
+|
+  StatementExpressionList()
+}
+
+void StatementExpressionList():
+{}
+{
+  StatementExpression() ( "," StatementExpression() )*
+}
+
+void ForUpdate():
+{}
+{
+  StatementExpressionList()
+}
+
+void BreakStatement():
+{}
+{
+  "break" [ <IDENTIFIER> ] ";"
+}
+
+void ContinueStatement():
+{}
+{
+  "continue" [ <IDENTIFIER> ] ";"
+}
+
+void ReturnStatement():
+{}
+{
+  "return" [ Expression() ] ";"
+}
+
+void ThrowStatement():
+{}
+{
+  "throw" Expression() ";"
+}
+
+void SynchronizedStatement():
+{}
+{
+  "synchronized" "(" Expression() ")" Block()
+}
+
+void TryStatement():
+/*
+ * Semantic check required here to make sure that at least one
+ * finally/catch is present.
+ */
+{}
+{
+  "try" Block()
+  ( "catch" "(" FormalParameter() ")" Block() )*
+  [ "finally" Block() ]
+}
+
+/* We use productions to match >>>, >> and > so that we can keep the
+ * type declaration syntax with generics clean
+ */
+
+void RUNSIGNEDSHIFT():
+{}
+{
+  ( LOOKAHEAD({ getToken(1).kind == GT &&
+                ((Token.GTToken)getToken(1)).realKind == RUNSIGNEDSHIFT} )
+   ">" ">" ">"
+  )
+}
+
+void RSIGNEDSHIFT():
+{}
+{
+  ( LOOKAHEAD({ getToken(1).kind == GT &&
+                ((Token.GTToken)getToken(1)).realKind == RSIGNEDSHIFT} )
+  ">" ">"
+  )
+}
+
+/* Annotation syntax follows. */
+
+void Annotation():
+{}
+{
+   LOOKAHEAD( "@" Name() "(" ( <IDENTIFIER> "=" | ")" ))
+   NormalAnnotation()
+ |
+   LOOKAHEAD( "@" Name() "(" )
+   SingleMemberAnnotation()
+ |
+   MarkerAnnotation()
+}
+
+void NormalAnnotation():
+{}
+{
+   "@" Name() "(" [ MemberValuePairs() ] ")"
+}
+
+void MarkerAnnotation():
+{}
+{
+  "@" Name()
+}
+
+void SingleMemberAnnotation():
+{}
+{
+  "@" Name() "(" MemberValue() ")"
+}
+
+void MemberValuePairs():
+{}
+{
+   MemberValuePair() ( "," MemberValuePair() )*
+}
+
+void MemberValuePair():
+{}
+{
+    <IDENTIFIER> "=" MemberValue()
+}
+
+void MemberValue():
+{}
+{
+   Annotation()
+ |
+   MemberValueArrayInitializer()
+ |
+   ConditionalExpression()
+}
+
+void  MemberValueArrayInitializer():
+{}
+{
+  "{" MemberValue() ( LOOKAHEAD(2) "," MemberValue() )* [ "," ] "}"
+}
+
+
+/* Annotation Types. */
+
+void AnnotationTypeDeclaration(int modifiers):
+{}
+{
+  "@" "interface" <IDENTIFIER> AnnotationTypeBody()
+}
+
+void AnnotationTypeBody():
+{}
+{
+  "{" ( AnnotationTypeMemberDeclaration() )* "}"
+}
+
+void AnnotationTypeMemberDeclaration():
+{
+   int modifiers;
+}
+{
+ modifiers = Modifiers()
+ (
+   LOOKAHEAD(Type() <IDENTIFIER> "(")
+   Type() <IDENTIFIER> "(" ")" [ DefaultValue() ] ";"
+  |
+   ClassOrInterfaceDeclaration(modifiers)
+  |
+   EnumDeclaration(modifiers)
+  |
+   AnnotationTypeDeclaration(modifiers)
+  |
+   FieldDeclaration(modifiers)
+ )
+ |
+   ( ";" )
+}
+
+void DefaultValue():
+{}
+{
+  "default" MemberValue()
+}
diff --git a/tools/javacc-4.0/examples/JavaGrammars/1.5/Main.java b/tools/javacc-4.0/examples/JavaGrammars/1.5/Main.java
new file mode 100644
index 0000000000000000000000000000000000000000..bfd0939d6c9990fb334a07e320afb75ff054defe
--- /dev/null
+++ b/tools/javacc-4.0/examples/JavaGrammars/1.5/Main.java
@@ -0,0 +1,48 @@
+import java.io.*;
+
+class Main
+{
+   private static int parseFilesFromFileList(String fileName)
+   {
+      LineNumberReader str = null;
+      int cnt = 0;
+      try
+      {
+         str = new LineNumberReader(new FileReader(new File(fileName))
+);
+         String s;
+
+         while ((s = str.readLine()) != null)
+         {
+            try
+            {
+               cnt++;
+               System.out.println("Parsing: " + s);
+               new JavaParser(s).CompilationUnit();
+            }
+            catch(ParseException e) { e.printStackTrace(); }
+            catch(TokenMgrError tme) { tme.printStackTrace(); }
+         }
+      }
+      catch(Exception e) { e.printStackTrace(); }
+      finally { if (str != null) try { str.close(); } catch(Exception e) {}  }
+
+      return cnt;
+   }
+
+   public static void main(String[] args) throws Throwable
+   {
+      int cnt = 1;
+      long l = System.currentTimeMillis();
+      JavaParser parser;
+      if (args[0].charAt(0) == '@')
+      {
+         cnt = parseFilesFromFileList(args[0].substring(1));
+      }
+      else
+      {
+         JavaParser.main(args);
+      }
+      System.out.println("Parsed " + cnt + " files in: " + (System.currentTimeMillis() - l));
+   }
+}
diff --git a/tools/javacc-4.0/examples/JavaGrammars/1.5/README b/tools/javacc-4.0/examples/JavaGrammars/1.5/README
new file mode 100644
index 0000000000000000000000000000000000000000..dd16a4bf4f86e1efe7b30a588a05cbaee521522e
--- /dev/null
+++ b/tools/javacc-4.0/examples/JavaGrammars/1.5/README
@@ -0,0 +1,34 @@
+
+This directory contains the JavaCC grammar for parsing (the proposed)
+JDK 1.5 Java language syntax. It handles generics, new for loops, static
+imports and annotation types.
+
+BUILDING
+--------
+
+Just run
+
+   ant
+
+in this directory and it will build the parser.
+
+
+RUNNING
+-------
+
+You can run the parser directly using
+
+   java JavaParser <fileName>
+
+or there is a new Main class that accepts @<fileName> where the
+file with <fileName> contains list of files one per line:
+
+   java Main @<fileName>
+
+REPORTING BUGS
+--------------
+
+If you find bugs in the grammar, please file an issue at
+javacc.dev.java.net, by logging in and clicking on the 'Issue Tracking'
+link on the navigation bar on the left side. You can also send email to:
+sreeni@viswanadha.net.
diff --git a/tools/javacc-4.0/examples/JavaGrammars/1.5/Test.java b/tools/javacc-4.0/examples/JavaGrammars/1.5/Test.java
new file mode 100644
index 0000000000000000000000000000000000000000..3f45a9ec336493d9d2bb7635c32ae36352e9d556
--- /dev/null
+++ b/tools/javacc-4.0/examples/JavaGrammars/1.5/Test.java
@@ -0,0 +1,15 @@
+import java.io.*;
+
+class Test
+{
+   public static void main(String[] args) throws Exception
+   {
+      Reader fr = null;
+      if (args.length == 2)
+         fr = new InputStreamReader(new FileInputStream(new File(args[0])), args[1]);
+      else
+         fr = new InputStreamReader(new FileInputStream(new File(args[0])));
+      JavaParser jp = new JavaParser(fr);
+      jp.CompilationUnit();
+   }
+}
diff --git a/tools/javacc-4.0/examples/JavaGrammars/1.5/Token.java b/tools/javacc-4.0/examples/JavaGrammars/1.5/Token.java
new file mode 100644
index 0000000000000000000000000000000000000000..8d25ba6b8f87d5e5ad24f5d19043428ca4856979
--- /dev/null
+++ b/tools/javacc-4.0/examples/JavaGrammars/1.5/Token.java
@@ -0,0 +1,87 @@
+/* Generated By:JavaCC: Do not edit this line. Token.java Version 3.0 */
+/**
+ * Describes the input token stream.
+ */
+
+public class Token {
+
+  /**
+   * An integer that describes the kind of this token.  This numbering
+   * system is determined by JavaCCParser, and a table of these numbers is
+   * stored in the file ...Constants.java.
+   */
+  public int kind;
+
+  /**
+   * beginLine and beginColumn describe the position of the first character
+   * of this token; endLine and endColumn describe the position of the
+   * last character of this token.
+   */
+  public int beginLine, beginColumn, endLine, endColumn;
+
+  /**
+   * The string image of the token.
+   */
+  public String image;
+
+  /**
+   * A reference to the next regular (non-special) token from the input
+   * stream.  If this is the last token from the input stream, or if the
+   * token manager has not read tokens beyond this one, this field is
+   * set to null.  This is true only if this token is also a regular
+   * token.  Otherwise, see below for a description of the contents of
+   * this field.
+   */
+  public Token next;
+
+  /**
+   * This field is used to access special tokens that occur prior to this
+   * token, but after the immediately preceding regular (non-special) token.
+   * If there are no such special tokens, this field is set to null.
+   * When there are more than one such special token, this field refers
+   * to the last of these special tokens, which in turn refers to the next
+   * previous special token through its specialToken field, and so on
+   * until the first special token (whose specialToken field is null).
+   * The next fields of special tokens refer to other special tokens that
+   * immediately follow it (without an intervening regular token).  If there
+   * is no such token, this field is null.
+   */
+  public Token specialToken;
+
+  /**
+   * Returns the image.
+   */
+  public String toString()
+  {
+     return image;
+  }
+
+  /**
+   * Returns a new Token object, by default. However, if you want, you
+   * can create and return subclass objects based on the value of ofKind.
+   * Simply add the cases to the switch for all those special cases.
+   * For example, if you have a subclass of Token called IDToken that
+   * you want to create if ofKind is ID, simlpy add something like :
+   *
+   *    case MyParserConstants.ID : return new IDToken();
+   *
+   * to the following switch statement. Then you can cast matchedToken
+   * variable to the appropriate type and use it in your lexical actions.
+   */
+  public static final Token newToken(int ofKind)
+  {
+     switch(ofKind)
+     {
+       default : return new Token();
+       case JavaParserConstants.RUNSIGNEDSHIFT:
+       case JavaParserConstants.RSIGNEDSHIFT:
+       case JavaParserConstants.GT:
+          return new GTToken();
+     }
+  }
+
+  public static class GTToken extends Token
+  {
+     int realKind = JavaParserConstants.GT;
+  }
+}
diff --git a/tools/javacc-4.0/examples/JavaGrammars/1.5/build.xml b/tools/javacc-4.0/examples/JavaGrammars/1.5/build.xml
new file mode 100644
index 0000000000000000000000000000000000000000..4f0ab1a86b3690756ec2c2a5d22181ca2d746cfc
--- /dev/null
+++ b/tools/javacc-4.0/examples/JavaGrammars/1.5/build.xml
@@ -0,0 +1,60 @@
+<?xml version='1.0' encoding='ISO-8859-1' ?>
+
+<project name="Java 1.5 Parser" default="compile-and-test" basedir=".">
+  <property name="version"
+            value="1.0">
+  </property>
+  <property name="javacc.root"
+            value="../../../">
+  </property>
+  <property name="debug_parser"
+            value="false">
+  </property>
+  <property name="debug_scanner"
+            value="false">
+  </property>
+
+  <target name="compile-and-test" depends="compile">
+     <exec executable="java">
+           <arg value="-classpath"/>
+           <arg value="."/>
+           <arg value="JavaParser"/>
+           <arg value="JavaParser.java"/>
+     </exec>
+  </target>
+
+  <target name="compile" depends="generated-files">
+    <javac srcdir="."
+           destdir="." >
+    </javac>
+  </target>
+
+  <target name="clean">
+    <delete>
+      <fileset dir=".">
+         <include name="JavaParser.java"/>
+         <include name="JavaParserTokenManager.java"/>
+         <include name="JavaParserConstants.java"/>
+         <include name="*CharStream*.java"/>
+         <include name="TokenMgrError.java"/>
+         <include name="ParseException.java"/>
+         <include name="*.class"/>
+      </fileset>
+    </delete>
+  </target>
+
+  <target name="parser-files-init">
+        <uptodate property="parser.gen"
+                  targetfile="Java1.5.jj">
+            <srcfiles dir="." includes="JavaParser.java"/>
+        </uptodate>
+  </target>
+
+  <target name="generated-files" depends="parser-files-init" if="parser.gen">
+     <exec executable="${javacc.root}/bin/javacc" >
+           <arg value="-DEBUG_PARSER=${debug_parser}"/>
+           <arg value="-DEBUG_TOKEN_MANAGER=${debug_scanner}"/>
+           <arg value="Java1.5.jj"/>
+     </exec>
+  </target>
+</project>
diff --git a/tools/javacc-4.0/examples/JavaGrammars/Java1.0.2.jj b/tools/javacc-4.0/examples/JavaGrammars/Java1.0.2.jj
new file mode 100644
index 0000000000000000000000000000000000000000..b5e6e0429ffc5112086a222ec525575c31e1876d
--- /dev/null
+++ b/tools/javacc-4.0/examples/JavaGrammars/Java1.0.2.jj
@@ -0,0 +1,963 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+
+options {
+  JAVA_UNICODE_ESCAPE = true;
+}
+
+PARSER_BEGIN(JavaParser)
+
+public class JavaParser {
+
+  public static void main(String args[]) {
+    JavaParser parser;
+    if (args.length == 0) {
+      System.out.println("Java Parser Version 1.0.2:  Reading from standard input . . .");
+      parser = new JavaParser(System.in);
+    } else if (args.length == 1) {
+      System.out.println("Java Parser Version 1.0.2:  Reading from file " + args[0] + " . . .");
+      try {
+        parser = new JavaParser(new java.io.FileInputStream(args[0]));
+      } catch (java.io.FileNotFoundException e) {
+        System.out.println("Java Parser Version 1.0.2:  File " + args[0] + " not found.");
+        return;
+      }
+    } else {
+      System.out.println("Java Parser Version 1.0.2:  Usage is one of:");
+      System.out.println("         java JavaParser < inputfile");
+      System.out.println("OR");
+      System.out.println("         java JavaParser inputfile");
+      return;
+    }
+    try {
+      parser.CompilationUnit();
+      System.out.println("Java Parser Version 1.0.2:  Java program parsed successfully.");
+    } catch (ParseException e) {
+      System.out.println("Java Parser Version 1.0.2:  Encountered errors during parse.");
+    }
+  }
+
+}
+
+PARSER_END(JavaParser)
+
+
+SKIP : /* WHITE SPACE */
+{
+  " "
+| "\t"
+| "\n"
+| "\r"
+| "\f"
+}
+
+SPECIAL_TOKEN : /* COMMENTS */
+{
+  <SINGLE_LINE_COMMENT: "//" (~["\n","\r"])* ("\n"|"\r"|"\r\n")>
+| <FORMAL_COMMENT: "/**" (~["*"])* "*" ("*" | (~["*","/"] (~["*"])* "*"))* "/">
+| <MULTI_LINE_COMMENT: "/*" (~["*"])* "*" ("*" | (~["*","/"] (~["*"])* "*"))* "/">
+}
+
+TOKEN : /* RESERVED WORDS AND LITERALS */
+{
+  < 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" >
+}
+
+TOKEN : /* LITERALS */
+{
+  < 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"]
+            )
+          )
+      )*
+      "\""
+  >
+}
+
+TOKEN : /* IDENTIFIERS */
+{
+  < 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"
+      ]
+  >
+}
+
+TOKEN : /* SEPARATORS */
+{
+  < LPAREN: "(" >
+| < RPAREN: ")" >
+| < LBRACE: "{" >
+| < RBRACE: "}" >
+| < LBRACKET: "[" >
+| < RBRACKET: "]" >
+| < SEMICOLON: ";" >
+| < COMMA: "," >
+| < DOT: "." >
+}
+
+TOKEN : /* OPERATORS */
+{
+  < 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() ";"
+}
+
+void ImportDeclaration() :
+{}
+{
+  "import" Name() [ "." "*" ] ";"
+}
+
+void TypeDeclaration() :
+{}
+{
+  LOOKAHEAD( ( "abstract" | "final" | "public" )* "class" )
+  ClassDeclaration()
+|
+  InterfaceDeclaration()
+|
+  ";"
+}
+
+
+/*
+ * Declaration syntax follows.
+ */
+
+void ClassDeclaration() :
+{}
+{
+  ( "abstract" | "final" | "public" )*
+  "class" <IDENTIFIER> [ "extends" Name() ] [ "implements" NameList() ]
+  "{" ( ClassBodyDeclaration() )* "}"
+}
+
+void ClassBodyDeclaration() :
+{}
+{
+  LOOKAHEAD(2)
+  StaticInitializer()
+|
+  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" | "public" )*
+  "interface" <IDENTIFIER> [ "extends" NameList() ]
+  "{" ( InterfaceMemberDeclaration() )* "}"
+}
+
+void InterfaceMemberDeclaration() :
+{}
+{
+  LOOKAHEAD( MethodDeclarationLookahead() )
+  MethodDeclaration()
+|
+  FieldDeclaration()
+}
+
+void FieldDeclaration() :
+{}
+{
+  ( "public" | "protected" | "private" | "static" | "final" | "transient" | "volatile" )*
+  Type() VariableDeclarator() ( "," VariableDeclarator() )* ";"
+}
+
+void VariableDeclarator() :
+{}
+{
+  VariableDeclaratorId() [ "=" VariableInitializer() ]
+}
+
+void VariableDeclaratorId() :
+{}
+{
+  <IDENTIFIER> ( "[" "]" )*
+}
+
+void VariableInitializer() :
+{}
+{
+  "{" [ VariableInitializer() ( LOOKAHEAD(2) "," VariableInitializer() )* ] [ "," ] "}"
+|
+  Expression()
+}
+
+void MethodDeclaration() :
+{}
+{
+  ( "public" | "protected" | "private" | "static" | "abstract" | "final" | "native" | "synchronized" )*
+  ResultType() MethodDeclarator() [ "throws" NameList() ]
+  ( Block() | ";" )
+}
+
+void MethodDeclarator() :
+{}
+{
+  <IDENTIFIER> FormalParameters() ( "[" "]" )*
+}
+
+void FormalParameters() :
+{}
+{
+  "(" [ FormalParameter() ( "," FormalParameter() )* ] ")"
+}
+
+void FormalParameter() :
+{}
+{
+  Type() VariableDeclaratorId()
+}
+
+void ConstructorDeclaration() :
+{}
+{
+  [ "public" | "protected" | "private" ]
+  <IDENTIFIER> FormalParameters() [ "throws" NameList() ]
+  "{" [ LOOKAHEAD(2) ExplicitConstructorInvocation() ] ( BlockStatement() )* "}"
+}
+
+void ExplicitConstructorInvocation() :
+{}
+{
+  "this" Arguments() ";"
+|
+  "super" Arguments() ";"
+}
+
+void StaticInitializer() :
+{}
+{
+  "static" Block()
+}
+
+
+/*
+ * Type, name and expression syntax follows.
+ */
+
+void Type() :
+{}
+{
+  ( PrimitiveType() | Name() ) ( "[" "]" )*
+}
+
+void PrimitiveType() :
+{}
+{
+  "boolean"
+|
+  "char"
+|
+  "byte"
+|
+  "short"
+|
+  "int"
+|
+  "long"
+|
+  "float"
+|
+  "double"
+}
+
+void ResultType() :
+{}
+{
+  "void"
+|
+  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() :
+{}
+{
+  LOOKAHEAD( PrimaryExpression() AssignmentOperator() )
+  Assignment()
+|
+  ConditionalExpression()
+}
+
+void Assignment() :
+{}
+{
+  PrimaryExpression() AssignmentOperator() Expression()
+}
+
+void AssignmentOperator() :
+{}
+{
+  "=" | "*=" | "/=" | "%=" | "+=" | "-=" | "<<=" | ">>=" | ">>>=" | "&=" | "^=" | "|="
+}
+
+void ConditionalExpression() :
+{}
+{
+  ConditionalOrExpression() [ "?" Expression() ":" ConditionalExpression() ]
+}
+
+void ConditionalOrExpression() :
+{}
+{
+  ConditionalAndExpression() ( "||" ConditionalAndExpression() )*
+}
+
+void ConditionalAndExpression() :
+{}
+{
+  InclusiveOrExpression() ( "&&" InclusiveOrExpression() )*
+}
+
+void InclusiveOrExpression() :
+{}
+{
+  ExclusiveOrExpression() ( "|" ExclusiveOrExpression() )*
+}
+
+void ExclusiveOrExpression() :
+{}
+{
+  AndExpression() ( "^" AndExpression() )*
+}
+
+void AndExpression() :
+{}
+{
+  EqualityExpression() ( "&" EqualityExpression() )*
+}
+
+void EqualityExpression() :
+{}
+{
+  InstanceOfExpression() ( ( "==" | "!=" ) InstanceOfExpression() )*
+}
+
+void InstanceOfExpression() :
+{}
+{
+  RelationalExpression() [ "instanceof" Type() ]
+}
+
+void RelationalExpression() :
+{}
+{
+  ShiftExpression() ( ( "<" | ">" | "<=" | ">=" ) ShiftExpression() )*
+}
+
+void ShiftExpression() :
+{}
+{
+  AdditiveExpression() ( ( "<<" | ">>" | ">>>" ) AdditiveExpression() )*
+}
+
+void AdditiveExpression() :
+{}
+{
+  MultiplicativeExpression() ( ( "+" | "-" ) MultiplicativeExpression() )*
+}
+
+void MultiplicativeExpression() :
+{}
+{
+  UnaryExpression() ( ( "*" | "/" | "%" ) UnaryExpression() )*
+}
+
+void UnaryExpression() :
+{}
+{
+  ( "+" | "-" ) UnaryExpression()
+|
+  PreIncrementExpression()
+|
+  PreDecrementExpression()
+|
+  UnaryExpressionNotPlusMinus()
+}
+
+void PreIncrementExpression() :
+{}
+{
+  "++" PrimaryExpression()
+}
+
+void PreDecrementExpression() :
+{}
+{
+  "--" PrimaryExpression()
+}
+
+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() [ "++" | "--" ]
+}
+
+void CastExpression() :
+{}
+{
+  LOOKAHEAD(2)
+  "(" PrimitiveType() ( "[" "]" )* ")" UnaryExpression()
+|
+  "(" Name() ( "[" "]" )* ")" UnaryExpressionNotPlusMinus()
+}
+
+void PrimaryExpression() :
+{}
+{
+  PrimaryPrefix() ( PrimarySuffix() )*
+}
+
+void PrimaryPrefix() :
+{}
+{
+  Literal()
+|
+  Name()
+|
+  "this"
+|
+  "super" "." <IDENTIFIER>
+|
+  "(" Expression() ")"
+|
+  AllocationExpression()
+}
+
+void PrimarySuffix() :
+{}
+{
+  "[" Expression() "]"
+|
+  "." <IDENTIFIER>
+|
+  Arguments()
+}
+
+void Literal() :
+{}
+{
+  <INTEGER_LITERAL>
+|
+  <FLOATING_POINT_LITERAL>
+|
+  <CHARACTER_LITERAL>
+|
+  <STRING_LITERAL>
+|
+  BooleanLiteral()
+|
+  NullLiteral()
+}
+
+void BooleanLiteral() :
+{}
+{
+  "true"
+|
+  "false"
+}
+
+void NullLiteral() :
+{}
+{
+  "null"
+}
+
+void Arguments() :
+{}
+{
+  "(" [ ArgumentList() ] ")"
+}
+
+void ArgumentList() :
+{}
+{
+  Expression() ( "," Expression() )*
+}
+
+void AllocationExpression() :
+{}
+{
+  LOOKAHEAD(2)
+  "new" PrimitiveType() ArrayDimensions()
+|
+  "new" Name() ( Arguments() | ArrayDimensions() )
+}
+
+/*
+ * The second LOOKAHEAD specification below is to parse to PrimarySuffix
+ * if there is an expression between the "[...]".
+ */
+void ArrayDimensions() :
+{}
+{
+  ( LOOKAHEAD(2) "[" Expression() "]" )+ ( LOOKAHEAD(2) "[" "]" )*
+}
+
+
+/*
+ * Statement syntax follows.
+ */
+
+void Statement() :
+{}
+{
+  LOOKAHEAD(2)
+  LabeledStatement()
+|
+  Block()
+|
+  EmptyStatement()
+|
+  StatementExpression() ";"
+|
+  SwitchStatement()
+|
+  IfStatement()
+|
+  WhileStatement()
+|
+  DoStatement()
+|
+  ForStatement()
+|
+  BreakStatement()
+|
+  ContinueStatement()
+|
+  ReturnStatement()
+|
+  ThrowStatement()
+|
+  SynchronizedStatement()
+|
+  TryStatement()
+}
+
+void LabeledStatement() :
+{}
+{
+  <IDENTIFIER> ":" Statement()
+}
+
+void Block() :
+{}
+{
+  "{" ( BlockStatement() )* "}"
+}
+
+void BlockStatement() :
+{}
+{
+  LOOKAHEAD(Type() <IDENTIFIER>)
+  LocalVariableDeclaration() ";"
+|
+  Statement()
+}
+
+void LocalVariableDeclaration() :
+{}
+{
+  Type() VariableDeclarator() ( "," VariableDeclarator() )*
+}
+
+void EmptyStatement() :
+{}
+{
+  ";"
+}
+
+void StatementExpression() :
+/*
+ * The last expansion of this production accepts more than the legal
+ * Java expansions for StatementExpression.
+ */
+{}
+{
+  PreIncrementExpression()
+|
+  PreDecrementExpression()
+|
+  LOOKAHEAD( PrimaryExpression() AssignmentOperator() )
+  Assignment()
+|
+  PostfixExpression()
+}
+
+void SwitchStatement() :
+{}
+{
+  "switch" "(" Expression() ")" "{"
+    ( SwitchLabel() ( BlockStatement() )* )*
+  "}"
+}
+
+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" "(" Expression() ")" Statement() [ LOOKAHEAD(1) "else" Statement() ]
+}
+
+void WhileStatement() :
+{}
+{
+  "while" "(" Expression() ")" Statement()
+}
+
+void DoStatement() :
+{}
+{
+  "do" Statement() "while" "(" Expression() ")" ";"
+}
+
+void ForStatement() :
+{}
+{
+  "for" "(" [ ForInit() ] ";" [ Expression() ] ";" [ ForUpdate() ] ")" Statement()
+}
+
+void ForInit() :
+{}
+{
+  LOOKAHEAD( Type() <IDENTIFIER> )
+  LocalVariableDeclaration()
+|
+  StatementExpressionList()
+}
+
+void StatementExpressionList() :
+{}
+{
+  StatementExpression() ( "," StatementExpression() )*
+}
+
+void ForUpdate() :
+{}
+{
+  StatementExpressionList()
+}
+
+void BreakStatement() :
+{}
+{
+  "break" [ <IDENTIFIER> ] ";"
+}
+
+void ContinueStatement() :
+{}
+{
+  "continue" [ <IDENTIFIER> ] ";"
+}
+
+void ReturnStatement() :
+{}
+{
+  "return" [ Expression() ] ";"
+}
+
+void ThrowStatement() :
+{}
+{
+  "throw" Expression() ";"
+}
+
+void SynchronizedStatement() :
+{}
+{
+  "synchronized" "(" Expression() ")" Block()
+}
+
+void TryStatement() :
+/*
+ * Semantic check required here to make sure that at least one
+ * finally/catch is present.
+ */
+{}
+{
+  "try" Block()
+  ( "catch" "(" FormalParameter() ")" Block() )*
+  [ "finally" Block() ]
+}
diff --git a/tools/javacc-4.0/examples/JavaGrammars/Java1.0.2LS.jj b/tools/javacc-4.0/examples/JavaGrammars/Java1.0.2LS.jj
new file mode 100644
index 0000000000000000000000000000000000000000..06bab847621c5384fa8efd595bde7277ef902070
--- /dev/null
+++ b/tools/javacc-4.0/examples/JavaGrammars/Java1.0.2LS.jj
@@ -0,0 +1,1005 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+
+options {
+  JAVA_UNICODE_ESCAPE = true;
+}
+
+PARSER_BEGIN(JavaParser)
+
+public class JavaParser {
+
+  public static void main(String args[]) {
+    JavaParser parser;
+    if (args.length == 0) {
+      System.out.println("Java Parser Version 1.0.2:  Reading from standard input . . .");
+      parser = new JavaParser(System.in);
+    } else if (args.length == 1) {
+      System.out.println("Java Parser Version 1.0.2:  Reading from file " + args[0] + " . . .");
+      try {
+        parser = new JavaParser(new java.io.FileInputStream(args[0]));
+      } catch (java.io.FileNotFoundException e) {
+        System.out.println("Java Parser Version 1.0.2:  File " + args[0] + " not found.");
+        return;
+      }
+    } else {
+      System.out.println("Java Parser Version 1.0.2:  Usage is one of:");
+      System.out.println("         java JavaParser < inputfile");
+      System.out.println("OR");
+      System.out.println("         java JavaParser inputfile");
+      return;
+    }
+    try {
+      parser.CompilationUnit();
+      System.out.println("Java Parser Version 1.0.2:  Java program parsed successfully.");
+    } catch (ParseException e) {
+      System.out.println("Java Parser Version 1.0.2:  Encountered errors during parse.");
+    }
+  }
+
+}
+
+PARSER_END(JavaParser)
+
+
+/* WHITE SPACE */
+
+SKIP :
+{
+  " "
+| "\t"
+| "\n"
+| "\r"
+| "\f"
+}
+
+/* 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_SINGLE_LINE_COMMENT>
+MORE :
+{
+  < ~[] >
+}
+
+<IN_FORMAL_COMMENT>
+SPECIAL_TOKEN :
+{
+  <FORMAL_COMMENT: "*/" > : DEFAULT
+}
+
+<IN_MULTI_LINE_COMMENT>
+SPECIAL_TOKEN :
+{
+  <MULTI_LINE_COMMENT: "*/" > : DEFAULT
+}
+
+<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"
+      ]
+  >
+}
+
+TOKEN : /* SEPARATORS */
+{
+  < LPAREN: "(" >
+| < RPAREN: ")" >
+| < LBRACE: "{" >
+| < RBRACE: "}" >
+| < LBRACKET: "[" >
+| < RBRACKET: "]" >
+| < SEMICOLON: ";" >
+| < COMMA: "," >
+| < DOT: "." >
+}
+
+TOKEN : /* OPERATORS */
+{
+  < 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() ";"
+}
+
+void ImportDeclaration() :
+{}
+{
+  "import" Name() [ "." "*" ] ";"
+}
+
+void TypeDeclaration() :
+{}
+{
+  LOOKAHEAD( ( "abstract" | "final" | "public" )* "class" )
+  ClassDeclaration()
+|
+  InterfaceDeclaration()
+|
+  ";"
+}
+
+
+/*
+ * Declaration syntax follows.
+ */
+
+void ClassDeclaration() :
+{}
+{
+  ( "abstract" | "final" | "public" )*
+  "class" <IDENTIFIER> [ "extends" Name() ] [ "implements" NameList() ]
+  "{" ( ClassBodyDeclaration() )* "}"
+}
+
+void ClassBodyDeclaration() :
+{}
+{
+  LOOKAHEAD(2)
+  StaticInitializer()
+|
+  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" | "public" )*
+  "interface" <IDENTIFIER> [ "extends" NameList() ]
+  "{" ( InterfaceMemberDeclaration() )* "}"
+}
+
+void InterfaceMemberDeclaration() :
+{}
+{
+  LOOKAHEAD( MethodDeclarationLookahead() )
+  MethodDeclaration()
+|
+  FieldDeclaration()
+}
+
+void FieldDeclaration() :
+{}
+{
+  ( "public" | "protected" | "private" | "static" | "final" | "transient" | "volatile" )*
+  Type() VariableDeclarator() ( "," VariableDeclarator() )* ";"
+}
+
+void VariableDeclarator() :
+{}
+{
+  VariableDeclaratorId() [ "=" VariableInitializer() ]
+}
+
+void VariableDeclaratorId() :
+{}
+{
+  <IDENTIFIER> ( "[" "]" )*
+}
+
+void VariableInitializer() :
+{}
+{
+  "{" [ VariableInitializer() ( LOOKAHEAD(2) "," VariableInitializer() )* ] [ "," ] "}"
+|
+  Expression()
+}
+
+void MethodDeclaration() :
+{}
+{
+  ( "public" | "protected" | "private" | "static" | "abstract" | "final" | "native" | "synchronized" )*
+  ResultType() MethodDeclarator() [ "throws" NameList() ]
+  ( Block() | ";" )
+}
+
+void MethodDeclarator() :
+{}
+{
+  <IDENTIFIER> FormalParameters() ( "[" "]" )*
+}
+
+void FormalParameters() :
+{}
+{
+  "(" [ FormalParameter() ( "," FormalParameter() )* ] ")"
+}
+
+void FormalParameter() :
+{}
+{
+  Type() VariableDeclaratorId()
+}
+
+void ConstructorDeclaration() :
+{}
+{
+  [ "public" | "protected" | "private" ]
+  <IDENTIFIER> FormalParameters() [ "throws" NameList() ]
+  "{" [ LOOKAHEAD(2) ExplicitConstructorInvocation() ] ( BlockStatement() )* "}"
+}
+
+void ExplicitConstructorInvocation() :
+{}
+{
+  "this" Arguments() ";"
+|
+  "super" Arguments() ";"
+}
+
+void StaticInitializer() :
+{}
+{
+  "static" Block()
+}
+
+
+/*
+ * Type, name and expression syntax follows.
+ */
+
+void Type() :
+{}
+{
+  ( PrimitiveType() | Name() ) ( "[" "]" )*
+}
+
+void PrimitiveType() :
+{}
+{
+  "boolean"
+|
+  "char"
+|
+  "byte"
+|
+  "short"
+|
+  "int"
+|
+  "long"
+|
+  "float"
+|
+  "double"
+}
+
+void ResultType() :
+{}
+{
+  "void"
+|
+  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() :
+{}
+{
+  LOOKAHEAD( PrimaryExpression() AssignmentOperator() )
+  Assignment()
+|
+  ConditionalExpression()
+}
+
+void Assignment() :
+{}
+{
+  PrimaryExpression() AssignmentOperator() Expression()
+}
+
+void AssignmentOperator() :
+{}
+{
+  "=" | "*=" | "/=" | "%=" | "+=" | "-=" | "<<=" | ">>=" | ">>>=" | "&=" | "^=" | "|="
+}
+
+void ConditionalExpression() :
+{}
+{
+  ConditionalOrExpression() [ "?" Expression() ":" ConditionalExpression() ]
+}
+
+void ConditionalOrExpression() :
+{}
+{
+  ConditionalAndExpression() ( "||" ConditionalAndExpression() )*
+}
+
+void ConditionalAndExpression() :
+{}
+{
+  InclusiveOrExpression() ( "&&" InclusiveOrExpression() )*
+}
+
+void InclusiveOrExpression() :
+{}
+{
+  ExclusiveOrExpression() ( "|" ExclusiveOrExpression() )*
+}
+
+void ExclusiveOrExpression() :
+{}
+{
+  AndExpression() ( "^" AndExpression() )*
+}
+
+void AndExpression() :
+{}
+{
+  EqualityExpression() ( "&" EqualityExpression() )*
+}
+
+void EqualityExpression() :
+{}
+{
+  InstanceOfExpression() ( ( "==" | "!=" ) InstanceOfExpression() )*
+}
+
+void InstanceOfExpression() :
+{}
+{
+  RelationalExpression() [ "instanceof" Type() ]
+}
+
+void RelationalExpression() :
+{}
+{
+  ShiftExpression() ( ( "<" | ">" | "<=" | ">=" ) ShiftExpression() )*
+}
+
+void ShiftExpression() :
+{}
+{
+  AdditiveExpression() ( ( "<<" | ">>" | ">>>" ) AdditiveExpression() )*
+}
+
+void AdditiveExpression() :
+{}
+{
+  MultiplicativeExpression() ( ( "+" | "-" ) MultiplicativeExpression() )*
+}
+
+void MultiplicativeExpression() :
+{}
+{
+  UnaryExpression() ( ( "*" | "/" | "%" ) UnaryExpression() )*
+}
+
+void UnaryExpression() :
+{}
+{
+  ( "+" | "-" ) UnaryExpression()
+|
+  PreIncrementExpression()
+|
+  PreDecrementExpression()
+|
+  UnaryExpressionNotPlusMinus()
+}
+
+void PreIncrementExpression() :
+{}
+{
+  "++" PrimaryExpression()
+}
+
+void PreDecrementExpression() :
+{}
+{
+  "--" PrimaryExpression()
+}
+
+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() [ "++" | "--" ]
+}
+
+void CastExpression() :
+{}
+{
+  LOOKAHEAD(2)
+  "(" PrimitiveType() ( "[" "]" )* ")" UnaryExpression()
+|
+  "(" Name() ( "[" "]" )* ")" UnaryExpressionNotPlusMinus()
+}
+
+void PrimaryExpression() :
+{}
+{
+  PrimaryPrefix() ( PrimarySuffix() )*
+}
+
+void PrimaryPrefix() :
+{}
+{
+  Literal()
+|
+  Name()
+|
+  "this"
+|
+  "super" "." <IDENTIFIER>
+|
+  "(" Expression() ")"
+|
+  AllocationExpression()
+}
+
+void PrimarySuffix() :
+{}
+{
+  "[" Expression() "]"
+|
+  "." <IDENTIFIER>
+|
+  Arguments()
+}
+
+void Literal() :
+{}
+{
+  <INTEGER_LITERAL>
+|
+  <FLOATING_POINT_LITERAL>
+|
+  <CHARACTER_LITERAL>
+|
+  <STRING_LITERAL>
+|
+  BooleanLiteral()
+|
+  NullLiteral()
+}
+
+void BooleanLiteral() :
+{}
+{
+  "true"
+|
+  "false"
+}
+
+void NullLiteral() :
+{}
+{
+  "null"
+}
+
+void Arguments() :
+{}
+{
+  "(" [ ArgumentList() ] ")"
+}
+
+void ArgumentList() :
+{}
+{
+  Expression() ( "," Expression() )*
+}
+
+void AllocationExpression() :
+{}
+{
+  LOOKAHEAD(2)
+  "new" PrimitiveType() ArrayDimensions()
+|
+  "new" Name() ( Arguments() | ArrayDimensions() )
+}
+
+/*
+ * The second LOOKAHEAD specification below is to parse to PrimarySuffix
+ * if there is an expression between the "[...]".
+ */
+void ArrayDimensions() :
+{}
+{
+  ( LOOKAHEAD(2) "[" Expression() "]" )+ ( LOOKAHEAD(2) "[" "]" )*
+}
+
+
+/*
+ * Statement syntax follows.
+ */
+
+void Statement() :
+{}
+{
+  LOOKAHEAD(2)
+  LabeledStatement()
+|
+  Block()
+|
+  EmptyStatement()
+|
+  StatementExpression() ";"
+|
+  SwitchStatement()
+|
+  IfStatement()
+|
+  WhileStatement()
+|
+  DoStatement()
+|
+  ForStatement()
+|
+  BreakStatement()
+|
+  ContinueStatement()
+|
+  ReturnStatement()
+|
+  ThrowStatement()
+|
+  SynchronizedStatement()
+|
+  TryStatement()
+}
+
+void LabeledStatement() :
+{}
+{
+  <IDENTIFIER> ":" Statement()
+}
+
+void Block() :
+{}
+{
+  "{" ( BlockStatement() )* "}"
+}
+
+void BlockStatement() :
+{}
+{
+  LOOKAHEAD(Type() <IDENTIFIER>)
+  LocalVariableDeclaration() ";"
+|
+  Statement()
+}
+
+void LocalVariableDeclaration() :
+{}
+{
+  Type() VariableDeclarator() ( "," VariableDeclarator() )*
+}
+
+void EmptyStatement() :
+{}
+{
+  ";"
+}
+
+void StatementExpression() :
+/*
+ * The last expansion of this production accepts more than the legal
+ * Java expansions for StatementExpression.
+ */
+{}
+{
+  PreIncrementExpression()
+|
+  PreDecrementExpression()
+|
+  LOOKAHEAD( PrimaryExpression() AssignmentOperator() )
+  Assignment()
+|
+  PostfixExpression()
+}
+
+void SwitchStatement() :
+{}
+{
+  "switch" "(" Expression() ")" "{"
+    ( SwitchLabel() ( BlockStatement() )* )*
+  "}"
+}
+
+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" "(" Expression() ")" Statement() [ LOOKAHEAD(1) "else" Statement() ]
+}
+
+void WhileStatement() :
+{}
+{
+  "while" "(" Expression() ")" Statement()
+}
+
+void DoStatement() :
+{}
+{
+  "do" Statement() "while" "(" Expression() ")" ";"
+}
+
+void ForStatement() :
+{}
+{
+  "for" "(" [ ForInit() ] ";" [ Expression() ] ";" [ ForUpdate() ] ")" Statement()
+}
+
+void ForInit() :
+{}
+{
+  LOOKAHEAD( Type() <IDENTIFIER> )
+  LocalVariableDeclaration()
+|
+  StatementExpressionList()
+}
+
+void StatementExpressionList() :
+{}
+{
+  StatementExpression() ( "," StatementExpression() )*
+}
+
+void ForUpdate() :
+{}
+{
+  StatementExpressionList()
+}
+
+void BreakStatement() :
+{}
+{
+  "break" [ <IDENTIFIER> ] ";"
+}
+
+void ContinueStatement() :
+{}
+{
+  "continue" [ <IDENTIFIER> ] ";"
+}
+
+void ReturnStatement() :
+{}
+{
+  "return" [ Expression() ] ";"
+}
+
+void ThrowStatement() :
+{}
+{
+  "throw" Expression() ";"
+}
+
+void SynchronizedStatement() :
+{}
+{
+  "synchronized" "(" Expression() ")" Block()
+}
+
+void TryStatement() :
+/*
+ * Semantic check required here to make sure that at least one
+ * finally/catch is present.
+ */
+{}
+{
+  "try" Block()
+  ( "catch" "(" FormalParameter() ")" Block() )*
+  [ "finally" Block() ]
+}
diff --git a/tools/javacc-4.0/examples/JavaGrammars/Java1.1.jj b/tools/javacc-4.0/examples/JavaGrammars/Java1.1.jj
new file mode 100644
index 0000000000000000000000000000000000000000..d1782c8ebe4b56095debe0ebd4afc23dfe3711a0
--- /dev/null
+++ b/tools/javacc-4.0/examples/JavaGrammars/Java1.1.jj
@@ -0,0 +1,1692 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+
+options {
+  JAVA_UNICODE_ESCAPE = true;
+}
+
+PARSER_BEGIN(JavaParser)
+
+public class JavaParser {
+
+  public static void main(String args[]) {
+    JavaParser parser;
+    if (args.length == 0) {
+      System.out.println("Java Parser Version 1.1:  Reading from standard input . . .");
+      parser = new JavaParser(System.in);
+    } else if (args.length == 1) {
+      System.out.println("Java Parser Version 1.1:  Reading from file " + args[0] + " . . .");
+      try {
+        parser = new JavaParser(new java.io.FileInputStream(args[0]));
+      } catch (java.io.FileNotFoundException e) {
+        System.out.println("Java Parser Version 1.1:  File " + args[0] + " not found.");
+        return;
+      }
+    } else {
+      System.out.println("Java Parser Version 1.1:  Usage is one of:");
+      System.out.println("         java JavaParser < inputfile");
+      System.out.println("OR");
+      System.out.println("         java JavaParser inputfile");
+      return;
+    }
+    try {
+      parser.CompilationUnit();
+      System.out.println("Java Parser Version 1.1:  Java program parsed successfully.");
+    } catch (ParseException e) {
+      System.out.println(e.getMessage());
+      System.out.println("Java Parser Version 1.1:  Encountered errors during parse.");
+    }
+  }
+
+}
+
+PARSER_END(JavaParser)
+
+
+/* WHITE SPACE */
+
+SKIP :
+{
+  " "
+| "\t"
+| "\n"
+| "\r"
+| "\f"
+}
+
+/* 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> (<PART_LETTER>)* >
+|
+  < #LETTER:
+      [  // all chars for which Character.isIdentifierStart is true
+         "$",
+         "A"-"Z",
+         "_",
+         "a"-"z",
+         "\u00a2"-"\u00a5",
+         "\u00aa",
+         "\u00b5",
+         "\u00ba",
+         "\u00c0"-"\u00d6",
+         "\u00d8"-"\u00f6",
+         "\u00f8"-"\u021f",
+         "\u0222"-"\u0233",
+         "\u0250"-"\u02ad",
+         "\u02b0"-"\u02b8",
+         "\u02bb"-"\u02c1",
+         "\u02d0"-"\u02d1",
+         "\u02e0"-"\u02e4",
+         "\u02ee",
+         "\u037a",
+         "\u0386",
+         "\u0388"-"\u038a",
+         "\u038c",
+         "\u038e"-"\u03a1",
+         "\u03a3"-"\u03ce",
+         "\u03d0"-"\u03d7",
+         "\u03da"-"\u03f3",
+         "\u0400"-"\u0481",
+         "\u048c"-"\u04c4",
+         "\u04c7"-"\u04c8",
+         "\u04cb"-"\u04cc",
+         "\u04d0"-"\u04f5",
+         "\u04f8"-"\u04f9",
+         "\u0531"-"\u0556",
+         "\u0559",
+         "\u0561"-"\u0587",
+         "\u05d0"-"\u05ea",
+         "\u05f0"-"\u05f2",
+         "\u0621"-"\u063a",
+         "\u0640"-"\u064a",
+         "\u0671"-"\u06d3",
+         "\u06d5",
+         "\u06e5"-"\u06e6",
+         "\u06fa"-"\u06fc",
+         "\u0710",
+         "\u0712"-"\u072c",
+         "\u0780"-"\u07a5",
+         "\u0905"-"\u0939",
+         "\u093d",
+         "\u0950",
+         "\u0958"-"\u0961",
+         "\u0985"-"\u098c",
+         "\u098f"-"\u0990",
+         "\u0993"-"\u09a8",
+         "\u09aa"-"\u09b0",
+         "\u09b2",
+         "\u09b6"-"\u09b9",
+         "\u09dc"-"\u09dd",
+         "\u09df"-"\u09e1",
+         "\u09f0"-"\u09f3",
+         "\u0a05"-"\u0a0a",
+         "\u0a0f"-"\u0a10",
+         "\u0a13"-"\u0a28",
+         "\u0a2a"-"\u0a30",
+         "\u0a32"-"\u0a33",
+         "\u0a35"-"\u0a36",
+         "\u0a38"-"\u0a39",
+         "\u0a59"-"\u0a5c",
+         "\u0a5e",
+         "\u0a72"-"\u0a74",
+         "\u0a85"-"\u0a8b",
+         "\u0a8d",
+         "\u0a8f"-"\u0a91",
+         "\u0a93"-"\u0aa8",
+         "\u0aaa"-"\u0ab0",
+         "\u0ab2"-"\u0ab3",
+         "\u0ab5"-"\u0ab9",
+         "\u0abd",
+         "\u0ad0",
+         "\u0ae0",
+         "\u0b05"-"\u0b0c",
+         "\u0b0f"-"\u0b10",
+         "\u0b13"-"\u0b28",
+         "\u0b2a"-"\u0b30",
+         "\u0b32"-"\u0b33",
+         "\u0b36"-"\u0b39",
+         "\u0b3d",
+         "\u0b5c"-"\u0b5d",
+         "\u0b5f"-"\u0b61",
+         "\u0b85"-"\u0b8a",
+         "\u0b8e"-"\u0b90",
+         "\u0b92"-"\u0b95",
+         "\u0b99"-"\u0b9a",
+         "\u0b9c",
+         "\u0b9e"-"\u0b9f",
+         "\u0ba3"-"\u0ba4",
+         "\u0ba8"-"\u0baa",
+         "\u0bae"-"\u0bb5",
+         "\u0bb7"-"\u0bb9",
+         "\u0c05"-"\u0c0c",
+         "\u0c0e"-"\u0c10",
+         "\u0c12"-"\u0c28",
+         "\u0c2a"-"\u0c33",
+         "\u0c35"-"\u0c39",
+         "\u0c60"-"\u0c61",
+         "\u0c85"-"\u0c8c",
+         "\u0c8e"-"\u0c90",
+         "\u0c92"-"\u0ca8",
+         "\u0caa"-"\u0cb3",
+         "\u0cb5"-"\u0cb9",
+         "\u0cde",
+         "\u0ce0"-"\u0ce1",
+         "\u0d05"-"\u0d0c",
+         "\u0d0e"-"\u0d10",
+         "\u0d12"-"\u0d28",
+         "\u0d2a"-"\u0d39",
+         "\u0d60"-"\u0d61",
+         "\u0d85"-"\u0d96",
+         "\u0d9a"-"\u0db1",
+         "\u0db3"-"\u0dbb",
+         "\u0dbd",
+         "\u0dc0"-"\u0dc6",
+         "\u0e01"-"\u0e30",
+         "\u0e32"-"\u0e33",
+         "\u0e3f"-"\u0e46",
+         "\u0e81"-"\u0e82",
+         "\u0e84",
+         "\u0e87"-"\u0e88",
+         "\u0e8a",
+         "\u0e8d",
+         "\u0e94"-"\u0e97",
+         "\u0e99"-"\u0e9f",
+         "\u0ea1"-"\u0ea3",
+         "\u0ea5",
+         "\u0ea7",
+         "\u0eaa"-"\u0eab",
+         "\u0ead"-"\u0eb0",
+         "\u0eb2"-"\u0eb3",
+         "\u0ebd",
+         "\u0ec0"-"\u0ec4",
+         "\u0ec6",
+         "\u0edc"-"\u0edd",
+         "\u0f00",
+         "\u0f40"-"\u0f47",
+         "\u0f49"-"\u0f6a",
+         "\u0f88"-"\u0f8b",
+         "\u1000"-"\u1021",
+         "\u1023"-"\u1027",
+         "\u1029"-"\u102a",
+         "\u1050"-"\u1055",
+         "\u10a0"-"\u10c5",
+         "\u10d0"-"\u10f6",
+         "\u1100"-"\u1159",
+         "\u115f"-"\u11a2",
+         "\u11a8"-"\u11f9",
+         "\u1200"-"\u1206",
+         "\u1208"-"\u1246",
+         "\u1248",
+         "\u124a"-"\u124d",
+         "\u1250"-"\u1256",
+         "\u1258",
+         "\u125a"-"\u125d",
+         "\u1260"-"\u1286",
+         "\u1288",
+         "\u128a"-"\u128d",
+         "\u1290"-"\u12ae",
+         "\u12b0",
+         "\u12b2"-"\u12b5",
+         "\u12b8"-"\u12be",
+         "\u12c0",
+         "\u12c2"-"\u12c5",
+         "\u12c8"-"\u12ce",
+         "\u12d0"-"\u12d6",
+         "\u12d8"-"\u12ee",
+         "\u12f0"-"\u130e",
+         "\u1310",
+         "\u1312"-"\u1315",
+         "\u1318"-"\u131e",
+         "\u1320"-"\u1346",
+         "\u1348"-"\u135a",
+         "\u13a0"-"\u13f4",
+         "\u1401"-"\u166c",
+         "\u166f"-"\u1676",
+         "\u1681"-"\u169a",
+         "\u16a0"-"\u16ea",
+         "\u1780"-"\u17b3",
+         "\u17db",
+         "\u1820"-"\u1877",
+         "\u1880"-"\u18a8",
+         "\u1e00"-"\u1e9b",
+         "\u1ea0"-"\u1ef9",
+         "\u1f00"-"\u1f15",
+         "\u1f18"-"\u1f1d",
+         "\u1f20"-"\u1f45",
+         "\u1f48"-"\u1f4d",
+         "\u1f50"-"\u1f57",
+         "\u1f59",
+         "\u1f5b",
+         "\u1f5d",
+         "\u1f5f"-"\u1f7d",
+         "\u1f80"-"\u1fb4",
+         "\u1fb6"-"\u1fbc",
+         "\u1fbe",
+         "\u1fc2"-"\u1fc4",
+         "\u1fc6"-"\u1fcc",
+         "\u1fd0"-"\u1fd3",
+         "\u1fd6"-"\u1fdb",
+         "\u1fe0"-"\u1fec",
+         "\u1ff2"-"\u1ff4",
+         "\u1ff6"-"\u1ffc",
+         "\u203f"-"\u2040",
+         "\u207f",
+         "\u20a0"-"\u20af",
+         "\u2102",
+         "\u2107",
+         "\u210a"-"\u2113",
+         "\u2115",
+         "\u2119"-"\u211d",
+         "\u2124",
+         "\u2126",
+         "\u2128",
+         "\u212a"-"\u212d",
+         "\u212f"-"\u2131",
+         "\u2133"-"\u2139",
+         "\u2160"-"\u2183",
+         "\u3005"-"\u3007",
+         "\u3021"-"\u3029",
+         "\u3031"-"\u3035",
+         "\u3038"-"\u303a",
+         "\u3041"-"\u3094",
+         "\u309d"-"\u309e",
+         "\u30a1"-"\u30fe",
+         "\u3105"-"\u312c",
+         "\u3131"-"\u318e",
+         "\u31a0"-"\u31b7",
+         "\u3400"-"\u4db5",
+         "\u4e00"-"\u9fa5",
+         "\ua000"-"\ua48c",
+         "\uac00"-"\ud7a3",
+         "\uf900"-"\ufa2d",
+         "\ufb00"-"\ufb06",
+         "\ufb13"-"\ufb17",
+         "\ufb1d",
+         "\ufb1f"-"\ufb28",
+         "\ufb2a"-"\ufb36",
+         "\ufb38"-"\ufb3c",
+         "\ufb3e",
+         "\ufb40"-"\ufb41",
+         "\ufb43"-"\ufb44",
+         "\ufb46"-"\ufbb1",
+         "\ufbd3"-"\ufd3d",
+         "\ufd50"-"\ufd8f",
+         "\ufd92"-"\ufdc7",
+         "\ufdf0"-"\ufdfb",
+         "\ufe33"-"\ufe34",
+         "\ufe4d"-"\ufe4f",
+         "\ufe69",
+         "\ufe70"-"\ufe72",
+         "\ufe74",
+         "\ufe76"-"\ufefc",
+         "\uff04",
+         "\uff21"-"\uff3a",
+         "\uff3f",
+         "\uff41"-"\uff5a",
+         "\uff65"-"\uffbe",
+         "\uffc2"-"\uffc7",
+         "\uffca"-"\uffcf",
+         "\uffd2"-"\uffd7",
+         "\uffda"-"\uffdc",
+         "\uffe0"-"\uffe1",
+         "\uffe5"-"\uffe6"
+      ]
+  >
+|
+  < #PART_LETTER:
+      [  // all chars for which Character.isIdentifierPart is true
+         "\u0000"-"\u0008",
+         "\u000e"-"\u001b",
+         "$",
+         "0"-"9",
+         "A"-"Z",
+         "_",
+         "a"-"z",
+         "\u007f"-"\u009f",
+         "\u00a2"-"\u00a5",
+         "\u00aa",
+         "\u00b5",
+         "\u00ba",
+         "\u00c0"-"\u00d6",
+         "\u00d8"-"\u00f6",
+         "\u00f8"-"\u021f",
+         "\u0222"-"\u0233",
+         "\u0250"-"\u02ad",
+         "\u02b0"-"\u02b8",
+         "\u02bb"-"\u02c1",
+         "\u02d0"-"\u02d1",
+         "\u02e0"-"\u02e4",
+         "\u02ee",
+         "\u0300"-"\u034e",
+         "\u0360"-"\u0362",
+         "\u037a",
+         "\u0386",
+         "\u0388"-"\u038a",
+         "\u038c",
+         "\u038e"-"\u03a1",
+         "\u03a3"-"\u03ce",
+         "\u03d0"-"\u03d7",
+         "\u03da"-"\u03f3",
+         "\u0400"-"\u0481",
+         "\u0483"-"\u0486",
+         "\u048c"-"\u04c4",
+         "\u04c7"-"\u04c8",
+         "\u04cb"-"\u04cc",
+         "\u04d0"-"\u04f5",
+         "\u04f8"-"\u04f9",
+         "\u0531"-"\u0556",
+         "\u0559",
+         "\u0561"-"\u0587",
+         "\u0591"-"\u05a1",
+         "\u05a3"-"\u05b9",
+         "\u05bb"-"\u05bd",
+         "\u05bf",
+         "\u05c1"-"\u05c2",
+         "\u05c4",
+         "\u05d0"-"\u05ea",
+         "\u05f0"-"\u05f2",
+         "\u0621"-"\u063a",
+         "\u0640"-"\u0655",
+         "\u0660"-"\u0669",
+         "\u0670"-"\u06d3",
+         "\u06d5"-"\u06dc",
+         "\u06df"-"\u06e8",
+         "\u06ea"-"\u06ed",
+         "\u06f0"-"\u06fc",
+         "\u070f"-"\u072c",
+         "\u0730"-"\u074a",
+         "\u0780"-"\u07b0",
+         "\u0901"-"\u0903",
+         "\u0905"-"\u0939",
+         "\u093c"-"\u094d",
+         "\u0950"-"\u0954",
+         "\u0958"-"\u0963",
+         "\u0966"-"\u096f",
+         "\u0981"-"\u0983",
+         "\u0985"-"\u098c",
+         "\u098f"-"\u0990",
+         "\u0993"-"\u09a8",
+         "\u09aa"-"\u09b0",
+         "\u09b2",
+         "\u09b6"-"\u09b9",
+         "\u09bc",
+         "\u09be"-"\u09c4",
+         "\u09c7"-"\u09c8",
+         "\u09cb"-"\u09cd",
+         "\u09d7",
+         "\u09dc"-"\u09dd",
+         "\u09df"-"\u09e3",
+         "\u09e6"-"\u09f3",
+         "\u0a02",
+         "\u0a05"-"\u0a0a",
+         "\u0a0f"-"\u0a10",
+         "\u0a13"-"\u0a28",
+         "\u0a2a"-"\u0a30",
+         "\u0a32"-"\u0a33",
+         "\u0a35"-"\u0a36",
+         "\u0a38"-"\u0a39",
+         "\u0a3c",
+         "\u0a3e"-"\u0a42",
+         "\u0a47"-"\u0a48",
+         "\u0a4b"-"\u0a4d",
+         "\u0a59"-"\u0a5c",
+         "\u0a5e",
+         "\u0a66"-"\u0a74",
+         "\u0a81"-"\u0a83",
+         "\u0a85"-"\u0a8b",
+         "\u0a8d",
+         "\u0a8f"-"\u0a91",
+         "\u0a93"-"\u0aa8",
+         "\u0aaa"-"\u0ab0",
+         "\u0ab2"-"\u0ab3",
+         "\u0ab5"-"\u0ab9",
+         "\u0abc"-"\u0ac5",
+         "\u0ac7"-"\u0ac9",
+         "\u0acb"-"\u0acd",
+         "\u0ad0",
+         "\u0ae0",
+         "\u0ae6"-"\u0aef",
+         "\u0b01"-"\u0b03",
+         "\u0b05"-"\u0b0c",
+         "\u0b0f"-"\u0b10",
+         "\u0b13"-"\u0b28",
+         "\u0b2a"-"\u0b30",
+         "\u0b32"-"\u0b33",
+         "\u0b36"-"\u0b39",
+         "\u0b3c"-"\u0b43",
+         "\u0b47"-"\u0b48",
+         "\u0b4b"-"\u0b4d",
+         "\u0b56"-"\u0b57",
+         "\u0b5c"-"\u0b5d",
+         "\u0b5f"-"\u0b61",
+         "\u0b66"-"\u0b6f",
+         "\u0b82"-"\u0b83",
+         "\u0b85"-"\u0b8a",
+         "\u0b8e"-"\u0b90",
+         "\u0b92"-"\u0b95",
+         "\u0b99"-"\u0b9a",
+         "\u0b9c",
+         "\u0b9e"-"\u0b9f",
+         "\u0ba3"-"\u0ba4",
+         "\u0ba8"-"\u0baa",
+         "\u0bae"-"\u0bb5",
+         "\u0bb7"-"\u0bb9",
+         "\u0bbe"-"\u0bc2",
+         "\u0bc6"-"\u0bc8",
+         "\u0bca"-"\u0bcd",
+         "\u0bd7",
+         "\u0be7"-"\u0bef",
+         "\u0c01"-"\u0c03",
+         "\u0c05"-"\u0c0c",
+         "\u0c0e"-"\u0c10",
+         "\u0c12"-"\u0c28",
+         "\u0c2a"-"\u0c33",
+         "\u0c35"-"\u0c39",
+         "\u0c3e"-"\u0c44",
+         "\u0c46"-"\u0c48",
+         "\u0c4a"-"\u0c4d",
+         "\u0c55"-"\u0c56",
+         "\u0c60"-"\u0c61",
+         "\u0c66"-"\u0c6f",
+         "\u0c82"-"\u0c83",
+         "\u0c85"-"\u0c8c",
+         "\u0c8e"-"\u0c90",
+         "\u0c92"-"\u0ca8",
+         "\u0caa"-"\u0cb3",
+         "\u0cb5"-"\u0cb9",
+         "\u0cbe"-"\u0cc4",
+         "\u0cc6"-"\u0cc8",
+         "\u0cca"-"\u0ccd",
+         "\u0cd5"-"\u0cd6",
+         "\u0cde",
+         "\u0ce0"-"\u0ce1",
+         "\u0ce6"-"\u0cef",
+         "\u0d02"-"\u0d03",
+         "\u0d05"-"\u0d0c",
+         "\u0d0e"-"\u0d10",
+         "\u0d12"-"\u0d28",
+         "\u0d2a"-"\u0d39",
+         "\u0d3e"-"\u0d43",
+         "\u0d46"-"\u0d48",
+         "\u0d4a"-"\u0d4d",
+         "\u0d57",
+         "\u0d60"-"\u0d61",
+         "\u0d66"-"\u0d6f",
+         "\u0d82"-"\u0d83",
+         "\u0d85"-"\u0d96",
+         "\u0d9a"-"\u0db1",
+         "\u0db3"-"\u0dbb",
+         "\u0dbd",
+         "\u0dc0"-"\u0dc6",
+         "\u0dca",
+         "\u0dcf"-"\u0dd4",
+         "\u0dd6",
+         "\u0dd8"-"\u0ddf",
+         "\u0df2"-"\u0df3",
+         "\u0e01"-"\u0e3a",
+         "\u0e3f"-"\u0e4e",
+         "\u0e50"-"\u0e59",
+         "\u0e81"-"\u0e82",
+         "\u0e84",
+         "\u0e87"-"\u0e88",
+         "\u0e8a",
+         "\u0e8d",
+         "\u0e94"-"\u0e97",
+         "\u0e99"-"\u0e9f",
+         "\u0ea1"-"\u0ea3",
+         "\u0ea5",
+         "\u0ea7",
+         "\u0eaa"-"\u0eab",
+         "\u0ead"-"\u0eb9",
+         "\u0ebb"-"\u0ebd",
+         "\u0ec0"-"\u0ec4",
+         "\u0ec6",
+         "\u0ec8"-"\u0ecd",
+         "\u0ed0"-"\u0ed9",
+         "\u0edc"-"\u0edd",
+         "\u0f00",
+         "\u0f18"-"\u0f19",
+         "\u0f20"-"\u0f29",
+         "\u0f35",
+         "\u0f37",
+         "\u0f39",
+         "\u0f3e"-"\u0f47",
+         "\u0f49"-"\u0f6a",
+         "\u0f71"-"\u0f84",
+         "\u0f86"-"\u0f8b",
+         "\u0f90"-"\u0f97",
+         "\u0f99"-"\u0fbc",
+         "\u0fc6",
+         "\u1000"-"\u1021",
+         "\u1023"-"\u1027",
+         "\u1029"-"\u102a",
+         "\u102c"-"\u1032",
+         "\u1036"-"\u1039",
+         "\u1040"-"\u1049",
+         "\u1050"-"\u1059",
+         "\u10a0"-"\u10c5",
+         "\u10d0"-"\u10f6",
+         "\u1100"-"\u1159",
+         "\u115f"-"\u11a2",
+         "\u11a8"-"\u11f9",
+         "\u1200"-"\u1206",
+         "\u1208"-"\u1246",
+         "\u1248",
+         "\u124a"-"\u124d",
+         "\u1250"-"\u1256",
+         "\u1258",
+         "\u125a"-"\u125d",
+         "\u1260"-"\u1286",
+         "\u1288",
+         "\u128a"-"\u128d",
+         "\u1290"-"\u12ae",
+         "\u12b0",
+         "\u12b2"-"\u12b5",
+         "\u12b8"-"\u12be",
+         "\u12c0",
+         "\u12c2"-"\u12c5",
+         "\u12c8"-"\u12ce",
+         "\u12d0"-"\u12d6",
+         "\u12d8"-"\u12ee",
+         "\u12f0"-"\u130e",
+         "\u1310",
+         "\u1312"-"\u1315",
+         "\u1318"-"\u131e",
+         "\u1320"-"\u1346",
+         "\u1348"-"\u135a",
+         "\u1369"-"\u1371",
+         "\u13a0"-"\u13f4",
+         "\u1401"-"\u166c",
+         "\u166f"-"\u1676",
+         "\u1681"-"\u169a",
+         "\u16a0"-"\u16ea",
+         "\u1780"-"\u17d3",
+         "\u17db",
+         "\u17e0"-"\u17e9",
+         "\u180b"-"\u180e",
+         "\u1810"-"\u1819",
+         "\u1820"-"\u1877",
+         "\u1880"-"\u18a9",
+         "\u1e00"-"\u1e9b",
+         "\u1ea0"-"\u1ef9",
+         "\u1f00"-"\u1f15",
+         "\u1f18"-"\u1f1d",
+         "\u1f20"-"\u1f45",
+         "\u1f48"-"\u1f4d",
+         "\u1f50"-"\u1f57",
+         "\u1f59",
+         "\u1f5b",
+         "\u1f5d",
+         "\u1f5f"-"\u1f7d",
+         "\u1f80"-"\u1fb4",
+         "\u1fb6"-"\u1fbc",
+         "\u1fbe",
+         "\u1fc2"-"\u1fc4",
+         "\u1fc6"-"\u1fcc",
+         "\u1fd0"-"\u1fd3",
+         "\u1fd6"-"\u1fdb",
+         "\u1fe0"-"\u1fec",
+         "\u1ff2"-"\u1ff4",
+         "\u1ff6"-"\u1ffc",
+         "\u200c"-"\u200f",
+         "\u202a"-"\u202e",
+         "\u203f"-"\u2040",
+         "\u206a"-"\u206f",
+         "\u207f",
+         "\u20a0"-"\u20af",
+         "\u20d0"-"\u20dc",
+         "\u20e1",
+         "\u2102",
+         "\u2107",
+         "\u210a"-"\u2113",
+         "\u2115",
+         "\u2119"-"\u211d",
+         "\u2124",
+         "\u2126",
+         "\u2128",
+         "\u212a"-"\u212d",
+         "\u212f"-"\u2131",
+         "\u2133"-"\u2139",
+         "\u2160"-"\u2183",
+         "\u3005"-"\u3007",
+         "\u3021"-"\u302f",
+         "\u3031"-"\u3035",
+         "\u3038"-"\u303a",
+         "\u3041"-"\u3094",
+         "\u3099"-"\u309a",
+         "\u309d"-"\u309e",
+         "\u30a1"-"\u30fe",
+         "\u3105"-"\u312c",
+         "\u3131"-"\u318e",
+         "\u31a0"-"\u31b7",
+         "\u3400"-"\u4db5",
+         "\u4e00"-"\u9fa5",
+         "\ua000"-"\ua48c",
+         "\uac00"-"\ud7a3",
+         "\uf900"-"\ufa2d",
+         "\ufb00"-"\ufb06",
+         "\ufb13"-"\ufb17",
+         "\ufb1d"-"\ufb28",
+         "\ufb2a"-"\ufb36",
+         "\ufb38"-"\ufb3c",
+         "\ufb3e",
+         "\ufb40"-"\ufb41",
+         "\ufb43"-"\ufb44",
+         "\ufb46"-"\ufbb1",
+         "\ufbd3"-"\ufd3d",
+         "\ufd50"-"\ufd8f",
+         "\ufd92"-"\ufdc7",
+         "\ufdf0"-"\ufdfb",
+         "\ufe20"-"\ufe23",
+         "\ufe33"-"\ufe34",
+         "\ufe4d"-"\ufe4f",
+         "\ufe69",
+         "\ufe70"-"\ufe72",
+         "\ufe74",
+         "\ufe76"-"\ufefc",
+         "\ufeff",
+         "\uff04",
+         "\uff10"-"\uff19",
+         "\uff21"-"\uff3a",
+         "\uff3f",
+         "\uff41"-"\uff5a",
+         "\uff65"-"\uffbe",
+         "\uffc2"-"\uffc7",
+         "\uffca"-"\uffcf",
+         "\uffd2"-"\uffd7",
+         "\uffda"-"\uffdc",
+         "\uffe0"-"\uffe1",
+         "\uffe5"-"\uffe6",
+         "\ufff9"-"\ufffb"
+      ]
+  >
+}
+
+/* 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() ";"
+}
+
+void ImportDeclaration() :
+{}
+{
+  "import" Name() [ "." "*" ] ";"
+}
+
+void TypeDeclaration() :
+{}
+{
+  LOOKAHEAD( ( "abstract" | "final" | "public" )* "class" )
+  ClassDeclaration()
+|
+  InterfaceDeclaration()
+|
+  ";"
+}
+
+
+/*
+ * Declaration syntax follows.
+ */
+
+void ClassDeclaration() :
+{}
+{
+  ( "abstract" | "final" | "public" )*
+  UnmodifiedClassDeclaration()
+}
+
+void UnmodifiedClassDeclaration() :
+{}
+{
+  "class" <IDENTIFIER> [ "extends" Name() ] [ "implements" NameList() ]
+  ClassBody()
+}
+
+void ClassBody() :
+{}
+{
+  "{" ( ClassBodyDeclaration() )* "}"
+}
+
+void NestedClassDeclaration() :
+{}
+{
+  ( "static" | "abstract" | "final" | "public" | "protected" | "private" )*
+  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" | "public" )*
+  UnmodifiedInterfaceDeclaration()
+}
+
+void NestedInterfaceDeclaration() :
+{}
+{
+  ( "static" | "abstract" | "final" | "public" | "protected" | "private" )*
+  UnmodifiedInterfaceDeclaration()
+}
+
+void UnmodifiedInterfaceDeclaration() :
+{}
+{
+  "interface" <IDENTIFIER> [ "extends" NameList() ]
+  "{" ( InterfaceMemberDeclaration() )* "}"
+}
+
+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" | "protected" | "private" | "static" | "final" | "transient" | "volatile" )*
+  Type() VariableDeclarator() ( "," VariableDeclarator() )* ";"
+}
+
+void VariableDeclarator() :
+{}
+{
+  VariableDeclaratorId() [ "=" VariableInitializer() ]
+}
+
+void VariableDeclaratorId() :
+{}
+{
+  <IDENTIFIER> ( "[" "]" )*
+}
+
+void VariableInitializer() :
+{}
+{
+  ArrayInitializer()
+|
+  Expression()
+}
+
+void ArrayInitializer() :
+{}
+{
+  "{" [ VariableInitializer() ( LOOKAHEAD(2) "," VariableInitializer() )* ] [ "," ] "}"
+}
+
+void MethodDeclaration() :
+{}
+{
+  ( "public" | "protected" | "private" | "static" | "abstract" | "final" | "native" | "synchronized" )*
+  ResultType() MethodDeclarator() [ "throws" NameList() ]
+  ( Block() | ";" )
+}
+
+void MethodDeclarator() :
+{}
+{
+  <IDENTIFIER> FormalParameters() ( "[" "]" )*
+}
+
+void FormalParameters() :
+{}
+{
+  "(" [ FormalParameter() ( "," FormalParameter() )* ] ")"
+}
+
+void FormalParameter() :
+{}
+{
+  [ "final" ] Type() VariableDeclaratorId()
+}
+
+void ConstructorDeclaration() :
+{}
+{
+  [ "public" | "protected" | "private" ]
+  <IDENTIFIER> FormalParameters() [ "throws" NameList() ]
+  "{"
+    [ LOOKAHEAD(ExplicitConstructorInvocation()) ExplicitConstructorInvocation() ]
+    ( BlockStatement() )*
+  "}"
+}
+
+void ExplicitConstructorInvocation() :
+{}
+{
+  LOOKAHEAD("this" Arguments() ";")
+  "this" Arguments() ";"
+|
+  [ LOOKAHEAD(2) PrimaryExpression() "." ] "super" Arguments() ";"
+}
+
+void Initializer() :
+{}
+{
+  [ "static" ] Block()
+}
+
+
+/*
+ * Type, name and expression syntax follows.
+ */
+
+void Type() :
+{}
+{
+  ( PrimitiveType() | Name() ) ( "[" "]" )*
+}
+
+void PrimitiveType() :
+{}
+{
+  "boolean"
+|
+  "char"
+|
+  "byte"
+|
+  "short"
+|
+  "int"
+|
+  "long"
+|
+  "float"
+|
+  "double"
+}
+
+void ResultType() :
+{}
+{
+  "void"
+|
+  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() :
+{}
+{
+  "=" | "*=" | "/=" | "%=" | "+=" | "-=" | "<<=" | ">>=" | ">>>=" | "&=" | "^=" | "|="
+}
+
+void ConditionalExpression() :
+{}
+{
+  ConditionalOrExpression() [ "?" Expression() ":" ConditionalExpression() ]
+}
+
+void ConditionalOrExpression() :
+{}
+{
+  ConditionalAndExpression() ( "||" ConditionalAndExpression() )*
+}
+
+void ConditionalAndExpression() :
+{}
+{
+  InclusiveOrExpression() ( "&&" InclusiveOrExpression() )*
+}
+
+void InclusiveOrExpression() :
+{}
+{
+  ExclusiveOrExpression() ( "|" ExclusiveOrExpression() )*
+}
+
+void ExclusiveOrExpression() :
+{}
+{
+  AndExpression() ( "^" AndExpression() )*
+}
+
+void AndExpression() :
+{}
+{
+  EqualityExpression() ( "&" EqualityExpression() )*
+}
+
+void EqualityExpression() :
+{}
+{
+  InstanceOfExpression() ( ( "==" | "!=" ) InstanceOfExpression() )*
+}
+
+void InstanceOfExpression() :
+{}
+{
+  RelationalExpression() [ "instanceof" Type() ]
+}
+
+void RelationalExpression() :
+{}
+{
+  ShiftExpression() ( ( "<" | ">" | "<=" | ">=" ) ShiftExpression() )*
+}
+
+void ShiftExpression() :
+{}
+{
+  AdditiveExpression() ( ( "<<" | ">>" | ">>>" ) AdditiveExpression() )*
+}
+
+void AdditiveExpression() :
+{}
+{
+  MultiplicativeExpression() ( ( "+" | "-" ) MultiplicativeExpression() )*
+}
+
+void MultiplicativeExpression() :
+{}
+{
+  UnaryExpression() ( ( "*" | "/" | "%" ) UnaryExpression() )*
+}
+
+void UnaryExpression() :
+{}
+{
+  ( "+" | "-" ) UnaryExpression()
+|
+  PreIncrementExpression()
+|
+  PreDecrementExpression()
+|
+  UnaryExpressionNotPlusMinus()
+}
+
+void PreIncrementExpression() :
+{}
+{
+  "++" PrimaryExpression()
+}
+
+void PreDecrementExpression() :
+{}
+{
+  "--" PrimaryExpression()
+}
+
+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() [ "++" | "--" ]
+}
+
+void CastExpression() :
+{}
+{
+  LOOKAHEAD("(" PrimitiveType())
+  "(" Type() ")" UnaryExpression()
+|
+  "(" Type() ")" UnaryExpressionNotPlusMinus()
+}
+
+void PrimaryExpression() :
+{}
+{
+  PrimaryPrefix() ( LOOKAHEAD(2) PrimarySuffix() )*
+}
+
+void PrimaryPrefix() :
+{}
+{
+  Literal()
+|
+  "this"
+|
+  "super" "." <IDENTIFIER>
+|
+  "(" Expression() ")"
+|
+  AllocationExpression()
+|
+  LOOKAHEAD( ResultType() "." "class" )
+  ResultType() "." "class"
+|
+  Name()
+}
+
+void PrimarySuffix() :
+{}
+{
+  LOOKAHEAD(2)
+  "." "this"
+|
+  LOOKAHEAD(2)
+  "." AllocationExpression()
+|
+  "[" Expression() "]"
+|
+  "." <IDENTIFIER>
+|
+  Arguments()
+}
+
+void Literal() :
+{}
+{
+  <INTEGER_LITERAL>
+|
+  <FLOATING_POINT_LITERAL>
+|
+  <CHARACTER_LITERAL>
+|
+  <STRING_LITERAL>
+|
+  BooleanLiteral()
+|
+  NullLiteral()
+}
+
+void BooleanLiteral() :
+{}
+{
+  "true"
+|
+  "false"
+}
+
+void NullLiteral() :
+{}
+{
+  "null"
+}
+
+void Arguments() :
+{}
+{
+  "(" [ ArgumentList() ] ")"
+}
+
+void ArgumentList() :
+{}
+{
+  Expression() ( "," Expression() )*
+}
+
+void AllocationExpression() :
+{}
+{
+  LOOKAHEAD(2)
+  "new" PrimitiveType() ArrayDimsAndInits()
+|
+  "new" Name()
+    (
+      ArrayDimsAndInits()
+    |
+      Arguments() [ ClassBody() ]
+    )
+}
+
+/*
+ * 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() ";"
+|
+  SwitchStatement()
+|
+  IfStatement()
+|
+  WhileStatement()
+|
+  DoStatement()
+|
+  ForStatement()
+|
+  BreakStatement()
+|
+  ContinueStatement()
+|
+  ReturnStatement()
+|
+  ThrowStatement()
+|
+  SynchronizedStatement()
+|
+  TryStatement()
+}
+
+void LabeledStatement() :
+{}
+{
+  <IDENTIFIER> ":" Statement()
+}
+
+void Block() :
+{}
+{
+  "{" ( BlockStatement() )* "}"
+}
+
+void BlockStatement() :
+{}
+{
+  LOOKAHEAD([ "final" ] Type() <IDENTIFIER>)
+  LocalVariableDeclaration() ";"
+|
+  Statement()
+|
+  UnmodifiedClassDeclaration()
+|
+  UnmodifiedInterfaceDeclaration()
+}
+
+void LocalVariableDeclaration() :
+{}
+{
+  [ "final" ] 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()
+  [
+    "++"
+  |
+    "--"
+  |
+    AssignmentOperator() Expression()
+  ]
+}
+
+void SwitchStatement() :
+{}
+{
+  "switch" "(" Expression() ")" "{"
+    ( SwitchLabel() ( BlockStatement() )* )*
+  "}"
+}
+
+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" "(" Expression() ")" Statement() [ LOOKAHEAD(1) "else" Statement() ]
+}
+
+void WhileStatement() :
+{}
+{
+  "while" "(" Expression() ")" Statement()
+}
+
+void DoStatement() :
+{}
+{
+  "do" Statement() "while" "(" Expression() ")" ";"
+}
+
+void ForStatement() :
+{}
+{
+  "for" "(" [ ForInit() ] ";" [ Expression() ] ";" [ ForUpdate() ] ")" Statement()
+}
+
+void ForInit() :
+{}
+{
+  LOOKAHEAD( [ "final" ] Type() <IDENTIFIER> )
+  LocalVariableDeclaration()
+|
+  StatementExpressionList()
+}
+
+void StatementExpressionList() :
+{}
+{
+  StatementExpression() ( "," StatementExpression() )*
+}
+
+void ForUpdate() :
+{}
+{
+  StatementExpressionList()
+}
+
+void BreakStatement() :
+{}
+{
+  "break" [ <IDENTIFIER> ] ";"
+}
+
+void ContinueStatement() :
+{}
+{
+  "continue" [ <IDENTIFIER> ] ";"
+}
+
+void ReturnStatement() :
+{}
+{
+  "return" [ Expression() ] ";"
+}
+
+void ThrowStatement() :
+{}
+{
+  "throw" Expression() ";"
+}
+
+void SynchronizedStatement() :
+{}
+{
+  "synchronized" "(" Expression() ")" Block()
+}
+
+void TryStatement() :
+/*
+ * Semantic check required here to make sure that at least one
+ * finally/catch is present.
+ */
+{}
+{
+  "try" Block()
+  ( "catch" "(" FormalParameter() ")" Block() )*
+  [ "finally" Block() ]
+}
diff --git a/tools/javacc-4.0/examples/JavaGrammars/Java1.1noLA.jj b/tools/javacc-4.0/examples/JavaGrammars/Java1.1noLA.jj
new file mode 100644
index 0000000000000000000000000000000000000000..c508f45259139359ba6f46a4d4a861b0f3407203
--- /dev/null
+++ b/tools/javacc-4.0/examples/JavaGrammars/Java1.1noLA.jj
@@ -0,0 +1,1536 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+
+options {
+  JAVA_UNICODE_ESCAPE = true;
+}
+
+PARSER_BEGIN(JavaParser)
+
+public class JavaParser {
+
+  public static void main(String args[]) {
+    JavaParser parser;
+    if (args.length == 0) {
+      System.out.println("Java Parser Version 1.1:  Reading from standard input . . .");
+      parser = new JavaParser(System.in);
+    } else if (args.length == 1) {
+      System.out.println("Java Parser Version 1.1:  Reading from file " + args[0] + " . . .");
+      try {
+        parser = new JavaParser(new java.io.FileInputStream(args[0]));
+      } catch (java.io.FileNotFoundException e) {
+        System.out.println("Java Parser Version 1.1:  File " + args[0] + " not found.");
+        return;
+      }
+    } else {
+      System.out.println("Java Parser Version 1.1:  Usage is one of:");
+      System.out.println("         java JavaParser < inputfile");
+      System.out.println("OR");
+      System.out.println("         java JavaParser inputfile");
+      return;
+    }
+    try {
+      parser.CompilationUnit();
+      System.out.println("Java Parser Version 1.1:  Java program parsed successfully.");
+    } catch (ParseException e) {
+      System.out.println(e.getMessage());
+      System.out.println("Java Parser Version 1.1:  Encountered errors during parse.");
+    }
+  }
+
+  // Semantic lookahead rules follow.
+
+  // implements:  LOOKAHEAD( ( "abstract" | "final" | "public" )* "class" )
+  static boolean isClassDeclaration() {
+    int curTok = 1;
+    Token tok;
+    while (true) {
+      tok = getToken(curTok);
+      switch (tok.kind) {
+      case ABSTRACT:
+      case FINAL:
+      case PUBLIC:
+        curTok++;
+        break;
+      case CLASS:
+        return true;
+      default:
+        return false;
+      }
+    }
+  }
+
+  // implements:  LOOKAHEAD(2)  for Initializer()
+  static boolean isInitializer() {
+    Token tok = getToken(1);
+    if (tok.kind == LBRACE) return true;
+    if (tok.kind == STATIC) {
+      tok = getToken(2);
+      if (tok.kind == LBRACE) return true;
+    }
+    return false;
+  }
+
+  // implements:  LOOKAHEAD( ( "static" | "abstract" | "final" | "public" | "protected" | "private" )* "class" )
+  static boolean isNestedClassDeclaration() {
+    int curTok = 1;
+    Token tok;
+    while (true) {
+      tok = getToken(curTok);
+      switch (tok.kind) {
+      case STATIC:
+      case ABSTRACT:
+      case FINAL:
+      case PUBLIC:
+      case PROTECTED:
+      case PRIVATE:
+        curTok++;
+        break;
+      case CLASS:
+        return true;
+      default:
+        return false;
+      }
+    }
+  }
+
+  // implements:  LOOKAHEAD( ( "static" | "abstract" | "final" | "public" | "protected" | "private" )* "interface" )
+  static boolean isNestedInterfaceDeclaration() {
+    int curTok = 1;
+    Token tok;
+    while (true) {
+      tok = getToken(curTok);
+      switch (tok.kind) {
+      case STATIC:
+      case ABSTRACT:
+      case FINAL:
+      case PUBLIC:
+      case PROTECTED:
+      case PRIVATE:
+        curTok++;
+        break;
+      case INTERFACE:
+        return true;
+      default:
+        return false;
+      }
+    }
+  }
+
+  // implements:  LOOKAHEAD( [ "public" | "protected" | "private" ] Name() "(" )
+  static boolean isConstructorDeclaration() {
+    int curTok = 1;
+    Token tok;
+    tok = getToken(1);
+    switch (tok.kind) {
+    case PUBLIC:
+    case PROTECTED:
+    case PRIVATE:
+      curTok = 2;
+    }
+    tok = getToken(curTok++);
+    if (tok.kind != IDENTIFIER) return false;
+    while (true) {
+      tok = getToken(curTok++);
+      if (tok.kind == LPAREN) return true;
+      if (tok.kind != DOT) return false;
+      tok = getToken(curTok++);
+      if (tok.kind != IDENTIFIER) return false;
+    }
+  }
+
+  // Returns true if the next set of tokens cannot be a field declaration.
+  // Returns false if the next set of tokens cannot be a method declaration.
+  // Note how this method is used in the grammar.  We don't have to do a
+  // comprehensive check like we have done in the lookahead methods above.
+  // This show (therefore) another way you can implement lookahead methods.
+  // The way we do it is to see if we can find a "(" before either a "=" or
+  // a ";", in which case we return true.
+  static boolean isMethodDeclaration() {
+    int curTok = 1;
+    Token tok;
+    while (true) {
+      tok = getToken(curTok++);
+      switch (tok.kind) {
+      case LPAREN:
+        return true;
+      case ASSIGN:
+      case SEMICOLON:
+      case EOF:
+        return false;
+      }
+    }
+  }
+
+  // Checks that there is a "," and then there is no "}" following that.
+  static boolean moreVariableInitializers() {
+    return getToken(1).kind == COMMA && getToken(2).kind != RBRACE;
+  }
+
+  // Checks that this is a constructor invocation as opposed to a block
+  // statement.
+  static boolean isConstructorInvocation() {
+    int curTok = 1;
+    Token tok = getToken(1);
+    switch (tok.kind) {
+    case THIS:
+    case SUPER:
+      // We are assuming here that if the statement starts with "this"
+      // or "super", and the next token is "(", then it has to be a
+      // constructor invocation.
+      return getToken(2).kind == LPAREN;
+    case STRING_LITERAL:
+    case LPAREN:
+    case NEW:
+    case IDENTIFIER:
+      // Now move across tokens until the end of the statement - the
+      // first semicolon not nested within any kind of parentheses.
+      // If a "super(" is matched also not nested and before this
+      // semicolon, we return true.  Otherwise return false.
+      int nestingLevel = 0;
+      while (true) {
+        tok = getToken(curTok++);
+        switch (tok.kind) {
+        case SEMICOLON:
+          if (nestingLevel == 0) {
+            return false;
+          }
+          break;
+        case SUPER:
+          if (nestingLevel == 0) {
+            return getToken(curTok).kind == LPAREN;
+          }
+          break;
+        case LPAREN:
+        case LBRACE:
+        case LBRACKET:
+          nestingLevel++;
+          break;
+        case RPAREN:
+        case RBRACE:
+        case RBRACKET:
+          nestingLevel--;
+          break;
+        case EOF:
+          return false;
+        }
+      }
+    default:
+      return false;
+    }
+  }
+
+  // Returns true if this is a primitive type (or an array of primitive
+  // type) cast.
+  static boolean isPrimitiveTypeCast() {
+    if (getToken(1).kind != LPAREN) return false;
+    Token tok = getToken(2);
+    switch (tok.kind) {
+    case BOOLEAN:
+    case CHAR:
+    case BYTE:
+    case SHORT:
+    case INT:
+    case LONG:
+    case FLOAT:
+    case DOUBLE:
+      return true;
+    }
+    return false;
+  }
+
+  // Returns true if this is a type cast.
+  static boolean isTypeCast() {
+    if (isPrimitiveTypeCast()) return true;
+    if (getToken(1).kind != LPAREN) return false;
+    int curTok = 2;
+    Token tok = getToken(curTok++);
+    if (tok.kind != IDENTIFIER) return false;
+    while (true) {
+      tok = getToken(curTok++);
+      if (tok.kind != DOT) break;
+      tok = getToken(curTok++);
+      if (tok.kind != IDENTIFIER) return false;
+    }
+    if (tok.kind == RPAREN) {
+      tok = getToken(curTok);
+      switch (tok.kind) {
+      case TILDE:
+      case BANG:
+      case LPAREN:
+      case IDENTIFIER:
+      case THIS:
+      case SUPER:
+      case NEW:
+      case INTEGER_LITERAL:
+      case FLOATING_POINT_LITERAL:
+      case CHARACTER_LITERAL:
+      case STRING_LITERAL:
+      case TRUE:
+      case FALSE:
+      case NULL:
+        return true;
+      }
+      return false;
+    } else {
+      if (tok.kind != LBRACKET) return false;
+      tok = getToken(curTok);
+      if (tok.kind != RBRACKET) return false;
+      return true;
+    }
+  }
+
+  // Distinguishes between ClassSelector and Name.
+  static boolean isClassSelector() {
+    int curTok = 1;
+    Token tok = getToken(curTok++);
+    if (tok.kind != IDENTIFIER) return true;
+    while (true) {
+      tok = getToken(curTok++);
+      while (tok.kind == LBRACKET) {
+        // A simple loop to accept "[]"s.  We are a little sloppy
+        // in that we don't require it to be at the end, but then
+        // this is only a lookahead check.
+        tok = getToken(curTok++);
+        if (tok.kind != RBRACKET) return false;
+        tok = getToken(curTok++);
+      }
+      if (tok.kind != DOT) return false;
+      tok = getToken(curTok++);
+      if (tok.kind == CLASS) return true;
+      if (tok.kind != IDENTIFIER) return false;
+    }
+  }
+
+  // implements:  LOOKAHEAD([ "final" ] Type() <IDENTIFIER>)
+  static boolean isLocalVariableDeclaration() {
+    int curTok = 1;
+    Token tok = getToken(curTok++);
+    if (tok.kind == FINAL) tok = getToken(curTok++);
+    switch (tok.kind) {
+    case BOOLEAN:
+    case CHAR:
+    case BYTE:
+    case SHORT:
+    case INT:
+    case LONG:
+    case FLOAT:
+    case DOUBLE:
+      tok = getToken(curTok++);
+      break;
+    case IDENTIFIER:
+      while (true) {
+        tok = getToken(curTok++);
+        if (tok.kind != DOT) break;
+        tok = getToken(curTok++);
+        if (tok.kind != IDENTIFIER) return false;
+      }
+      break;
+    default:
+      return false;
+    }
+    while (tok.kind == LBRACKET) {
+      tok = getToken(curTok++);
+      if (tok.kind != RBRACKET) return false;
+      tok = getToken(curTok++);
+    }
+    return tok.kind == IDENTIFIER;
+  }
+
+  static boolean isPrimarySuffix() {
+    Token tok = getToken(1);
+    if (tok.kind == LPAREN || tok.kind == LBRACKET) return true;
+    if (tok.kind == DOT) {
+      tok = getToken(2);
+      switch (tok.kind) {
+      case THIS:
+      case NEW:
+      case IDENTIFIER:
+        return true;
+      }
+    }
+    return false;
+  }
+
+}
+
+PARSER_END(JavaParser)
+
+
+/* WHITE SPACE */
+
+SKIP :
+{
+  " "
+| "\t"
+| "\n"
+| "\r"
+| "\f"
+}
+
+/* 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() )*
+  (
+    LOOKAHEAD(1, <ABSTRACT> | <CLASS> | <FINAL> | <INTERFACE> | <PUBLIC> | <SEMICOLON>)
+    TypeDeclaration()
+  )*
+  <EOF>
+}
+
+void PackageDeclaration() :
+{}
+{
+  "package" Name() ";"
+}
+
+void ImportDeclaration() :
+{}
+{
+  "import" Name() [ "." "*" ] ";"
+}
+
+void TypeDeclaration() :
+{}
+{
+  LOOKAHEAD( { isClassDeclaration() } )
+  ClassDeclaration()
+|
+  InterfaceDeclaration()
+|
+  ";"
+}
+
+
+/*
+ * Declaration syntax follows.
+ */
+
+void ClassDeclaration() :
+{}
+{
+  ( "abstract" | "final" | "public" )*
+  UnmodifiedClassDeclaration()
+}
+
+void UnmodifiedClassDeclaration() :
+{}
+{
+  "class" <IDENTIFIER> [ "extends" Name() ] [ "implements" NameList() ]
+  ClassBody()
+}
+
+void ClassBody() :
+{}
+{
+  "{"
+    (
+      LOOKAHEAD(1, <ABSTRACT> | <BOOLEAN> | <BYTE> | <CHAR> | <CLASS> | <DOUBLE> |
+                   <FINAL> | <FLOAT> | <INT> | <INTERFACE> | <LONG> | <NATIVE> |
+                   <PRIVATE> | <PROTECTED> | <PUBLIC> | <SHORT> | <STATIC> |
+                   <SYNCHRONIZED> | <TRANSIENT> | <VOID> | <VOLATILE> | <IDENTIFIER> |
+                   <LBRACE>)
+      ClassBodyDeclaration()
+    )*
+  "}"
+}
+
+void NestedClassDeclaration() :
+{}
+{
+  ( "static" | "abstract" | "final" | "public" | "protected" | "private" )*
+  UnmodifiedClassDeclaration()
+}
+
+void ClassBodyDeclaration() :
+{}
+{
+  LOOKAHEAD( { isInitializer() } )
+  Initializer()
+|
+  LOOKAHEAD( { isNestedClassDeclaration() } )
+  NestedClassDeclaration()
+|
+  LOOKAHEAD( { isNestedInterfaceDeclaration() } )
+  NestedInterfaceDeclaration()
+|
+  LOOKAHEAD( { isConstructorDeclaration() } )
+  ConstructorDeclaration()
+|
+  LOOKAHEAD( { isMethodDeclaration() } )
+  MethodDeclaration()
+|
+  FieldDeclaration()
+}
+
+void InterfaceDeclaration() :
+{}
+{
+  ( "abstract" | "public" )*
+  UnmodifiedInterfaceDeclaration()
+}
+
+void NestedInterfaceDeclaration() :
+{}
+{
+  ( "static" | "abstract" | "final" | "public" | "protected" | "private" )*
+  UnmodifiedInterfaceDeclaration()
+}
+
+void UnmodifiedInterfaceDeclaration() :
+{}
+{
+  "interface" <IDENTIFIER> [ "extends" NameList() ]
+  "{"
+    (
+      LOOKAHEAD(1, <ABSTRACT> | <BOOLEAN> | <BYTE> | <CHAR> | <CLASS> | <DOUBLE> |
+                   <FINAL> | <FLOAT> | <INT> | <INTERFACE> | <LONG> | <NATIVE> |
+                   <PRIVATE> | <PROTECTED> | <PUBLIC> | <SHORT> | <STATIC> |
+                   <SYNCHRONIZED> | <TRANSIENT> | <VOID> | <VOLATILE> | <IDENTIFIER>)
+      InterfaceMemberDeclaration()
+    )*
+  "}"
+}
+
+void InterfaceMemberDeclaration() :
+{}
+{
+  LOOKAHEAD( { isNestedClassDeclaration() } )
+  NestedClassDeclaration()
+|
+  LOOKAHEAD( { isNestedInterfaceDeclaration() } )
+  NestedInterfaceDeclaration()
+|
+  LOOKAHEAD( { isMethodDeclaration() } )
+  MethodDeclaration()
+|
+  FieldDeclaration()
+}
+
+void FieldDeclaration() :
+{}
+{
+  ( "public" | "protected" | "private" | "static" | "final" | "transient" | "volatile" )*
+  Type() VariableDeclarator() ( "," VariableDeclarator() )* ";"
+}
+
+void VariableDeclarator() :
+{}
+{
+  VariableDeclaratorId() [ "=" VariableInitializer() ]
+}
+
+void VariableDeclaratorId() :
+{}
+{
+  <IDENTIFIER> ( "[" "]" )*
+}
+
+void VariableInitializer() :
+{}
+{
+  ArrayInitializer()
+|
+  LOOKAHEAD(1, <BOOLEAN> | <BYTE> | <CHAR> | <DOUBLE> | <FALSE> | <FLOAT> | <INT> |
+               <LONG> | <NEW> | <NULL> | <SHORT> | <SUPER> | <THIS> | <TRUE> |
+               <VOID> | <INTEGER_LITERAL> | <FLOATING_POINT_LITERAL> |
+               <CHARACTER_LITERAL> | <STRING_LITERAL> | <IDENTIFIER> | <LPAREN> |
+               <BANG> | <TILDE> | <INCR> | <DECR> | <PLUS> | <MINUS>)
+  Expression()
+}
+
+void ArrayInitializer() :
+{}
+{
+  "{"
+    [
+      LOOKAHEAD(1, <BOOLEAN> | <BYTE> | <CHAR> | <DOUBLE> | <FALSE> | <FLOAT> | <INT> |
+                   <LONG> | <NEW> | <NULL> | <SHORT> | <SUPER> | <THIS> | <TRUE> |
+                   <VOID> | <INTEGER_LITERAL> | <FLOATING_POINT_LITERAL> |
+                   <CHARACTER_LITERAL> | <STRING_LITERAL> | <IDENTIFIER> | <LPAREN> |
+                   <LBRACE> | <BANG> | <TILDE> | <INCR> | <DECR> | <PLUS> | <MINUS>)
+      VariableInitializer()
+      ( LOOKAHEAD( { getToken(1).kind == COMMA && getToken(2).kind != RBRACE } )
+        "," VariableInitializer()
+      )*
+    ]
+    [ "," ]
+  "}"
+}
+
+void MethodDeclaration() :
+{}
+{
+  ( "public" | "protected" | "private" | "static" | "abstract" | "final" | "native" | "synchronized" )*
+  ResultType() MethodDeclarator() [ "throws" NameList() ]
+  ( Block() | ";" )
+}
+
+void MethodDeclarator() :
+{}
+{
+  <IDENTIFIER> FormalParameters() ( "[" "]" )*
+}
+
+void FormalParameters() :
+{}
+{
+  "(" [ FormalParameter() ( "," FormalParameter() )* ] ")"
+}
+
+void FormalParameter() :
+{}
+{
+  [ "final" ] Type() VariableDeclaratorId()
+}
+
+void ConstructorDeclaration() :
+{}
+{
+  [ "public" | "protected" | "private" ]
+  <IDENTIFIER> FormalParameters() [ "throws" NameList() ]
+  "{"
+    [ LOOKAHEAD( { isConstructorInvocation() } ) ExplicitConstructorInvocation() ]
+    (
+      LOOKAHEAD(1, <BOOLEAN> | <BREAK> | <BYTE> | <CHAR> | <CLASS> | <CONTINUE> |
+                   <DO> | <DOUBLE> | <FALSE> | <FINAL> | <FLOAT> | <FOR> | <IF> |
+                   <INT> | <LONG> | <NEW> | <NULL> | <RETURN> | <SHORT> | <SUPER> |
+                   <SWITCH> | <SYNCHRONIZED> | <THIS> | <THROW> | <TRUE> | <TRY> |
+                   <VOID> | <WHILE> | <INTEGER_LITERAL> | <FLOATING_POINT_LITERAL> |
+                   <CHARACTER_LITERAL> | <STRING_LITERAL> | <IDENTIFIER> | <LPAREN> |
+                   <LBRACE> | <SEMICOLON> | <INCR> | <DECR>)
+      BlockStatement()
+    )*
+  "}"
+}
+
+void ExplicitConstructorInvocation() :
+{}
+{
+  LOOKAHEAD( { getToken(1).kind == THIS && getToken(2).kind == LPAREN } )
+  "this" Arguments() ";"
+|
+  LOOKAHEAD(1, <BOOLEAN> | <BYTE> | <CHAR> | <DOUBLE> | <FALSE> | <FLOAT> | <INT> |
+               <LONG> | <NEW> | <NULL> | <SHORT> | <SUPER> | <THIS> | <TRUE> |
+               <VOID> | <INTEGER_LITERAL> | <FLOATING_POINT_LITERAL> |
+               <CHARACTER_LITERAL> | <STRING_LITERAL> | <IDENTIFIER> | <LPAREN>)
+  [
+    LOOKAHEAD( { getToken(1).kind != SUPER || getToken(2).kind != LPAREN } )
+    PrimaryExpression() "."
+  ]
+  "super" Arguments() ";"
+}
+
+void Initializer() :
+{}
+{
+  [ "static" ] Block()
+}
+
+
+/*
+ * Type, name and expression syntax follows.
+ */
+
+void Type() :
+{}
+{
+  ( PrimitiveType() | Name() ) ( "[" "]" )*
+}
+
+void PrimitiveType() :
+{}
+{
+  "boolean"
+|
+  "char"
+|
+  "byte"
+|
+  "short"
+|
+  "int"
+|
+  "long"
+|
+  "float"
+|
+  "double"
+}
+
+void ResultType() :
+{}
+{
+  "void"
+|
+  Type()
+}
+
+void Name() :
+{}
+{
+  <IDENTIFIER>
+  ( LOOKAHEAD( { getToken(1).kind == DOT && getToken(2).kind == IDENTIFIER } )
+    "." <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() :
+{}
+{
+  "=" | "*=" | "/=" | "%=" | "+=" | "-=" | "<<=" | ">>=" | ">>>=" | "&=" | "^=" | "|="
+}
+
+void ConditionalExpression() :
+{}
+{
+  ConditionalOrExpression() [ "?" Expression() ":" ConditionalExpression() ]
+}
+
+void ConditionalOrExpression() :
+{}
+{
+  ConditionalAndExpression() ( "||" ConditionalAndExpression() )*
+}
+
+void ConditionalAndExpression() :
+{}
+{
+  InclusiveOrExpression() ( "&&" InclusiveOrExpression() )*
+}
+
+void InclusiveOrExpression() :
+{}
+{
+  ExclusiveOrExpression() ( "|" ExclusiveOrExpression() )*
+}
+
+void ExclusiveOrExpression() :
+{}
+{
+  AndExpression() ( "^" AndExpression() )*
+}
+
+void AndExpression() :
+{}
+{
+  EqualityExpression() ( "&" EqualityExpression() )*
+}
+
+void EqualityExpression() :
+{}
+{
+  InstanceOfExpression() ( ( "==" | "!=" ) InstanceOfExpression() )*
+}
+
+void InstanceOfExpression() :
+{}
+{
+  RelationalExpression() [ "instanceof" Type() ]
+}
+
+void RelationalExpression() :
+{}
+{
+  ShiftExpression() ( ( "<" | ">" | "<=" | ">=" ) ShiftExpression() )*
+}
+
+void ShiftExpression() :
+{}
+{
+  AdditiveExpression() ( ( "<<" | ">>" | ">>>" ) AdditiveExpression() )*
+}
+
+void AdditiveExpression() :
+{}
+{
+  MultiplicativeExpression() ( ( "+" | "-" ) MultiplicativeExpression() )*
+}
+
+void MultiplicativeExpression() :
+{}
+{
+  UnaryExpression() ( ( "*" | "/" | "%" ) UnaryExpression() )*
+}
+
+void UnaryExpression() :
+{}
+{
+  ( "+" | "-" ) UnaryExpression()
+|
+  PreIncrementExpression()
+|
+  PreDecrementExpression()
+|
+  LOOKAHEAD(1, <BOOLEAN> | <BYTE> | <CHAR> | <DOUBLE> | <FALSE> | <FLOAT> |
+               <INT> | <LONG> | <NEW> | <NULL> | <SHORT> | <SUPER> | <THIS> |
+               <TRUE> | <VOID> | <INTEGER_LITERAL> | <FLOATING_POINT_LITERAL> |
+               <CHARACTER_LITERAL> | <STRING_LITERAL> | <IDENTIFIER> |
+               <LPAREN> | <BANG> | <TILDE>)
+  UnaryExpressionNotPlusMinus()
+}
+
+void PreIncrementExpression() :
+{}
+{
+  "++" PrimaryExpression()
+}
+
+void PreDecrementExpression() :
+{}
+{
+  "--" PrimaryExpression()
+}
+
+void UnaryExpressionNotPlusMinus() :
+{}
+{
+  ( "~" | "!" ) UnaryExpression()
+|
+  LOOKAHEAD( { isTypeCast() } )
+  CastExpression()
+|
+  LOOKAHEAD(1, <BOOLEAN> | <BYTE> | <CHAR> | <DOUBLE> | <FALSE> | <FLOAT> |
+               <INT> | <LONG> | <NEW> | <NULL> | <SHORT> | <SUPER> | <THIS> |
+               <TRUE> | <VOID> | <INTEGER_LITERAL> | <FLOATING_POINT_LITERAL> |
+               <CHARACTER_LITERAL> | <STRING_LITERAL> | <IDENTIFIER> | <LPAREN>)
+  PostfixExpression()
+}
+
+void PostfixExpression() :
+{}
+{
+  PrimaryExpression() [ "++" | "--" ]
+}
+
+void CastExpression() :
+{}
+{
+  LOOKAHEAD( { isPrimitiveTypeCast() } )
+  "(" Type() ")" UnaryExpression()
+|
+  "(" Type() ")" UnaryExpressionNotPlusMinus()
+}
+
+void PrimaryExpression() :
+{}
+{
+  PrimaryPrefix() ( LOOKAHEAD( { isPrimarySuffix() } ) PrimarySuffix() )*
+}
+
+void PrimaryPrefix() :
+{}
+{
+  Literal()
+|
+  "this"
+|
+  "super" "." <IDENTIFIER>
+|
+  "(" Expression() ")"
+|
+  LOOKAHEAD(1, <NEW>)
+  AllocationExpression()
+|
+  LOOKAHEAD( { isClassSelector() } )
+  ResultType() "." "class"
+|
+  Name()
+}
+
+void PrimarySuffix() :
+{}
+{
+  LOOKAHEAD( { getToken(1).kind == DOT && getToken(2).kind == THIS } )
+  "." "this"
+|
+  LOOKAHEAD( { getToken(1).kind == DOT && getToken(2).kind == NEW } )
+  "." AllocationExpression()
+|
+  "[" Expression() "]"
+|
+  "." <IDENTIFIER>
+|
+  Arguments()
+}
+
+void Literal() :
+{}
+{
+  <INTEGER_LITERAL>
+|
+  <FLOATING_POINT_LITERAL>
+|
+  <CHARACTER_LITERAL>
+|
+  <STRING_LITERAL>
+|
+  BooleanLiteral()
+|
+  NullLiteral()
+}
+
+void BooleanLiteral() :
+{}
+{
+  "true"
+|
+  "false"
+}
+
+void NullLiteral() :
+{}
+{
+  "null"
+}
+
+void Arguments() :
+{}
+{
+  "("
+    [
+      LOOKAHEAD(1, <BOOLEAN> | <BYTE> | <CHAR> | <DOUBLE> | <FALSE> | <FLOAT> |
+                   <INT> | <LONG> | <NEW> | <NULL> | <SHORT> | <SUPER> | <THIS> |
+                   <TRUE> | <VOID> | <INTEGER_LITERAL> | <FLOATING_POINT_LITERAL> |
+                   <CHARACTER_LITERAL> | <STRING_LITERAL> | <IDENTIFIER> | <LPAREN> |
+                   <BANG> | <TILDE> | <INCR> | <DECR> | <PLUS> | <MINUS>)
+      ArgumentList()
+    ]
+  ")"
+}
+
+void ArgumentList() :
+{}
+{
+  Expression() ( "," Expression() )*
+}
+
+void AllocationExpression() :
+{}
+{
+  LOOKAHEAD( { getToken(2).kind != IDENTIFIER } )
+  "new" PrimitiveType() ArrayDimsAndInits()
+|
+  "new" Name()
+    (
+      LOOKAHEAD(1, <LBRACKET>)
+      ArrayDimsAndInits()
+    |
+      Arguments() [ ClassBody() ]
+    )
+}
+
+/*
+ * The third LOOKAHEAD specification below is to parse to PrimarySuffix
+ * if there is an expression between the "[...]".
+ */
+void ArrayDimsAndInits() :
+{}
+{
+  LOOKAHEAD( { getToken(2).kind != RBRACKET } )
+  ( LOOKAHEAD( { getToken(1).kind == LBRACKET && getToken(2).kind != RBRACKET } )
+    "[" Expression() "]"
+  )+
+  ( LOOKAHEAD( { getToken(1).kind == LBRACKET && getToken(2).kind == RBRACKET } )
+    "[" "]"
+  )*
+|
+  ( "[" "]" )+ ArrayInitializer()
+}
+
+
+/*
+ * Statement syntax follows.
+ */
+
+void Statement() :
+{}
+{
+  LOOKAHEAD( { getToken(1).kind == IDENTIFIER && getToken(2).kind == COLON } )
+  LabeledStatement()
+|
+  Block()
+|
+  EmptyStatement()
+|
+  LOOKAHEAD(1, <BOOLEAN> | <BYTE> | <CHAR> | <DOUBLE> | <FALSE> | <FLOAT> |
+               <INT> | <LONG> | <NEW> | <NULL> | <SHORT> | <SUPER> | <THIS> |
+               <TRUE> | <VOID> | <INTEGER_LITERAL> | <FLOATING_POINT_LITERAL> |
+               <CHARACTER_LITERAL> | <STRING_LITERAL> | <IDENTIFIER> |
+               <LPAREN> | <INCR> | <DECR>)
+  StatementExpression() ";"
+|
+  SwitchStatement()
+|
+  IfStatement()
+|
+  WhileStatement()
+|
+  DoStatement()
+|
+  ForStatement()
+|
+  BreakStatement()
+|
+  ContinueStatement()
+|
+  ReturnStatement()
+|
+  ThrowStatement()
+|
+  SynchronizedStatement()
+|
+  TryStatement()
+}
+
+void LabeledStatement() :
+{}
+{
+  <IDENTIFIER> ":" Statement()
+}
+
+void Block() :
+{}
+{
+  "{"
+    (
+      LOOKAHEAD(1, <BOOLEAN> | <BREAK> | <BYTE> | <CHAR> | <CLASS> | <CONTINUE> |
+                   <DO> | <DOUBLE> | <FALSE> | <FINAL> | <FLOAT> | <FOR> | <IF> |
+                   <INT> | <LONG> | <NEW> | <NULL> | <RETURN> | <SHORT> | <SUPER> |
+                   <SWITCH> | <SYNCHRONIZED> | <THIS> | <THROW> | <TRUE> | <TRY> |
+                   <VOID> | <WHILE> | <INTEGER_LITERAL> | <FLOATING_POINT_LITERAL> |
+                   <CHARACTER_LITERAL> | <STRING_LITERAL> | <IDENTIFIER> |
+                   <LPAREN> | <LBRACE> | <SEMICOLON> | <INCR> | <DECR>)
+      BlockStatement()
+    )*
+  "}"
+}
+
+void BlockStatement() :
+{}
+{
+  LOOKAHEAD( { isLocalVariableDeclaration() } )
+  LocalVariableDeclaration() ";"
+|
+  LOOKAHEAD(1, <BOOLEAN> | <BREAK> | <BYTE> | <CHAR> | <CONTINUE> | <DO> |
+               <DOUBLE> | <FALSE> | <FLOAT> | <FOR> | <IF> | <INT> | <LONG> |
+               <NEW> | <NULL> | <RETURN> | <SHORT> | <SUPER> | <SWITCH> |
+               <SYNCHRONIZED> | <THIS> | <THROW> | <TRUE> | <TRY> | <VOID> |
+               <WHILE> | <INTEGER_LITERAL> | <FLOATING_POINT_LITERAL> |
+               <CHARACTER_LITERAL> | <STRING_LITERAL> | <IDENTIFIER> | <LPAREN> |
+               <LBRACE> | <SEMICOLON> | <INCR> | <DECR>)
+  Statement()
+|
+  UnmodifiedClassDeclaration()
+|
+  UnmodifiedInterfaceDeclaration()
+}
+
+void LocalVariableDeclaration() :
+{}
+{
+  [ "final" ] 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()
+|
+  LOOKAHEAD(1, <BOOLEAN> | <BYTE> | <CHAR> | <DOUBLE> | <FALSE> | <FLOAT> |
+               <INT> | <LONG> | <NEW> | <NULL> | <SHORT> | <SUPER> | <THIS> |
+               <TRUE> | <VOID> | <INTEGER_LITERAL> | <FLOATING_POINT_LITERAL> |
+               <CHARACTER_LITERAL> | <STRING_LITERAL> | <IDENTIFIER> | <LPAREN>)
+  PrimaryExpression()
+  [
+    "++"
+  |
+    "--"
+  |
+    AssignmentOperator() Expression()
+  ]
+}
+
+void SwitchStatement() :
+{}
+{
+  "switch" "(" Expression() ")" "{"
+    (
+      SwitchLabel()
+      (
+        LOOKAHEAD(1, <BOOLEAN> | <BREAK> | <BYTE> | <CHAR> | <CLASS> | <CONTINUE> |
+                     <DO> | <DOUBLE> | <FALSE> | <FINAL> | <FLOAT> | <FOR> | <IF> |
+                     <INT> | <LONG> | <NEW> | <NULL> | <RETURN> | <SHORT> | <SUPER> |
+                     <SWITCH> | <SYNCHRONIZED> | <THIS> | <THROW> | <TRUE> | <TRY> |
+                     <VOID> | <WHILE> | <INTEGER_LITERAL> | <FLOATING_POINT_LITERAL> |
+                     <CHARACTER_LITERAL> | <STRING_LITERAL> | <IDENTIFIER> |
+                     <LPAREN> | <LBRACE> | <SEMICOLON> | <INCR> | <DECR>)
+        BlockStatement()
+      )*
+    )*
+  "}"
+}
+
+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" "(" Expression() ")" Statement() [ LOOKAHEAD(1) "else" Statement() ]
+}
+
+void WhileStatement() :
+{}
+{
+  "while" "(" Expression() ")" Statement()
+}
+
+void DoStatement() :
+{}
+{
+  "do" Statement() "while" "(" Expression() ")" ";"
+}
+
+void ForStatement() :
+{}
+{
+  "for" "("
+    [
+      LOOKAHEAD(1, <BOOLEAN> | <BYTE> | <CHAR> | <DOUBLE> | <FALSE> | <FINAL> |
+                   <FLOAT> | <INT> | <LONG> | <NEW> | <NULL> | <SHORT> | <SUPER> |
+                   <THIS> | <TRUE> | <VOID> | <INTEGER_LITERAL> |
+                   <FLOATING_POINT_LITERAL> | <CHARACTER_LITERAL> | <STRING_LITERAL> |
+                   <IDENTIFIER> | <LPAREN> | <INCR> | <DECR>)
+      ForInit()
+    ]
+    ";"
+    [
+      LOOKAHEAD(1, <BOOLEAN> | <BYTE> | <CHAR> | <DOUBLE> | <FALSE> | <FLOAT> |
+                   <INT> | <LONG> | <NEW> | <NULL> | <SHORT> | <SUPER> | <THIS> |
+                   <TRUE> | <VOID> | <INTEGER_LITERAL> | <FLOATING_POINT_LITERAL> |
+                   <CHARACTER_LITERAL> | <STRING_LITERAL> | <IDENTIFIER> | <LPAREN> |
+                   <BANG> | <TILDE> | <INCR> | <DECR> | <PLUS> | <MINUS>)
+      Expression()
+    ]
+    ";"
+    [
+      LOOKAHEAD(1, <BOOLEAN> | <BYTE> | <CHAR> | <DOUBLE> | <FALSE> | <FLOAT> |
+                   <INT> | <LONG> | <NEW> | <NULL> | <SHORT> | <SUPER> | <THIS> |
+                   <TRUE> | <VOID> | <INTEGER_LITERAL> | <FLOATING_POINT_LITERAL> |
+                   <CHARACTER_LITERAL> | <STRING_LITERAL> | <IDENTIFIER> | <LPAREN> |
+                   <INCR> | <DECR>)
+      ForUpdate()
+    ]
+    ")"
+    Statement()
+}
+
+void ForInit() :
+{}
+{
+  LOOKAHEAD( { isLocalVariableDeclaration() } )
+  LocalVariableDeclaration()
+|
+  LOOKAHEAD(1, <BOOLEAN> | <BYTE> | <CHAR> | <DOUBLE> | <FALSE> | <FLOAT> |
+               <INT> | <LONG> | <NEW> | <NULL> | <SHORT> | <SUPER> | <THIS> |
+               <TRUE> | <VOID> | <INTEGER_LITERAL> | <FLOATING_POINT_LITERAL> |
+               <CHARACTER_LITERAL> | <STRING_LITERAL> | <IDENTIFIER> | <LPAREN> |
+               <INCR> | <DECR>)
+  StatementExpressionList()
+}
+
+void StatementExpressionList() :
+{}
+{
+  StatementExpression() ( "," StatementExpression() )*
+}
+
+void ForUpdate() :
+{}
+{
+  StatementExpressionList()
+}
+
+void BreakStatement() :
+{}
+{
+  "break" [ <IDENTIFIER> ] ";"
+}
+
+void ContinueStatement() :
+{}
+{
+  "continue" [ <IDENTIFIER> ] ";"
+}
+
+void ReturnStatement() :
+{}
+{
+  "return"
+  [
+    LOOKAHEAD(1, <BOOLEAN> | <BYTE> | <CHAR> | <DOUBLE> | <FALSE> | <FLOAT> |
+                 <INT> | <LONG> | <NEW> | <NULL> | <SHORT> | <SUPER> | <THIS> |
+                 <TRUE> | <VOID> | <INTEGER_LITERAL> | <FLOATING_POINT_LITERAL> |
+                 <CHARACTER_LITERAL> | <STRING_LITERAL> | <IDENTIFIER> | <LPAREN> |
+                 <BANG> | <TILDE> | <INCR> | <DECR> | <PLUS> | <MINUS>)
+    Expression()
+  ]
+  ";"
+}
+
+void ThrowStatement() :
+{}
+{
+  "throw" Expression() ";"
+}
+
+void SynchronizedStatement() :
+{}
+{
+  "synchronized" "(" Expression() ")" Block()
+}
+
+void TryStatement() :
+/*
+ * Semantic check required here to make sure that at least one
+ * finally/catch is present.
+ */
+{}
+{
+  "try" Block()
+  ( "catch" "(" FormalParameter() ")" Block() )*
+  [ "finally" Block() ]
+}
diff --git a/tools/javacc-4.0/examples/JavaGrammars/OPTIMIZING b/tools/javacc-4.0/examples/JavaGrammars/OPTIMIZING
new file mode 100644
index 0000000000000000000000000000000000000000..6d1db834abd28d07556d25aed2951fa82fe2b682
--- /dev/null
+++ b/tools/javacc-4.0/examples/JavaGrammars/OPTIMIZING
@@ -0,0 +1,262 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+This file describes in a step by step manner how you can modify the
+lookaheads in your grammar to optimize for space in the generated
+parser.  This is only necessary until JavaCC is improved to do this
+optimization automatically (at which time, we will delete this file).
+
+1. How much space optimization can one expect?
+
+The optimizations that we show here gets rid of all methods in the
+generated parser which start with "jj_2" and "jj_3" respectively.  So
+take a look at your generated parser and figure out how much space is
+occupied by these methods.  When we performed this optimization on the
+Java grammar, we were able to decrease the size of the generated
+parser by more than 50%.
+
+2. Why are "jj_2" and "jj_3" methods generated?
+
+These methods are generated to handle all lookaheads except the
+following:
+
+a. A syntactic lookahead of 1 (the most common situation).
+b. For any amount of syntactic lookahead - when the target expansion can
+   match the empty string.
+c. When the syntactic lookahead is 0.  Typically there is only semantic
+   lookahead this situation.
+
+The "jj_2" and "jj_3" methods are also generated for lookaheads in the
+(a) and (b) categories above when hoisting of semantic predicates is
+required.
+
+3. Summary of how we achieve the optimization:
+
+Essentially, we go through the entire grammar looking for choice
+points that are not one of (a), (b), or (c) above.  We then replace
+the lookaheads at these points with one of kind (c) above.
+
+When we do this, JavaCC generates a parser where all the new semantic
+lookaheads causes hoisting which affect other related choice points
+and cause the "jj_2" and "jj_3" methods to be generated there.
+
+So the final step is to locate these related choice points and insert
+explicit lookahead specifications here to prevent hoisting from taking
+place.
+
+4. When is a grammar amenable to such optimization?
+
+If the majority of the choice points in your grammar use lookaheads
+that fall into the categories (a), (b), or (c) above then go for it.
+Otherwise, you'll be spending too much work and essentially rewriting
+the entire parser.  It took a few hours to optimize the Java grammar.
+But I would not recommend doing it for C++ (for C++, just wait for
+JavaCC to be upgraded to do it automatically).
+
+5. Step by step instructions:
+
+Suppose your grammar file is called Grammar.jj.  You are going to go
+through two steps - in the first step, you create Grammar1.jj, and
+in the second step you create the final grammar file - Grammar2.jj.
+Lets also assume that the parsers generated from these grammar files
+are Grammar.java, Grammar1.java, and Grammar2.java respectively.
+
+STEP 1:
+
+For every lookahead in your grammar that does not fit into categories
+(a), (b), or (c) above, replace it with an equivalent semantic
+lookahead.  When you're done with all such replacements, the resulting
+file is Grammar1.jj.
+
+Example:
+
+In the Java1.1.jj grammar, we have the following production for Name:
+
+void Name() :
+{}
+{
+  <IDENTIFIER>
+  ( LOOKAHEAD(2)
+    "." <IDENTIFIER>
+  )*
+}
+
+It uses a lookahead of 2 - obviously this means that the choice
+selection succeeds only if the next two characters are a "." and
+an <IDENTIFIER>.  The following modification replaces the syntactic
+lookahead with a semantic lookahead:
+
+void Name() :
+{}
+{
+  <IDENTIFIER>
+  ( LOOKAHEAD( { getToken(1).kind == DOT && getToken(2).kind == IDENTIFIER } )
+    "." <IDENTIFIER>
+  )*
+}
+
+STEP 2:
+
+Run JavaCC on both Grammar.jj and Grammar1.jj to obtain Grammar.java
+and Grammar1.java.  Remember, the goal is to get rid of "jj_2" and
+"jj_3" methods from the grammar.  Changes are you will see a bunch of
+"jj_2" and "jj_3" methods in Grammar1.java.  We need to focus only
+on the "jj_2" methods.  When these methods are removed, the "jj_3"
+methods automatically go away too.  In the Java grammar, we found 23
+"jj_2" methods to get rid of in this step.
+
+Search for calls to "jj_2" methods in Grammar1.java.  Locate the
+corresponding portions in Grammar1.jj (the choice points in the grammar
+corresponding to these calls).  These calls are there to perform
+hoisting (which you don't want - you don't need to understand hoisting
+to perform this step).
+
+Now look for corresponding locations in Grammar.java.  You will see
+references to a token mask array instead of a "jj_2" call at these
+locations.  Take a look at the value of the token mask array.  Use
+these values to create a new lookahead for this choice point to get
+rid of the "jj_2" call.
+
+The resulting grammar (Grammar2.jj) is the grammar you want.
+
+Obviously, we need an example:
+
+The Java parser generated after performing step 1 has the following
+method with a call to a "jj_2" method ("jj_2_3"):
+
+  static final public void UnmodifiedInterfaceDeclaration() throws ParseException {
+    jj_consume_token(INTERFACE);
+    jj_consume_token(IDENTIFIER);
+    if (jj_mask_29[getToken(1).kind]) {
+      jj_consume_token(EXTENDS);
+      NameList();
+    } else {
+      jj_expLA1[29] = jj_gen;
+      ;
+    }
+    jj_consume_token(LBRACE);
+    label_8:
+    while (true) {
+      if (jj_2_3(1)) {
+        ;
+      } else {
+        break label_8;
+      }
+      InterfaceMemberDeclaration();
+    }
+    jj_consume_token(RBRACE);
+  }
+
+The corresponding location in the Java grammar is:
+
+void UnmodifiedInterfaceDeclaration() :
+{}
+{
+  "interface" <IDENTIFIER> [ "extends" NameList() ]
+  "{"
+    ( // <-- the choice point
+      InterfaceMemberDeclaration()
+    )*
+  "}"
+}
+
+The choice point corresponding to the call to "jj_2_3" above is
+marked by the arrow.
+
+Now lets take a look at the parser generated from the original Java
+grammar.  The above method is shown below:
+
+  static final public void UnmodifiedInterfaceDeclaration() throws ParseException {
+    jj_consume_token(INTERFACE);
+    jj_consume_token(IDENTIFIER);
+    if (jj_mask_40[getToken(1).kind]) {
+      jj_consume_token(EXTENDS);
+      NameList();
+    } else {
+      jj_expLA1[40] = jj_gen;
+      ;
+    }
+    jj_consume_token(LBRACE);
+    label_9:
+    while (true) {
+      if (jj_mask_41[getToken(1).kind]) {
+        ;
+      } else {
+        jj_expLA1[41] = jj_gen;
+        break label_9;
+      }
+      InterfaceMemberDeclaration();
+    }
+    jj_consume_token(RBRACE);
+  }
+
+Instead of the call to "jj_2_3", there is a reference to the token
+mask array "jj_mask_41".  Now take a look at the initialization of
+"jj_mask_41" that occurs a few lines further on:
+
+  static boolean[] jj_mask_41 = new boolean[120];
+  static {
+    jj_mask_41[ABSTRACT] =
+    jj_mask_41[BOOLEAN] =
+    jj_mask_41[BYTE] =
+    jj_mask_41[CHAR] =
+    jj_mask_41[CLASS] =
+    jj_mask_41[DOUBLE] =
+    jj_mask_41[FINAL] =
+    jj_mask_41[FLOAT] =
+    jj_mask_41[INT] =
+    jj_mask_41[INTERFACE] =
+    jj_mask_41[LONG] =
+    jj_mask_41[NATIVE] =
+    jj_mask_41[PRIVATE] =
+    jj_mask_41[PROTECTED] =
+    jj_mask_41[PUBLIC] =
+    jj_mask_41[SHORT] =
+    jj_mask_41[STATIC] =
+    jj_mask_41[SYNCHRONIZED] =
+    jj_mask_41[TRANSIENT] =
+    jj_mask_41[VOID] =
+    jj_mask_41[VOLATILE] =
+    jj_mask_41[IDENTIFIER] = true;
+  }
+
+This defines the tokens that must be matched at the choice point
+in order for that choice point to succeed.  Use this to explicitly
+insert a lookahead specification into the grammar to prevent the
+hoisting of semantic predicates.  Hence the resulting production
+in the final grammar is:
+
+void UnmodifiedInterfaceDeclaration() :
+{}
+{
+  "interface" <IDENTIFIER> [ "extends" NameList() ]
+  "{"
+    (
+      LOOKAHEAD(1, <ABSTRACT> | <BOOLEAN> | <BYTE> | <CHAR> | <CLASS> | <DOUBLE> |
+                   <FINAL> | <FLOAT> | <INT> | <INTERFACE> | <LONG> | <NATIVE> |
+                   <PRIVATE> | <PROTECTED> | <PUBLIC> | <SHORT> | <STATIC> |
+                   <SYNCHRONIZED> | <TRANSIENT> | <VOID> | <VOLATILE> | <IDENTIFIER>)
+      InterfaceMemberDeclaration()
+    )*
+  "}"
+}
diff --git a/tools/javacc-4.0/examples/JavaGrammars/README b/tools/javacc-4.0/examples/JavaGrammars/README
new file mode 100644
index 0000000000000000000000000000000000000000..d842d75cd4c2195402afd801f9336db798d16e4f
--- /dev/null
+++ b/tools/javacc-4.0/examples/JavaGrammars/README
@@ -0,0 +1,66 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+This directory contains a bunch of Java grammars:
+
+Java1.0.2.jj:
+	This is our most thoroughly tested Java grammar.  It is a
+	faithful rendering of the language syntax as specified by the
+	Java Language Specification by Gosling, Joy, and Steele.
+
+Java.1.0.2LS.jj:
+	This is a minor modification of Java1.0.2.jj which uses
+	lexical states to express the comment tokens.  While this is a
+	cleaner grammar, it has not been tested as thoroughly as the
+	previous grammar.  Over time, we will make this grammar our
+	primary grammar and delete Java1.0.2.jj.
+
+Java1.1.jj:
+	This is the grammar that includes the Java 1.1 language
+	extensions.  It is based on the Java Language Specification
+	by Gosling, Joy, and Steele augmented by the inner class
+	document released with JDK 1.1.
+
+Java1.1noLA.jj:
+	Same as Java1.1.jj, but all explicit syntactic lookaheads
+	are replaced by semantic lookaheads to minimize the space
+	requirements of the generated parser.  To do the same kind
+	of optimization for your grammar, please see file OPTIMIZING
+	in this directory.
+
+To build a parser from a .jj file, simply type:
+
+  "javacc <grammar-file>"
+
+in this directory.  The files that comprise the Java parser are
+generated into this directory.
+
+Compile these files using "javac".
+
+JavaParser.java contains a main program that takes input from either
+the standard input or from the file specified as the argument to
+"java".  i.e., A Java program can be parser in either of the following
+ways:
+
+  java JavaParser < javafile
+  java JavaParser javafile
diff --git a/tools/javacc-4.0/examples/JavaGrammars/Test.java b/tools/javacc-4.0/examples/JavaGrammars/Test.java
new file mode 100644
index 0000000000000000000000000000000000000000..3f45a9ec336493d9d2bb7635c32ae36352e9d556
--- /dev/null
+++ b/tools/javacc-4.0/examples/JavaGrammars/Test.java
@@ -0,0 +1,15 @@
+import java.io.*;
+
+class Test
+{
+   public static void main(String[] args) throws Exception
+   {
+      Reader fr = null;
+      if (args.length == 2)
+         fr = new InputStreamReader(new FileInputStream(new File(args[0])), args[1]);
+      else
+         fr = new InputStreamReader(new FileInputStream(new File(args[0])));
+      JavaParser jp = new JavaParser(fr);
+      jp.CompilationUnit();
+   }
+}
diff --git a/tools/javacc-4.0/examples/Lookahead/Example1.jj b/tools/javacc-4.0/examples/Lookahead/Example1.jj
new file mode 100644
index 0000000000000000000000000000000000000000..0934817de6c028ef24c2c71abd7cd7922c587423
--- /dev/null
+++ b/tools/javacc-4.0/examples/Lookahead/Example1.jj
@@ -0,0 +1,56 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+
+PARSER_BEGIN(Example)
+
+public class Example {
+
+  public static void main(String args[]) throws ParseException {
+    Example parser = new Example(System.in);
+    parser.Input();
+  }
+
+}
+
+PARSER_END(Example)
+
+SKIP :
+{
+  " "
+| "\t"
+| "\n"
+| "\r"
+}
+
+void Input() :
+{}
+{
+  "a" BC() "c"
+}
+
+void BC() :
+{}
+{
+  "b" [ "c" ]
+}
diff --git a/tools/javacc-4.0/examples/Lookahead/Example10.jj b/tools/javacc-4.0/examples/Lookahead/Example10.jj
new file mode 100644
index 0000000000000000000000000000000000000000..79491e05e75c914dabf9e3944f14912725610769
--- /dev/null
+++ b/tools/javacc-4.0/examples/Lookahead/Example10.jj
@@ -0,0 +1,64 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+
+PARSER_BEGIN(Example)
+
+public class Example {
+
+  public static void main(String args[]) throws ParseException {
+    Example parser = new Example(System.in);
+    parser.IfStm();
+  }
+
+}
+
+PARSER_END(Example)
+
+SKIP :
+{
+  " "
+| "\t"
+| "\n"
+| "\r"
+}
+
+void IfStm() :
+{}
+{
+ "if" C() S() [ "else" S() ]
+}
+
+void C() :
+{}
+{
+  "TBD"
+}
+
+void S() :
+{}
+{
+  "TBD"
+|
+  IfStm()
+}
diff --git a/tools/javacc-4.0/examples/Lookahead/Example2.jj b/tools/javacc-4.0/examples/Lookahead/Example2.jj
new file mode 100644
index 0000000000000000000000000000000000000000..90bf1b469236a214be5ecfb0555b279dc0bed1bf
--- /dev/null
+++ b/tools/javacc-4.0/examples/Lookahead/Example2.jj
@@ -0,0 +1,65 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+
+PARSER_BEGIN(Example)
+
+public class Example {
+
+  public static void main(String args[]) throws ParseException {
+    Example parser = new Example(System.in);
+    parser.basic_expr();
+  }
+
+}
+
+PARSER_END(Example)
+
+SKIP :
+{
+  " "
+| "\t"
+| "\n"
+| "\r"
+}
+
+TOKEN [IGNORE_CASE] :
+{
+  <ID: (["a"-"z"])+>
+}
+
+void basic_expr() :
+{}
+{
+  <ID> "(" expr() ")"
+|
+  "(" expr() ")"
+|
+  "new" <ID>
+}
+
+void expr() :
+{}
+{
+  "TBD"
+}
diff --git a/tools/javacc-4.0/examples/Lookahead/Example3.jj b/tools/javacc-4.0/examples/Lookahead/Example3.jj
new file mode 100644
index 0000000000000000000000000000000000000000..54e047ec9b7bba7db6d618437205c5210f524c96
--- /dev/null
+++ b/tools/javacc-4.0/examples/Lookahead/Example3.jj
@@ -0,0 +1,67 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+
+PARSER_BEGIN(Example)
+
+public class Example {
+
+  public static void main(String args[]) throws ParseException {
+    Example parser = new Example(System.in);
+    parser.basic_expr();
+  }
+
+}
+
+PARSER_END(Example)
+
+SKIP :
+{
+  " "
+| "\t"
+| "\n"
+| "\r"
+}
+
+void basic_expr() :
+{}
+{
+  <ID> "(" expr() ")"
+|
+  "(" expr() ")"
+|
+  "new" <ID>
+|
+  <ID> "." <ID>
+}
+
+void expr() :
+{}
+{
+  "TBD"
+}
+
+TOKEN [IGNORE_CASE] :
+{
+  <ID: (["a"-"z"])+>
+}
diff --git a/tools/javacc-4.0/examples/Lookahead/Example4.jj b/tools/javacc-4.0/examples/Lookahead/Example4.jj
new file mode 100644
index 0000000000000000000000000000000000000000..1af59f041064fd6609f46e63e38a4876c189b1eb
--- /dev/null
+++ b/tools/javacc-4.0/examples/Lookahead/Example4.jj
@@ -0,0 +1,55 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+
+PARSER_BEGIN(Example)
+
+public class Example {
+
+  public static void main(String args[]) throws ParseException {
+    Example parser = new Example(System.in);
+    parser.identifier_list();
+  }
+
+}
+
+PARSER_END(Example)
+
+SKIP :
+{
+  " "
+| "\t"
+| "\n"
+| "\r"
+}
+
+void identifier_list() :
+{}
+{
+  <ID> ( "," <ID> )*
+}
+
+TOKEN [IGNORE_CASE] :
+{
+  <ID: (["a"-"z"])+>
+}
diff --git a/tools/javacc-4.0/examples/Lookahead/Example5.jj b/tools/javacc-4.0/examples/Lookahead/Example5.jj
new file mode 100644
index 0000000000000000000000000000000000000000..aa20c6524dd1100c75c48ea9c7268992598a6199
--- /dev/null
+++ b/tools/javacc-4.0/examples/Lookahead/Example5.jj
@@ -0,0 +1,63 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+
+PARSER_BEGIN(Example)
+
+public class Example {
+
+  public static void main(String args[]) throws ParseException {
+    Example parser = new Example(System.in);
+    parser.funny_list();
+  }
+
+}
+
+PARSER_END(Example)
+
+SKIP :
+{
+  " "
+| "\t"
+| "\n"
+| "\r"
+}
+
+void identifier_list() :
+{}
+{
+  <ID> ( "," <ID> )*
+}
+
+void funny_list() :
+{}
+{
+  identifier_list() "," <INT>
+}
+
+TOKEN [IGNORE_CASE] :
+{
+  <ID: (["a"-"z"])+>
+|
+  <INT: (["0"-"9"])+>
+}
diff --git a/tools/javacc-4.0/examples/Lookahead/Example6.jj b/tools/javacc-4.0/examples/Lookahead/Example6.jj
new file mode 100644
index 0000000000000000000000000000000000000000..0030f721413e9d13f648767b6ba91defc4d7f4f8
--- /dev/null
+++ b/tools/javacc-4.0/examples/Lookahead/Example6.jj
@@ -0,0 +1,65 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+
+PARSER_BEGIN(Example)
+
+public class Example {
+
+  public static void main(String args[]) throws ParseException {
+    Example parser = new Example(System.in);
+    parser.basic_expr();
+  }
+
+}
+
+PARSER_END(Example)
+
+SKIP :
+{
+  " "
+| "\t"
+| "\n"
+| "\r"
+}
+
+void basic_expr() :
+{}
+{
+  <ID> ( "(" expr() ")" | "." <ID> )
+|
+  "(" expr() ")"
+|
+  "new" <ID>
+}
+
+void expr() :
+{}
+{
+  "TBD"
+}
+
+TOKEN [IGNORE_CASE] :
+{
+  <ID: (["a"-"z"])+>
+}
diff --git a/tools/javacc-4.0/examples/Lookahead/Example7.jj b/tools/javacc-4.0/examples/Lookahead/Example7.jj
new file mode 100644
index 0000000000000000000000000000000000000000..cd26c2b9e37c8ca1045cb817177c71d16eb6bc2f
--- /dev/null
+++ b/tools/javacc-4.0/examples/Lookahead/Example7.jj
@@ -0,0 +1,57 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+
+PARSER_BEGIN(Example)
+
+public class Example {
+
+  public static void main(String args[]) throws ParseException {
+    Example parser = new Example(System.in);
+    parser.funny_list();
+  }
+
+}
+
+PARSER_END(Example)
+
+SKIP :
+{
+  " "
+| "\t"
+| "\n"
+| "\r"
+}
+
+void funny_list() :
+{}
+{
+  <ID> "," ( <ID> "," )* <INT>
+}
+
+TOKEN [IGNORE_CASE] :
+{
+  <ID: (["a"-"z"])+>
+|
+  <INT: (["0"-"9"])+>
+}
diff --git a/tools/javacc-4.0/examples/Lookahead/Example8.jj b/tools/javacc-4.0/examples/Lookahead/Example8.jj
new file mode 100644
index 0000000000000000000000000000000000000000..48be767b38763accce63c10b6e4d91aa13a82a1f
--- /dev/null
+++ b/tools/javacc-4.0/examples/Lookahead/Example8.jj
@@ -0,0 +1,68 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+
+PARSER_BEGIN(Example)
+
+public class Example {
+
+  public static void main(String args[]) throws ParseException {
+    Example parser = new Example(System.in);
+    parser.basic_expr();
+  }
+
+}
+
+PARSER_END(Example)
+
+SKIP :
+{
+  " "
+| "\t"
+| "\n"
+| "\r"
+}
+
+void basic_expr() :
+{}
+{
+  LOOKAHEAD(2)
+  <ID> "(" expr() ")"
+|
+  "(" expr() ")"
+|
+  "new" <ID>
+|
+  <ID> "." <ID>
+}
+
+void expr() :
+{}
+{
+  "TBD"
+}
+
+TOKEN [IGNORE_CASE] :
+{
+  <ID: (["a"-"z"])+>
+}
diff --git a/tools/javacc-4.0/examples/Lookahead/Example9.jj b/tools/javacc-4.0/examples/Lookahead/Example9.jj
new file mode 100644
index 0000000000000000000000000000000000000000..a32fb6be7c2b0c173558d4375249fecdcd7cd892
--- /dev/null
+++ b/tools/javacc-4.0/examples/Lookahead/Example9.jj
@@ -0,0 +1,63 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+
+PARSER_BEGIN(Example)
+
+public class Example {
+
+  public static void main(String args[]) throws ParseException {
+    Example parser = new Example(System.in);
+    parser.funny_list();
+  }
+
+}
+
+PARSER_END(Example)
+
+SKIP :
+{
+  " "
+| "\t"
+| "\n"
+| "\r"
+}
+
+void identifier_list() :
+{}
+{
+  <ID> ( LOOKAHEAD(2) "," <ID> )*
+}
+
+void funny_list() :
+{}
+{
+  identifier_list() "," <INT>
+}
+
+TOKEN [IGNORE_CASE] :
+{
+  <ID: (["a"-"z"])+>
+|
+  <INT: (["0"-"9"])+>
+}
diff --git a/tools/javacc-4.0/examples/Lookahead/README b/tools/javacc-4.0/examples/Lookahead/README
new file mode 100644
index 0000000000000000000000000000000000000000..293d133faa3bfd7e2924a8f844d3f42fbbc369a9
--- /dev/null
+++ b/tools/javacc-4.0/examples/Lookahead/README
@@ -0,0 +1,818 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+This directory contains the tutorial on LOOKAHEAD along with all
+examples used in the tutorial.
+
+We assume that you have already taken a look at some of the simple
+examples provided in the release before you read this section.
+
+1. WHAT IS LOOKAHEAD?
+
+The job of a parser is to read an input stream and determine whether
+or not the input stream conforms to the grammar.
+
+This determination in its most general form can be quite time
+consuming.  Consider the following example (file Example1.jj):
+
+----------------------------------------------------------------
+
+	void Input() :
+	{}
+	{
+	  "a" BC() "c"
+	}
+
+	void BC() :
+	{}
+	{
+	  "b" [ "c" ]
+	}
+
+In this simple example, it is quite clear that there are exactly two
+strings that match the above grammar, namely:
+
+	abc
+	abcc
+
+The general way to perform this match is to walk through the grammar
+based on the string as follows.  Here, we use "abc" as the input
+string:
+
+Step 1. There is only one choice here - the first input character
+must be 'a' - and since that is indeed the case, we are OK.
+
+Step 2. We now proceed on to non-terminal BC.  Here again, there is
+only one choice for the next input character - it must be 'b'.  The
+input matches this one too, so we are still OK.
+
+Step 3. We now come to a "choice point" in the grammar.  We can either
+go inside the [...] and match it, or ignore it altogether.  We decide
+to go inside.  So the next input character must be a 'c'.  We are
+again OK.
+
+Step 4. Now we have completed with non-terminal BC and go back to
+non-terminal Input.  Now the grammar says the next character must be
+yet another 'c'.  But there are no more input characters.  So we have
+a problem.
+
+Step 5. When we have such a problem in the general case, we conclude
+that we may have made a bad choice somewhere.  In this case, we made
+the bad choice in Step 3.  So we retrace our steps back to step 3 and
+make another choice and try that.  This process is called
+"backtracking".
+
+Step 6. We have now backtracked and made the other choice we could
+have made at Step 3 - namely, ignore the [...].  Now we have completed
+with non-terminal BC and go back to non-terminal Input.  Now the
+grammar says the next character must be yet another 'c'.  The next
+input character is a 'c', so we are OK now.
+
+Step 7. We realize we have reached the end of the grammar (end of
+non-terminal Input) successfully.  This means we have successfully
+matched the string "abc" to the grammar.
+
+----------------------------------------------------------------
+
+As the above example indicates, the general problem of matching an
+input with a grammar may result in large amounts of backtracking and
+making new choices and this can consume a lot of time.  The amount of
+time taken can also be a function of how the grammar is written.  Note
+that many grammars can be written to cover the same set of inputs - or
+the same language (i.e., there can be multiple equivalent grammars for
+the same input language).
+
+----------------------------------------------------------------
+
+For example, the following grammar would speed up the parsing of the
+same language as compared to the previous grammar:
+
+	void Input() :
+	{}
+	{
+	  "a" "b" "c" [ "c" ]
+	}
+
+while the following grammar slows it down even more since the parser
+has to backtrack all the way to the beginning:
+
+	void Input() :
+	{}
+	{
+	  "a" "b" "c" "c"
+	|
+	  "a" "b" "c"
+	}
+
+One can even have a grammar that looks like the following:
+
+	void Input() :
+	{}
+	{
+	  "a" ( BC1() | BC2() )
+	}
+
+	void BC1() :
+	{}
+	{
+	  "b" "c" "c"
+	}
+
+	void BC2() :
+	{}
+	{
+	  "b" "c" [ "c" ]
+	}
+
+This grammar can match "abcc" in two ways, and is therefore considered
+"ambiguous".
+
+----------------------------------------------------------------
+
+The performance hit from such backtracking is unacceptable for most
+systems that include a parser.  Hence most parsers do not backtrack in
+this general manner (or do not backtrack at all), rather they make
+decisions at choice points based on limited information and then
+commit to it.
+
+Parsers generated by Java Compiler Compiler make decisions at choice
+points based on some exploration of tokens further ahead in the input
+stream, and once they make such a decision, they commit to it.  i.e.,
+No backtracking is performed once a decision is made.
+
+The process of exploring tokens further in the input stream is termed
+"looking ahead" into the input stream - hence our use of the term
+"LOOKAHEAD".
+
+Since some of these decisions may be made with less than perfect
+information (JavaCC will warn you in these situations, so you don't
+have to worry), you need to know something about LOOKAHEAD to make
+your grammar work correctly.
+
+The two ways in which you make the choice decisions work properly are:
+
+. Modify the grammar to make it simpler.
+
+. Insert hints at the more complicated choice points to help the
+  parser make the right choices.
+
+----------------------------------------------------------------
+
+2. CHOICE POINTS IN JAVACC GRAMMARS
+
+There are 4 different kinds of choice points in JavaCC:
+
+. An expansion of the form: ( exp1 | exp2 | ... ).  In this case, the
+  generated parser has to somehow determine which of exp1, exp2, etc.
+  to select to continue parsing.
+
+. An expansion of the form: ( exp )?.  In this case, the generated parser
+  must somehow determine whether to choose exp or to continue beyond
+  the ( exp )? without choosing exp.  Note: ( exp )? may also be written
+  as [ exp ].
+
+. An expansion of the form ( exp )*.  In this case, the generated parser
+  must do the same thing as in the previous case, and furthermore, after
+  each time a successful match of exp (if exp was chosen) is completed,
+  this choice determination must be made again.
+
+. An expansion of the form ( exp )+.  This is essentially similar to
+  the previous case with a mandatory first match to exp.
+
+Remember that token specifications that occur within angular
+brackets <...> also have choice points.  But these choices are made
+in different ways and are the subject of a different tutorial.
+
+----------------------------------------------------------------
+
+3. THE DEFAULT CHOICE DETERMINATION ALGORITHM
+
+The default choice determination algorithm looks ahead 1 token in the
+input stream and uses this to help make its choice at choice points.
+
+The following examples will describe the default algorithm fully:
+
+----------------------------------------------------------------
+
+Consider the following grammar (file Example2.jj):
+
+	void basic_expr() :
+	{}
+	{
+	  <ID> "(" expr() ")"	// Choice 1
+	|
+	  "(" expr() ")"	// Choice 2
+	|
+	  "new" <ID>		// Choice 3
+	}
+
+The choice determination algorithm works as follows:
+
+	if (next token is <ID>) {
+	  choose Choice 1
+	} else if (next token is "(") {
+	  choose Choice 2
+	} else if (next token is "new") {
+	  choose Choice 3
+	} else {
+	  produce an error message
+	}
+
+----------------------------------------------------------------
+
+In the above example, the grammar has been written such that the
+default choice determination algorithm does the right thing.  Another
+thing to note is that the choice determination algorithm works in a
+top to bottom order - if Choice 1 was selected, the other choices are
+not even considered.  While this is not an issue in this example
+(except for performance), it will become important later below when
+local ambiguities require the insertion of LOOKAHEAD hints.
+
+Suppose the above grammar was modified to (file Example3.jj):
+
+	void basic_expr() :
+	{}
+	{
+	  <ID> "(" expr() ")"	// Choice 1
+	|
+	  "(" expr() ")"	// Choice 2
+	|
+	  "new" <ID>		// Choice 3
+	|
+	  <ID> "." <ID>		// Choice 4
+	}
+
+Then the default algorithm will always choose Choice 1 when the next
+input token is <ID> and never choose Choice 4 even if the token
+following <ID> is a ".".  More on this later.
+
+You can try running the parser generated from Example3.jj on the input
+"id1.id2".  It will complain that it encountered a "." when it was
+expecting a "(".  Note - when you built the parser, it would have
+given you the following warning message:
+
+Warning: Choice conflict involving two expansions at
+         line 25, column 3 and line 31, column 3 respectively.
+         A common prefix is: <ID>
+         Consider using a lookahead of 2 for earlier expansion.
+
+Essentially, JavaCC is saying it has detected a situation in your
+grammar which may cause the default lookahead algorithm to do strange
+things.  The generated parser will still work using the default
+lookahead algorithm - except that it may not do what you expect of it.
+
+----------------------------------------------------------------
+
+Now consider the following example (file Example 4.jj):
+
+	void identifier_list() :
+	{}
+	{
+	  <ID> ( "," <ID> )*
+	}
+
+Suppose the first <ID> has already been matched and that the parser
+has reached the choice point (the (...)* construct).  Here's how the
+choice determination algorithm works:
+
+	while (next token is ",") {
+	  choose the nested expansion (i.e., go into the (...)* construct)
+	  consume the "," token
+	  if (next token is <ID>) consume it, otherwise report error
+	}
+
+----------------------------------------------------------------
+
+In the above example, note that the choice determination algorithm
+does not look beyond the (...)* construct to make its decision.
+Suppose there was another production in that same grammar as follows
+(file Example5.jj):
+
+	void funny_list() :
+	{}
+	{
+	  identifier_list() "," <INT>
+	}
+
+When the default algorithm is making a choice at ( "," <ID> )*, it
+will always go into the (...)* construct if the next token is a ",".
+It will do this even when identifier_list was called from funny_list
+and the token after the "," is an <INT>.  Intuitively, the right thing
+to do in this situation is to skip the (...)* construct and return to
+funny_list.  More on this later.
+
+As a concrete example, suppose your input was "id1, id2, 5", the
+parser will complain that it encountered a 5 when it was expecting an
+<ID>.  Note - when you built the parser, it would have given you the
+following warning message:
+
+Warning: Choice conflict in (...)* construct at line 25, column 8.
+         Expansion nested within construct and expansion following construct
+         have common prefixes, one of which is: ","
+         Consider using a lookahead of 2 or more for nested expansion.
+
+Essentially, JavaCC is saying it has detected a situation in your
+grammar which may cause the default lookahead algorithm to do strange
+things.  The generated parser will still work using the default
+lookahead algorithm - except that it may not do what you expect of it.
+
+----------------------------------------------------------------
+
+We have shown you examples of two kinds of choice points in the
+examples above - "exp1 | exp2 | ...", and "(exp)*".  The other two
+kinds of choice points - "(exp)+" and "(exp)?" - behave similarly to
+(exp)* and we will not be providing examples of their use here.
+
+----------------------------------------------------------------
+
+4. MULTIPLE TOKEN LOOKAHEAD SPECIFICATIONS
+
+So far, we have described the default lookahead algorithm of the
+generated parsers.  In the majority of situations, the default
+algorithm works just fine.  In situations where it does not work
+well, Java Compiler Compiler provides you with warning messages like
+the ones shown above.  If you have a grammar that goes through
+Java Compiler Compiler without producing any warnings, then the
+grammar is a LL(1) grammar.  Essentially, LL(1) grammars are those
+that can be handled by top-down parsers (such as those generated
+by Java Compiler Compiler) using at most one token of LOOKAHEAD.
+
+When you get these warning messages, you can do one of two things.
+
+----------------------------------------------------------------
+
+Option 1
+
+You can modify your grammar so that the warning messages go away.
+That is, you can attempt to make your grammar LL(1) by making some
+changes to it.
+
+The following (file Example6.jj) shows how you may change Example3.jj
+to make it LL(1):
+
+	void basic_expr() :
+	{}
+	{
+	  <ID> ( "(" expr() ")" | "." <ID> )
+	|
+	  "(" expr() ")"
+	|
+	  "new" <ID>
+	}
+
+What we have done here is to factor the fourth choice into the first
+choice.  Note how we have placed their common first token <ID> outside
+the parentheses, and then within the parentheses, we have yet another
+choice which can now be performed by looking at only one token in the
+input stream and comparing it with "(" and ".".  This process of
+modifying grammars to make them LL(1) is called "left factoring".
+
+The following (file Example7.jj) shows how Example5.jj may be changed
+to make it LL(1):
+
+	void funny_list() :
+	{}
+	{
+	  <ID> "," ( <ID> "," )* <INT>
+	}
+
+Note that this change is somewhat more drastic.
+
+----------------------------------------------------------------
+
+Option 2
+
+You can provide the generated parser with some hints to help it out
+in the non-LL(1) situations that the warning messages bring to your
+attention.
+
+All such hints are specified using either setting the global LOOKAHEAD
+value to a larger value (see below) or by using the LOOKAHEAD(...)
+construct to provide a local hint.
+
+A design decision must be made to determine if Option 1 or Option 2 is
+the right one to take.  The only advantage of choosing Option 1 is
+that it makes your grammar perform better.  JavaCC generated parsers
+can handle LL(1) constructs much faster than other constructs.
+However, the advantage of choosing Option 2 is that you have a simpler
+grammar - one that is easier to develop and maintain - one that
+focuses on human-friendliness and not machine-friendliness.
+
+Sometimes Option 2 is the only choice - especially in the presence of
+user actions.  Suppose Example3.jj contained actions as shown below:
+
+	void basic_expr() :
+	{}
+	{
+	  { initMethodTables(); } <ID> "(" expr() ")"
+	|
+	  "(" expr() ")"
+	|
+	  "new" <ID>
+	|
+	  { initObjectTables(); } <ID> "." <ID>
+	}
+
+Since the actions are different, left-factoring cannot be performed.
+
+----------------------------------------------------------------
+
+4.1. SETTING A GLOBAL LOOKAHEAD SPECIFICATION
+
+You can set a global LOOKAHEAD specification by using the option
+"LOOKAHEAD" either from the command line, or at the beginning of the
+grammar file in the options section.  The value of this option is an
+integer which is the number of tokens to look ahead when making choice
+decisions.  As you may have guessed, the default value of this option
+is 1 - which derives the default LOOKAHEAD algorithm described above.
+
+Suppose you set the value of this option to 2.  Then the LOOKAHEAD
+algorithm derived from this looks at two tokens (instead of just one
+token) before making a choice decision.  Hence, in Example3.jj, choice
+1 will be taken only if the next two tokens are <ID> and "(", while
+choice 4 will be taken only if the next two tokens are <ID> and ".".
+Hence, the parser will now work properly for Example3.jj.  Similarly,
+the problem with Example5.jj also goes away since the parser goes into
+the (...)* construct only when the next two tokens are "," and <ID>.
+
+By setting the global LOOKAHEAD to 2, the parsing algorithm
+essentially becomes LL(2).  Since you can set the global LOOKAHEAD to
+any value, parsers generated by Java Compiler Compiler are called
+LL(k) parsers.
+
+----------------------------------------------------------------
+
+4.2. SETTING A LOCAL LOOKAHEAD SPECIFICATION
+
+You can also set a local LOOKAHEAD specification that affects only a
+specific choice point.  This way, the majority of the grammar can
+remain LL(1) and hence perform better, while at the same time one gets
+the flexibility of LL(k) grammars.  Here's how Example3.jj is modified
+with local LOOKAHEAD to fix the choice ambiguity problem (file
+Example8.jj):
+
+	void basic_expr() :
+	{}
+	{
+	  LOOKAHEAD(2)
+	  <ID> "(" expr() ")"	// Choice 1
+	|
+	  "(" expr() ")"	// Choice 2
+	|
+	  "new" <ID>		// Choice 3
+	|
+	  <ID> "." <ID>		// Choice 4
+	}
+
+Only the first choice (the first condition in the translation below)
+is affected by the LOOKAHEAD specification.  All others continue to
+use a single token of LOOKAHEAD:
+
+	if (next 2 tokens are <ID> and "(" ) {
+	  choose Choice 1
+	} else if (next token is "(") {
+	  choose Choice 2
+	} else if (next token is "new") {
+	  choose Choice 3
+	} else if (next token is <ID>) {
+	  choose Choice 4
+	} else {
+	  produce an error message
+	}
+
+Similarily, Example5.jj can be modified as shown below (file
+Example9.jj):
+
+	void identifier_list() :
+	{}
+	{
+	  <ID> ( LOOKAHEAD(2) "," <ID> )*
+	}
+
+Note, the LOOKAHEAD specification has to occur inside the (...)* which
+is the choice is being made.  The translation for this construct is
+shown below (after the first <ID> has been consumed):
+
+	while (next 2 tokens are "," and <ID>) {
+	  choose the nested expansion (i.e., go into the (...)* construct)
+	  consume the "," token
+	  consume the <ID> token
+	}
+
+----------------------------------------------------------------
+
+We strongly discourage you from modifying the global LOOKAHEAD
+default.  Most grammars are predominantly LL(1), hence you will be
+unnecessarily degrading performance by converting the entire grammar
+to LL(k) to facilitate just some portions of the grammar that are not
+LL(1).  If your grammar and input files being parsed are very small,
+then this is okay.
+
+You should also keep in mind that the warning messages JavaCC prints
+when it detects ambiguities at choice points (such as the two messages
+shown earlier) simply tells you that the specified choice points are
+not LL(1).  JavaCC does not verify the correctness of your local
+LOOKAHEAD specification - it assumes you know what you are doing, in
+fact, it really cannot verify the correctness of local LOOKAHEAD's as
+the following example of if statements illustrates (file
+Example10.jj):
+
+	void IfStm() :
+	{}
+	{
+	 "if" C() S() [ "else" S() ]
+	}
+
+	void S() :
+	{}
+	{
+	  ...
+	|
+	  IfStm()
+	}
+
+This example is the famous "dangling else" problem.  If you have a
+program that looks like:
+
+	"if C1 if C2 S1 else S2"
+
+The "else S2" can be bound to either of the two if statements.  The
+standard interpretation is that it is bound to the inner if statement
+(the one closest to it).  The default choice determination algorithm
+happens to do the right thing, but it still prints the following
+warning message:
+
+Warning: Choice conflict in [...] construct at line 25, column 15.
+         Expansion nested within construct and expansion following construct
+         have common prefixes, one of which is: "else"
+         Consider using a lookahead of 2 or more for nested expansion.
+
+To suppress the warning message, you could simply tell JavaCC that
+you know what you are doing as follows:
+
+	void IfStm() :
+	{}
+	{
+	 "if" C() S() [ LOOKAHEAD(1) "else" S() ]
+	}
+
+To force lookahead ambiguity checking in such instances, set the option
+FORCE_LA_CHECK to true.
+
+----------------------------------------------------------------
+
+5. SYNTACTIC LOOKAHEAD
+
+Consider the following production taken from the Java grammar:
+
+	void TypeDeclaration() :
+	{}
+	{
+	  ClassDeclaration()
+	|
+	  InterfaceDeclaration()
+	}
+
+At the syntactic level, ClassDeclaration can start with any number of
+"abstract"s, "final"s, and "public"s.  While a subsequent semantic
+check will produce error messages for multiple uses of the same
+modifier, this does not happen until parsing is completely over.
+Similarly, InterfaceDeclaration can start with any number of
+"abstract"s and "public"s.
+
+What if the next tokens in the input stream are a very large number of
+"abstract"s (say 100 of them) followed by "interface"?  It is clear
+that a fixed amount of LOOKAHEAD (such as LOOKAHEAD(100) for example)
+will not suffice.  One can argue that this is such a wierd situation
+that it does not warrant any reasonable error message and that it is
+okay to make the wrong choice in some pathalogical situations.  But
+suppose one wanted to be precise about this.
+
+The solution here is to set the LOOKAHEAD to infinity - that is set no
+bounds on the number of tokens to look ahead.  One way to do this is
+to use a very large integer value (such as the largest possible
+integer) as follows:
+
+	void TypeDeclaration() :
+	{}
+	{
+	  LOOKAHEAD(2147483647)
+	  ClassDeclaration()
+	|
+	  InterfaceDeclaration()
+	}
+
+One can also achieve the same effect with "syntactic LOOKAHEAD".  In
+syntactic LOOKAHEAD, you specify an expansion to try out and it that
+succeeds, then the following choice is taken.  The above example is
+rewritten using syntactic LOOKAHEAD below:
+
+	void TypeDeclaration() :
+	{}
+	{
+	  LOOKAHEAD(ClassDeclaration())
+	  ClassDeclaration()
+	|
+	  InterfaceDeclaration()
+	}
+
+Essentially, what this is saying is:
+
+	if (the tokens from the input stream match ClassDeclaration) {
+	  choose ClassDeclaration()
+	} else if (next token matches InterfaceDeclaration) {
+	  choose InterfaceDeclaration()
+	} else {
+	  produce an error message
+	}
+
+The problem with the above syntactic LOOKAHEAD specification is that
+the LOOKAHEAD calculation takes too much time and does a lot of
+unnecessary checking.  In this case, the LOOKAHEAD calculation can
+stop as soon as the token "class" is encountered, but the
+specification forces the calculation to continue until the end of the
+class declaration has been reached - which is rather time consuming.
+This problem can be solved by placing a shorter expansion to try out
+in the syntactic LOOKAHEAD specification as in the following example:
+
+	void TypeDeclaration() :
+	{}
+	{
+	  LOOKAHEAD( ( "abstract" | "final" | "public" )* "class" )
+	  ClassDeclaration()
+	|
+	  InterfaceDeclaration()
+	}
+
+Essentially, what this is saying is:
+
+	if (the nest set of tokens from the input stream are a sequence of
+	    "abstract"s, "final"s, and "public"s followed by a "class") {
+	  choose ClassDeclaration()
+	} else if (next token matches InterfaceDeclaration) {
+	  choose InterfaceDeclaration()
+	} else {
+	  produce an error message
+	}
+
+By doing this, you make the choice determination algorithm stop as
+soon as it sees "class" - i.e., make its decision at the earliest
+possible time.
+
+You can place a bound on the number of tokens to consume during
+syntactic lookahead as follows:
+
+	void TypeDeclaration() :
+	{}
+	{
+	  LOOKAHEAD(10, ( "abstract" | "final" | "public" )* "class" )
+	  ClassDeclaration()
+	|
+	  InterfaceDeclaration()
+	}
+
+In this case, the LOOKAHEAD determination is not permitted to go beyond
+10 tokens.  If it reaches this limit and is still successfully matching
+( "abstract" | "final" | "public" )* "class", then ClassDeclaration is
+selected.
+
+Actually, when such a limit is not specified, it defaults to the largest
+integer value (2147483647).
+
+----------------------------------------------------------------
+
+6. SEMANTIC LOOKAHEAD
+
+Let us go back to Example1.jj:
+
+	void Input() :
+	{}
+	{
+	  "a" BC() "c"
+	}
+
+	void BC() :
+	{}
+	{
+	  "b" [ "c" ]
+	}
+
+Let us suppose that there is a good reason for writing a grammar this
+way (maybe the way actions are embedded).  As noted earlier, this
+grammar recognizes two string "abc" and "abcc".  The problem here is
+that the default LL(1) algorithm will choose the [ "c" ] everytime
+it sees a "c" and therefore "abc" will never be matched.  We need to
+specify that this choice must be made only when the next token is a
+"c", and the token following that is not a "c".  This is a negative
+statement - one that cannot be made using syntactic LOOKAHEAD.
+
+We can use semantic LOOKAHEAD for this purpose.  With semantic
+LOOKAHEAD, you can specify any arbitrary boolean expression whose
+evaluation determines which choice to take at a choice point.  The
+above example can be instrumented with semantic LOOKAHEAD as follows:
+
+	void BC() :
+	{}
+	{
+	  "b"
+	  [ LOOKAHEAD( { getToken(1).kind == C && getToken(2).kind != C } )
+	    <C:"c">
+	  ]
+	}
+
+First we give the token "c" a label C so that we can refer to it from
+the semantic LOOKAHEAD.  The boolean expression essentially states the
+desired property.  The choice determination decision is therefore:
+
+	if (next token is "c" and following token is not "c") {
+	  choose the nested expansion (i.e., go into the [...] construct)
+	} else {
+	  go beyond the [...] construct without entering it.
+	}
+
+This example can be rewritten to combine both syntactic and semantic
+LOOKAHEAD as follows (recognize the first "c" using syntactic
+LOOKAHEAD and the absence of the second using semantic LOOKAHEAD):
+
+	void BC() :
+	{}
+	{
+	  "b"
+	  [ LOOKAHEAD( "c", { getToken(2).kind != C } )
+	    <C:"c">
+	  ]
+	}
+
+----------------------------------------------------------------
+
+7. GENERAL STRUCTURE OF LOOKAHEAD
+
+We've pretty much covered the various aspects of LOOKAHEAD in the
+previous sections.  A couple of advanced topics follow.  However,
+we shall now present a formal language reference for LOOKAHEAD in
+Java Compiler Compiler:
+
+The general structure of a LOOKAHEAD specification is:
+
+	LOOKAHEAD( amount,
+	           expansion,
+	           { boolean_expression }
+	         )
+
+"amount" specifies the number of tokens to LOOKAHEAD,"expansion"
+specifies the expansion to use to perform syntactic LOOKAHEAD, and
+"boolean_expression" is the expression to use for semantic
+LOOKAHEAD.
+
+At least one of the three entries must be present.  If more than
+one are present, they are separated by commas.  The default values
+for each of these entities is defined below:
+
+"amount":
+ - if "expansion is present, this defaults to 2147483647.
+ - otherwise ("boolean_expression" must be present then) this
+   defaults to 0.
+
+Note: When "amount" is 0, no syntactic LOOKAHEAD is performed.  Also,
+"amount" does not affect the semantic LOOKAHEAD.
+
+"expansion":
+- defaults to the expansion being considered.
+
+"boolean_expression":
+
+- defaults to true.
+
+----------------------------------------------------------------
+
+8. NESTED EVALUATION OF SEMANTIC LOOKAHEAD
+
+TBD
+
+----------------------------------------------------------------
+
+9. JAVACODE PRODUCTIONS
+
+TBD
+
+----------------------------------------------------------------
diff --git a/tools/javacc-4.0/examples/MailProcessing/Digest.jj b/tools/javacc-4.0/examples/MailProcessing/Digest.jj
new file mode 100644
index 0000000000000000000000000000000000000000..4eeb2416883c49db3854fb7b2d3f1895e0461861
--- /dev/null
+++ b/tools/javacc-4.0/examples/MailProcessing/Digest.jj
@@ -0,0 +1,181 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+
+PARSER_BEGIN(Digest)
+
+import java.io.*;
+
+public class Digest {
+
+  static int count = 0;
+
+  static String buffer = "";
+
+  public static void main(String args[]) throws ParseException {
+    Digest parser = new Digest(System.in);
+    System.out.println("DIGEST OF RECENT MESSAGES FROM THE JAVACC MAILING LIST");
+    System.out.println("----------------------------------------------------------------------");
+    System.out.println("");
+    System.out.println("MESSAGE SUMMARY:");
+    System.out.println("");
+    parser.MailFile();
+    if (count == 0) {
+      System.out.println("There have been no messages since the last digest posting.");
+      System.out.println("");
+      System.out.println("----------------------------------------------------------------------");
+    } else {
+      System.out.println("");
+      System.out.println("----------------------------------------------------------------------");
+      System.out.println("");
+      System.out.println(buffer);
+    }
+  }
+
+}
+
+PARSER_END(Digest)
+
+
+// PARSER SPECIFICATIONS BEGIN HERE
+
+void MailFile() :
+	{
+	}
+{
+  (
+	{
+	  count++;
+	}
+    MailMessage()
+  )*
+  <EOF>
+}
+
+void MailMessage() :
+	{
+	  Token subj=null, from=null, date=null, body;
+	}
+{
+  ( subj=<SUBJECT> | from=<FROM> | date=<DATE> )+
+	{
+	  System.out.println(count + ". " + ((subj==null) ? "no subject" : subj.image));
+	  buffer += "\n";
+	  buffer += "Message " + count + ":\n";
+	  buffer += "\n";
+	  buffer += "Subject: " + ((subj==null) ? "no subject" : subj.image) + "\n";
+	  buffer += "From: " + ((from==null) ? "" : from.image) + "\n";
+	  buffer += "Date: " + ((date==null) ? "" : date.image) + "\n";
+	  buffer += "\n";
+	}
+  ( body=<BODY>
+	{
+	  buffer += body.image;
+	}
+  )*
+  <END>
+	{
+	  buffer += "\n";
+	  buffer += "----------------------------------------------------------------------\n";
+	}
+}
+
+
+// LEXICAL SPECIFICATIONS BEGIN HERE
+
+TOKEN:
+{
+  <#EOL: "\n" | "\r" | "\r\n">
+|
+  <#TWOEOLS: (("\n"|"\r\n") <EOL>) | ("\r\r" [ "\n" ])>
+|
+  <#NOT_EOL: ~["\n","\r"]>
+}
+
+<DEFAULT>
+SKIP:
+{
+  < <EOL> "*** EOOH ***" <EOL> > : MAILHEADER
+|
+  <~[]>
+}
+
+<MAILHEADER>
+SKIP:
+{
+  <_TWOEOLS: <TWOEOLS>> : MAILBODY
+    // We cannot have just a reference to a regular expression in a
+    // lexical specification - i.e., we cannot simply have <TWOEOLS>.
+|
+  "Subject: " : MAILSUBJECT
+|
+  "From: " : MAILFROM
+|
+  "Date: " : MAILDATE
+|
+  <~[]>
+}
+
+<MAILSUBJECT>
+TOKEN:
+{
+  <SUBJECT: ( <NOT_EOL> )+>
+}
+
+<MAILSUBJECT>
+SKIP:
+{
+  <_EOL1: <EOL>> : MAILHEADER
+}
+
+<MAILFROM>
+TOKEN:
+{
+  <FROM: ( <NOT_EOL> )+>
+}
+
+<MAILFROM>
+SKIP:
+{
+  <_EOL2: <EOL>> : MAILHEADER
+}
+
+<MAILDATE>
+TOKEN:
+{
+  <DATE: ( <NOT_EOL> )+>
+}
+
+<MAILDATE>
+SKIP:
+{
+  <_EOL3: <EOL>> : MAILHEADER
+}
+
+<MAILBODY>
+TOKEN:
+{
+  <BODY: (~["\n","\r","\u001f"])* <EOL>>
+|
+  <END: "\u001f"> : DEFAULT
+}
diff --git a/tools/javacc-4.0/examples/MailProcessing/Faq.jj b/tools/javacc-4.0/examples/MailProcessing/Faq.jj
new file mode 100644
index 0000000000000000000000000000000000000000..5592de53df0a8248f4ad17c6cb7a79b528cbc66f
--- /dev/null
+++ b/tools/javacc-4.0/examples/MailProcessing/Faq.jj
@@ -0,0 +1,220 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+
+PARSER_BEGIN(Faq)
+
+import java.io.*;
+
+public class Faq {
+
+  static int count = 0;
+
+  static int beginAt = 1;
+
+  static PrintWriter indstr;
+
+  static {
+    try {
+      indstr = new PrintWriter(new FileWriter("index.html"));
+      indstr.println("<title>Selected list of emails from the JavaCC mailing list</title>");
+      indstr.println("<h2>Selected list of emails from the JavaCC mailing list</h2>");
+    } catch (IOException e) {
+      throw new Error();
+    }
+  }
+
+  static String fix(String s) {
+    String retval = "";
+    for (int i = 0; i < s.length(); i++) {
+      char c = s.charAt(i);
+      if (c == '<') {
+        retval += "&lt;";
+      } else if (c == '>') {
+        retval += "&gt;";
+      } else {
+        retval += c;
+      }
+    }
+    return retval;
+  }
+
+  public static void main(String args[]) throws ParseException {
+    if (args.length == 1) {
+      beginAt = Integer.parseInt(args[0]);
+    }
+    Faq parser = new Faq(System.in);
+    parser.MailFile();
+  }
+
+}
+
+PARSER_END(Faq)
+
+
+// PARSER SPECIFICATIONS BEGIN HERE
+
+void MailFile() :
+	{
+	}
+{
+  (
+	{
+	  count++;
+	}
+    MailMessage()
+	{
+	  System.out.print(count + ".");
+	  System.out.flush();
+	}
+  )*
+  <EOF>
+	{
+	  System.out.println("");
+	  indstr.close();
+	}
+}
+
+void MailMessage() :
+	{
+	  PrintWriter msgstr = null;
+	  Token subj=null, from=null, date=null, body;
+	  if (count >= beginAt) {
+	    try {
+	      msgstr = new PrintWriter(new FileWriter(count + ".html"));
+	    } catch (IOException e) {
+	      throw new Error();
+	    }
+	  }
+	}
+{
+  ( subj=<SUBJECT> | from=<FROM> | date=<DATE> )+
+	{
+	  indstr.print("<a href=\"" + count + ".html\">");
+	  if (subj == null) {
+	    indstr.println("no subject</a><br>");
+	  } else {
+	    indstr.println(fix(subj.image) + "</a><br>");
+	  }
+	  if (count >= beginAt) {
+	    msgstr.println("<title>" + ((subj==null) ? "no subject" : fix(subj.image)) + "</title>");
+	    msgstr.println("Subject: " + ((subj==null) ? "no subject" : fix(subj.image)) + "<br>");
+	    msgstr.println("From: " + ((from==null) ? "" : fix(from.image)) + "<br>");
+	    msgstr.println("Date: " + ((date==null) ? "" : fix(date.image)) + "<br>");
+            msgstr.println("<br>");
+	  }
+	}
+  ( body=<BODY>
+	{
+	  if (count >= beginAt) {
+	    msgstr.print(fix(body.image) + "<br>");
+	  }
+	}
+  )*
+  <END>
+	{
+	  if (count >= beginAt) {
+	    msgstr.close();
+	  }
+	}
+}
+
+
+// LEXICAL SPECIFICATIONS BEGIN HERE
+
+TOKEN:
+{
+  <#EOL: "\n" | "\r" | "\r\n">
+|
+  <#TWOEOLS: (("\n"|"\r\n") <EOL>) | ("\r\r" [ "\n" ])>
+|
+  <#NOT_EOL: ~["\n","\r"]>
+}
+
+<DEFAULT>
+SKIP:
+{
+  < <EOL> "*** EOOH ***" <EOL> > : MAILHEADER
+|
+  <~[]>
+}
+
+<MAILHEADER>
+SKIP:
+{
+  <_TWOEOLS: <TWOEOLS>> : MAILBODY
+    // We cannot have just a reference to a regular expression in a
+    // lexical specification - i.e., we cannot simply have <TWOEOLS>.
+|
+  "Subject: " : MAILSUBJECT
+|
+  "From: " : MAILFROM
+|
+  "Date: " : MAILDATE
+|
+  <~[]>
+}
+
+<MAILSUBJECT>
+TOKEN:
+{
+  <SUBJECT: ( <NOT_EOL> )+>
+}
+
+<MAILSUBJECT>
+SKIP:
+{
+  <_EOL1: <EOL>> : MAILHEADER
+}
+
+<MAILFROM>
+TOKEN:
+{
+  <FROM: ( <NOT_EOL> )+>
+}
+
+<MAILFROM>
+SKIP:
+{
+  <_EOL2: <EOL>> : MAILHEADER
+}
+
+<MAILDATE>
+TOKEN:
+{
+  <DATE: ( <NOT_EOL> )+>
+}
+
+<MAILDATE>
+SKIP:
+{
+  <_EOL3: <EOL>> : MAILHEADER
+}
+
+<MAILBODY>
+TOKEN:
+{
+  <BODY: (~["\n","\r","\u001f"])* <EOL>>
+|
+  <END: "\u001f"> : DEFAULT
+}
diff --git a/tools/javacc-4.0/examples/MailProcessing/README b/tools/javacc-4.0/examples/MailProcessing/README
new file mode 100644
index 0000000000000000000000000000000000000000..cbaa8700ed8b22c955abda4896237635049f02a6
--- /dev/null
+++ b/tools/javacc-4.0/examples/MailProcessing/README
@@ -0,0 +1,105 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+This example illustrates the use of lexical states.
+
+In this directory are two grammar files Digest.jj and Faq.jj.  These
+generate parsers that process RMAIL files that are created by the GNU
+emacs editor.  A sample RMAIL file called sampleMailFile is also
+included.
+
+Digest.jj and Faq.jj are both identical in their grammar and lexical
+specifications.  They only differ in their actions.  Digest.jj takes a
+mail file as standard input and produces a digest version of the
+messages to standard output.  This is what we used (before we moved
+over to an automatic mailing list software) to produce the weekly mail
+digest of the JavaCC mailing list.  Faq.jj takes a mail file as
+standard input and produces a mail FAQ in HTML format.  It produces a
+file "index.html" that contains all the mail headers and links to
+other HTML files called "1.html", "2.html", etc. that contain the 1st,
+2nd, etc. messages.  The parser generated from Faq.jj accepts an
+optional integer argument that specifies the message number from where
+to begin processing.
+
+Type the following:
+
+	javacc Digest.jj
+	javacc Faq.jj
+	javac *.java
+	java Digest < sampleMailFile > digestFile
+	java Faq < sampleMailFile
+
+And take a look at the output files created.
+
+
+MORE DETAILS ON HOW THE GRAMMARS WORK:
+
+The grammar specification is rather trivial.  It simply says that a
+MailFile is is a sequence of MailMessage's followed by an end of file.
+And that a MailMessage is a list of one or more <SUBJECT>'s, <FROM>'s,
+and <DATE>'s followed by a list of zero or more <BODY>'s followed by
+an <END>.
+
+Essentially, there are five lexical tokens:
+
+<SUBJECT>, <FROM, <DATE> : Are the strings of the Subject, From, and
+Date fields of the message.
+
+<BODY> : Is a single line of the message body.
+
+<END> : is the end of message token.
+
+The lexical specification starts with a set of reusable private
+regular expressions EOL, TWOEOLS, and NOT_EOL.  These are defined to
+be portable across different platforms where the end of line
+characters are different.
+
+In the <DEFAULT> lexical state, the token manager simply eats up
+characters until it sees the beginning of a message which is marked by
+<<EOL> "*** EOOH ***" <EOL>>.  See the sample mail file for details.
+At this point, it switches to state <MAILHEADER>.
+
+In the state <MAILHEADER>, two consecutive end of line's indicate the
+end of the mail header and therefore the token manager goes to the
+<MAILBODY> lexical state.  Also, if it sees "Subject: ", it goes to
+the <MAILSUBJECT> lexical state, and similarly for "From: " and "Date: ".
+
+The end of message is signified by the "^_" character, of "\u001f".
+The state <MAILBODY> returns to the <DEFAULT> state when it sees this
+character, otherwise it simply returns message body lines one by one.
+
+The general flow chart for the lexical states is shown below.  It is
+useful to make such a diagram when building complex lexical
+specifications.
+
+
+      <DEFAULT> ---> <MAILHEADER> --+--> <MAILSUBJECT> -->+
+       ^                |    ^      |                     |
+       |                |    |      |                     |
+       |                |    |      +--> <MAILFROM> ----->+
+       +- <MAILBODY> <--+    |      |                     |
+                             |      |                     |
+                             |      +--> <MAILDATE> ----->+
+                             |                            |
+                             |                            |
+                             +----------------------------+
diff --git a/tools/javacc-4.0/examples/MailProcessing/sampleMailFile b/tools/javacc-4.0/examples/MailProcessing/sampleMailFile
new file mode 100644
index 0000000000000000000000000000000000000000..310bab722f3660e8d67c14b86aaad9d752fdbf59
--- /dev/null
+++ b/tools/javacc-4.0/examples/MailProcessing/sampleMailFile
@@ -0,0 +1,232 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+BABYL OPTIONS:
+Version: 5
+Labels:
+Note:   This is the header of an rmail file.
+Note:   If you are seeing it in rmail,
+Note:    it means the file has no messages in it.
+
+1, filed,,
+Summary-line: 11-Jan       sreeni@cs.albany.edu  #A note on using RE's matching the emty string
+Return-Path: <sreeni@cs.albany.edu>
+Received: from Eng.Sun.COM by schizophrenia.Eng.Sun.COM (SMI-8.6/SMI-SVR4)
+	id HAA21134; Sat, 11 Jan 1997 07:47:28 -0800
+Received: from sunmail1.Sun.COM by Eng.Sun.COM (SMI-8.6/SMI-5.3)
+	id HAA02652; Sat, 11 Jan 1997 07:44:26 -0800
+Received: from Eng.Sun.COM by sunmail1.Sun.COM (SMI-8.6/SMI-4.1)
+	id HAA06974; Sat, 11 Jan 1997 07:44:26 -0800
+Received: from suntest.Eng.Sun.COM by Eng.Sun.COM (SMI-8.6/SMI-5.3)
+	id HAA02640; Sat, 11 Jan 1997 07:44:24 -0800
+Received: from asap.Eng.Sun.COM by suntest.Eng.Sun.COM (SMI-8.6/SMI-SVR4)
+	id HAA21295; Sat, 11 Jan 1997 07:44:18 -0800
+Received: from Eng.Sun.COM by asap.Eng.Sun.COM (SMI-8.6/SMI-SVR4)
+	id HAA24684; Sat, 11 Jan 1997 07:44:19 -0800
+Received: from mercury.Sun.COM by Eng.Sun.COM (SMI-8.6/SMI-5.3)
+	id HAA02630; Sat, 11 Jan 1997 07:44:17 -0800
+Received: from cs.albany.edu (cs.albany.edu [169.226.2.22]) by mercury.Sun.COM (SMI-8.6/mail.byaddr) with SMTP id HAA01828 for <jack-interest@asap.eng.sun.com>; Sat, 11 Jan 1997 07:44:18 -0800
+Received: from bhaskara.cs.albany.edu (sreeni@bhaskara.cs.albany.edu [169.226.2.60]) by cs.albany.edu (8.7.4/HUB03) with ESMTP id KAA01464; Sat, 11 Jan 1997 10:44:06 -0500 (EST)
+Received: (from sreeni@localhost) by bhaskara.cs.albany.edu (8.7.4/CLI2) id KAA09608; Sat, 11 Jan 1997 10:43:58 -0500 (EST)
+From: Sreenivasa Rao Viswanadha <sreeni@cs.albany.edu>
+Date: Sat, 11 Jan 1997 10:43:58 -0500 (EST)
+Message-Id: <199701111543.KAA09608@bhaskara.cs.albany.edu>
+To: jack-interest@asap.Eng.Sun.COM
+Subject: A note on using RE's matching the emty string
+Cc: sreeni@cs.albany.edu
+X-Sun-Charset: US-ASCII
+Content-Type: text
+Content-Length: 1639
+X-Lines: 32
+Status: RO
+
+*** EOOH ***
+Return-Path: <sreeni@cs.albany.edu>
+From: Sreenivasa Rao Viswanadha <sreeni@cs.albany.edu>
+Date: Sat, 11 Jan 1997 10:43:58 -0500 (EST)
+To: jack-interest@asap.Eng.Sun.COM
+Subject: A note on using RE's matching the emty string
+Cc: sreeni@cs.albany.edu
+X-Sun-Charset: US-ASCII
+Content-Type: text
+Content-Length: 1639
+X-Lines: 32
+
+
+In the last couple of days, we had seen a couple of users facing problems with
+regular expressions that match "". There is a minor bug in the way it is 
+implemented in 0.6.-9. We will fix it.
+
+But the purpose of this mail is to suggest you should be careful when you use
+RE's that match the "" string. Consider the following example of string literals
+where two consecutive "" are interpreted as the literal " (equivalent to \" in
+Java).
+
+< STRING_LITERAL: ( "\"" (~["\""])* "\"" )* >
+
+This will work in general. But, if this a part of a lot of other lexical rules,
+then if there a lexical error, say a char is given that cannot be the first one
+of any token, then, the lexer decides to use the empty string "" and match it
+as STRING_LITERAL without actually giving the lexical error. And since this is
+the empty string, no character will be consumed and you will start getting the
+same STRING_LITERAL token (with "" as the image) infinte number of times. In
+fact, if this was the only lexical rule, then if you give a input that starts
+with any char other than the ", you will get into an infinite loop.
+
+So a better alternative is to use the + operator which will not match the empty
+string. As a matter of fact, I don't know any practical grammar where matching
+"" is useful.
+
+In version 0.5, the lexer generated implicitly treated it as + (which is not
+totally right). But in 0.6.-9, it does it right and so there is a chance that
+your grammar that used to work with 0.5 will not work with 0.6.-9. So if you
+have any top-level lexical rule with ? or *, please change those rules so that
+they don't match the empty string "".
+
+Sreeni.
+
+
+1,,
+Summary-line: 11-Jan         kimbo@highway1.com  #Re: Looking for HTML.jack
+Return-Path: <kimbo@highway1.com>
+Received: from Eng.Sun.COM by schizophrenia.Eng.Sun.COM (SMI-8.6/SMI-SVR4)
+	id QAA21339; Sat, 11 Jan 1997 16:41:53 -0800
+Received: from sunmail1.Sun.COM by Eng.Sun.COM (SMI-8.6/SMI-5.3)
+	id QAA18458; Sat, 11 Jan 1997 16:38:44 -0800
+Received: from Eng.Sun.COM by sunmail1.Sun.COM (SMI-8.6/SMI-4.1)
+	id QAA16642; Sat, 11 Jan 1997 16:38:51 -0800
+Received: from suntest.Eng.Sun.COM by Eng.Sun.COM (SMI-8.6/SMI-5.3)
+	id QAA18449; Sat, 11 Jan 1997 16:38:42 -0800
+Received: from asap.Eng.Sun.COM by suntest.Eng.Sun.COM (SMI-8.6/SMI-SVR4)
+	id QAA23127; Sat, 11 Jan 1997 16:38:42 -0800
+Received: from Eng.Sun.COM by asap.Eng.Sun.COM (SMI-8.6/SMI-SVR4)
+	id QAA24956; Sat, 11 Jan 1997 16:38:41 -0800
+Received: from mercury.Sun.COM by Eng.Sun.COM (SMI-8.6/SMI-5.3)
+	id QAA18438; Sat, 11 Jan 1997 16:38:36 -0800
+Received: from chmls01.highway1.com (ne.highway1.com [24.128.1.82]) by mercury.Sun.COM (SMI-8.6/mail.byaddr) with SMTP id QAA22125 for <jack-interest@asap.Eng.Sun.COM>; Sat, 11 Jan 1997 16:38:42 -0800
+Received: from papa ([24.128.36.164]) by chmls01.highway1.com
+          (Netscape Mail Server v2.0) with SMTP id AAA17669;
+          Sat, 11 Jan 1997 19:38:31 -0400
+Message-ID: <32D83288.5A8@highway1.com>
+Date: Sat, 11 Jan 1997 19:38:32 -0500
+From: kimbo@highway1.com (Kimbo Mundy)
+X-Mailer: Mozilla 3.0Gold (WinNT; U)
+MIME-Version: 1.0
+To: Rupert Nagler <nagler@idi.co.at>
+CC: jack-interest@asap.Eng.Sun.COM
+Subject: Re: Looking for HTML.jack
+References: <1.5.4.32.19970111214054.0069e40c@mail.austria.eu.net>
+Content-Transfer-Encoding: 7bit
+X-Lines: 13
+Status: RO
+Content-Type: text/plain; charset="us-ascii"
+Content-Length: 447
+
+*** EOOH ***
+Return-Path: <kimbo@highway1.com>
+Date: Sat, 11 Jan 1997 19:38:32 -0500
+From: kimbo@highway1.com (Kimbo Mundy)
+X-Mailer: Mozilla 3.0Gold (WinNT; U)
+MIME-Version: 1.0
+To: Rupert Nagler <nagler@idi.co.at>
+CC: jack-interest@asap.Eng.Sun.COM
+Subject: Re: Looking for HTML.jack
+References: <1.5.4.32.19970111214054.0069e40c@mail.austria.eu.net>
+Content-Transfer-Encoding: 7bit
+X-Lines: 13
+Content-Type: text/plain; charset="us-ascii"
+Content-Length: 447
+
+Rupert Nagler wrote:
+> 
+> I am very impressed by the Jack-Concept and I am looking for a "HTML.jack".
+> Is there anybody out there who has an example of a Jack-Definition file for
+> HTML 3.2?
+
+I previously sent a message entitled "A first cut at an HTML grammar".
+Did people not get it?  If not, see:
+http://www.tiac.net/users/kimbo/jack/HTML.jack
+
+> Is there a way to construct a *.jack file out of a *.sgml file?
+
+Sorry, I can't help with this.
+
+
+1,,
+Summary-line: 13-Jan         kimbo@highway1.com  #Re: HTML?
+Return-Path: <kimbo@highway1.com>
+Received: from suntest.Eng.Sun.COM by schizophrenia.Eng.Sun.COM (SMI-8.6/SMI-SVR4)
+	id XAA21746; Sun, 12 Jan 1997 23:06:34 -0800
+Received: from Eng.Sun.COM by suntest.Eng.Sun.COM (SMI-8.6/SMI-SVR4)
+	id XAA29422; Sun, 12 Jan 1997 23:03:31 -0800
+Received: from mercury.Sun.COM by Eng.Sun.COM (SMI-8.6/SMI-5.3)
+	id XAA07269; Sun, 12 Jan 1997 23:03:30 -0800
+Received: from chmls01.highway1.com (ne.highway1.com [24.128.1.82]) by mercury.Sun.COM (SMI-8.6/mail.byaddr) with SMTP id XAA18021 for <sankar@suntest.Eng.Sun.COM>; Sun, 12 Jan 1997 23:03:30 -0800
+Received: from papa ([24.128.36.164]) by chmls01.highway1.com
+          (Netscape Mail Server v2.0) with SMTP id AAA20062
+          for <sankar@suntest.Eng.Sun.COM>; Mon, 13 Jan 1997 02:03:25 -0400
+Message-ID: <32D9DE40.3604@highway1.com>
+Date: Mon, 13 Jan 1997 02:03:28 -0500
+From: kimbo@highway1.com (Kimbo Mundy)
+X-Mailer: Mozilla 3.0Gold (WinNT; U)
+MIME-Version: 1.0
+To: Sriram Sankar <sankar@suntest.Eng.Sun.COM>
+Subject: Re: HTML?
+References: <199612162037.MAA29649@schizophrenia.Eng.Sun.COM>
+Content-Transfer-Encoding: 7bit
+X-Lines: 34
+Status: RO
+Content-Type: text/plain; charset="us-ascii"
+Content-Length: 1420
+
+*** EOOH ***
+Return-Path: <kimbo@highway1.com>
+Date: Mon, 13 Jan 1997 02:03:28 -0500
+From: kimbo@highway1.com (Kimbo Mundy)
+X-Mailer: Mozilla 3.0Gold (WinNT; U)
+MIME-Version: 1.0
+To: Sriram Sankar <sankar@suntest.Eng.Sun.COM>
+Subject: Re: HTML?
+References: <199612162037.MAA29649@schizophrenia.Eng.Sun.COM>
+Content-Transfer-Encoding: 7bit
+X-Lines: 34
+Content-Type: text/plain; charset="us-ascii"
+Content-Length: 1420
+
+Well, I finally got an HTML grammar out there (at
+http://www.tiac.net/users/kimbo/jack/HTML.jack).  I hope you saw it, I
+got some mailer errors, that seemed like the kind that you could ignore,
+but at least one person didn't receive my first posting.
+
+I'd be interested to know if this is the sort of thing people are
+looking for, or do they want the full set of tags enumerated in the
+grammar as well?  Also, if there you have any desire to bundle this with
+Jack (possibly after upgrades and/or integration with other people's
+work), please feel free.
+
+I must say Jack is an amazing tool.  It was really easy to learn.  I
+love how readable the grammars are, and I love being able to pass info
+up and down the productions as the parser runs.  I never want to have to
+settle for LALR(1) again!  Thanks for writing it!
+
+
diff --git a/tools/javacc-4.0/examples/Obfuscator/Globals.java b/tools/javacc-4.0/examples/Obfuscator/Globals.java
new file mode 100644
index 0000000000000000000000000000000000000000..f1a6b87725a41e16ac34af52cb7bd535fbf6247a
--- /dev/null
+++ b/tools/javacc-4.0/examples/Obfuscator/Globals.java
@@ -0,0 +1,71 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+
+import java.io.*;
+import java.util.*;
+
+public class Globals {
+
+  // The mappings from old id's to new id's.
+  static Hashtable mappings = new Hashtable();
+
+  // A table of targets of all known mappings.
+  static Hashtable mapTargets = new Hashtable();
+
+  // These id's may not be changed.
+  static Hashtable noChangeIds = new Hashtable();
+
+  // These id's should be used for mappings.
+  static Hashtable useIds = new Hashtable();
+
+  // The location of the input and output directories.
+  static File inpDir, outDir;
+
+  // Set to true by Java parser if class has a main program.
+  static boolean mainExists;
+
+  // Returns the map of old to obfuscated id.  If map does not
+  // exist, it is created.
+  static String map(String str) {
+    Object obj = mappings.get(str);
+    if (obj != null) {
+      return (String)obj;
+    }
+    if (useIds.isEmpty()) {
+      String newId = "O0" + counter++;
+      mappings.put(str, newId);
+      return newId;
+    } else {
+      obj = useIds.keys().nextElement();
+      useIds.remove(obj);
+      String newId = (String)obj;
+      mappings.put(str, newId);
+      return newId;
+    }
+  }
+
+  // A counter used to generate new identifiers
+  static int counter = 0;
+
+}
diff --git a/tools/javacc-4.0/examples/Obfuscator/IdsFile.jj b/tools/javacc-4.0/examples/Obfuscator/IdsFile.jj
new file mode 100644
index 0000000000000000000000000000000000000000..e387f1e68a85dbfa5fffd5f5aa82064ac783955d
--- /dev/null
+++ b/tools/javacc-4.0/examples/Obfuscator/IdsFile.jj
@@ -0,0 +1,191 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+
+options {
+  JAVA_UNICODE_ESCAPE = true;
+  STATIC = false;
+}
+
+PARSER_BEGIN(IdsFile)
+
+import java.util.*;
+
+public class IdsFile {
+}
+
+PARSER_END(IdsFile)
+
+/*
+ * Following is the only production in this grammar.  This describes the grammar
+ * of the nochangeidsfile and useidsfile, which are simply lists of identifiers.
+ * The actions here insert these identifiers into the appropriate Hashtable's
+ * in Globals.java.
+ */
+
+void input(boolean noChangeIds, String fileName) :
+	{
+	  Token t;
+	  Object obj;
+	  Hashtable symtab = noChangeIds ? Globals.noChangeIds : Globals.useIds;
+	}
+{
+  (
+    t=<IDENTIFIER>
+	{
+	  if (!noChangeIds) {
+            // truncate size just to be safe on machines like Macs
+            if (t.image.length() > 24) {
+	      t.image = t.image.substring(0,24);
+	    }
+          }
+	  if (!noChangeIds && Globals.mapTargets.get(t.image) != null) {
+	    System.out.println("Warning: Identifier " + t.image + " from <useidsfile> already mapped.");
+	  } else {
+	    obj = symtab.put(t.image, "");
+	    if (obj != null) {
+	      System.out.println("Warning: Multiple occurrence of identifier " + t.image + " in " + fileName);
+	    } else if (noChangeIds) {
+	      Globals.mappings.put(t.image, t.image);
+	      Globals.mapTargets.put(t.image, "");
+	    }
+	  }
+	}
+  )*
+  <EOF>
+}
+
+// Lexical specifications follow (copied from the Java 1.1 grammar)
+
+SKIP : /* WHITE SPACE */
+{
+  " "
+| "\t"
+| "\n"
+| "\r"
+| "\f"
+}
+
+SKIP : /* COMMENTS */
+{
+  <SINGLE_LINE_COMMENT: "//" (~["\n","\r"])* ("\n"|"\r"|"\r\n")>
+| <FORMAL_COMMENT: "/**" (~["*"])* "*" ("*" | (~["*","/"] (~["*"])* "*"))* "/">
+| <MULTI_LINE_COMMENT: "/*" (~["*"])* "*" ("*" | (~["*","/"] (~["*"])* "*"))* "/">
+}
+
+TOKEN : /* RESERVED WORDS */
+{
+  < 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" >
+}
+
+TOKEN : /* IDENTIFIERS */
+{
+  < 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"
+      ]
+  >
+}
diff --git a/tools/javacc-4.0/examples/Obfuscator/Java1.1.jj b/tools/javacc-4.0/examples/Obfuscator/Java1.1.jj
new file mode 100644
index 0000000000000000000000000000000000000000..5daec60fbca87e2d8e2fc3ee392ff8dd2beb188d
--- /dev/null
+++ b/tools/javacc-4.0/examples/Obfuscator/Java1.1.jj
@@ -0,0 +1,1103 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+
+/*
+ * This modifies the original Java1.1.jj to include actions to determine
+ * if the file has a main program or not.  This information is stored in
+ * Globals.mainExists and used to decide when to generate main programs.
+ * The method CompilationUnit returns the first token of the Java program
+ * using which all tokens can be recovered through the next field.
+ */
+
+options {
+  JAVA_UNICODE_ESCAPE = true;
+  STATIC = false;
+}
+
+PARSER_BEGIN(JavaParser)
+
+import java.util.*;
+
+public class JavaParser {
+  static String className, fileName;
+}
+
+PARSER_END(JavaParser)
+
+
+/* WHITE SPACE */
+
+SKIP :
+{
+  " "
+| "\t"
+| "\n"
+| "\r"
+| "\f"
+}
+
+/* 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.
+ */
+
+Token CompilationUnit(String file) :
+	{
+	  Token retval = getToken(1);
+	  fileName = file;
+	  Globals.mainExists = false;
+	}
+{
+  [ PackageDeclaration() ]
+  ( ImportDeclaration() )*
+  ( TypeDeclaration() )*
+  <EOF>
+	{
+	  return retval;
+	}
+}
+
+void PackageDeclaration() :
+{}
+{
+  "package" Name() ";"
+}
+
+void ImportDeclaration() :
+{}
+{
+  "import" Name() [ "." "*" ] ";"
+}
+
+void TypeDeclaration() :
+{}
+{
+  LOOKAHEAD( ( "abstract" | "final" | "public" )* "class" )
+  ClassDeclaration()
+|
+  InterfaceDeclaration()
+|
+  ";"
+}
+
+
+/*
+ * Declaration syntax follows.
+ */
+
+void ClassDeclaration() :
+{}
+{
+  ( "abstract" | "final" | "public" )*
+  UnmodifiedClassDeclaration(true)
+}
+
+void UnmodifiedClassDeclaration(boolean topLevel) :
+	{
+	  Token t;
+	  String backupOfClassName = "";
+	}
+{
+  "class" t=<IDENTIFIER> [ "extends" Name() ] [ "implements" NameList() ]
+	{
+	  if (topLevel) {
+	    className = t.image;
+	  } else if (!className.equals("")) {
+	    backupOfClassName = className;
+	    className = "";
+	  }
+	}
+  ClassBody()
+	{
+	  if (topLevel) {
+	    className = "";
+	  } else if (!backupOfClassName.equals("")) {
+	    className = backupOfClassName;
+	  }
+	}
+}
+
+void ClassBody() :
+{}
+{
+  "{" ( ClassBodyDeclaration() )* "}"
+}
+
+void NestedClassDeclaration() :
+{}
+{
+  ( "static" | "abstract" | "final" | "public" | "protected" | "private" )*
+  UnmodifiedClassDeclaration(false)
+}
+
+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" | "public" )*
+  UnmodifiedInterfaceDeclaration()
+}
+
+void NestedInterfaceDeclaration() :
+{}
+{
+  ( "static" | "abstract" | "final" | "public" | "protected" | "private" )*
+  UnmodifiedInterfaceDeclaration()
+}
+
+void UnmodifiedInterfaceDeclaration() :
+{}
+{
+  "interface" <IDENTIFIER> [ "extends" NameList() ]
+  "{" ( InterfaceMemberDeclaration() )* "}"
+}
+
+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" | "protected" | "private" | "static" | "final" | "transient" | "volatile" )*
+  Type() VariableDeclarator() ( "," VariableDeclarator() )* ";"
+}
+
+void VariableDeclarator() :
+{}
+{
+  VariableDeclaratorId() [ "=" VariableInitializer() ]
+}
+
+void VariableDeclaratorId() :
+{}
+{
+  <IDENTIFIER> ( "[" "]" )*
+}
+
+void VariableInitializer() :
+{}
+{
+  ArrayInitializer()
+|
+  Expression()
+}
+
+void ArrayInitializer() :
+{}
+{
+  "{" [ VariableInitializer() ( LOOKAHEAD(2) "," VariableInitializer() )* ] [ "," ] "}"
+}
+
+void MethodDeclaration() :
+{}
+{
+  ( "public" | "protected" | "private" | "static" | "abstract" | "final" | "native" | "synchronized" )*
+  ResultType() MethodDeclarator() [ "throws" NameList() ]
+  ( Block() | ";" )
+}
+
+void MethodDeclarator() :
+	{
+	  Token t;
+	}
+{
+  t=<IDENTIFIER> FormalParameters() ( "[" "]" )*
+	{
+	  if (fileName.substring(0, fileName.length() - 5).equals(className)) {
+	    if (t.image.equals("main")) {
+	      Globals.mainExists = true;
+	    }
+	  }
+	}
+}
+
+void FormalParameters() :
+{}
+{
+  "(" [ FormalParameter() ( "," FormalParameter() )* ] ")"
+}
+
+void FormalParameter() :
+{}
+{
+  [ "final" ] Type() VariableDeclaratorId()
+}
+
+void ConstructorDeclaration() :
+{}
+{
+  [ "public" | "protected" | "private" ]
+  <IDENTIFIER> FormalParameters() [ "throws" NameList() ]
+  "{"
+    [ LOOKAHEAD(ExplicitConstructorInvocation()) ExplicitConstructorInvocation() ]
+    ( BlockStatement() )*
+  "}"
+}
+
+void ExplicitConstructorInvocation() :
+{}
+{
+  LOOKAHEAD("this" Arguments() ";")
+  "this" Arguments() ";"
+|
+  [ LOOKAHEAD(2) PrimaryExpression() "." ] "super" Arguments() ";"
+}
+
+void Initializer() :
+{}
+{
+  [ "static" ] Block()
+}
+
+
+/*
+ * Type, name and expression syntax follows.
+ */
+
+void Type() :
+{}
+{
+  ( PrimitiveType() | Name() ) ( "[" "]" )*
+}
+
+void PrimitiveType() :
+{}
+{
+  "boolean"
+|
+  "char"
+|
+  "byte"
+|
+  "short"
+|
+  "int"
+|
+  "long"
+|
+  "float"
+|
+  "double"
+}
+
+void ResultType() :
+{}
+{
+  "void"
+|
+  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() :
+{}
+{
+  "=" | "*=" | "/=" | "%=" | "+=" | "-=" | "<<=" | ">>=" | ">>>=" | "&=" | "^=" | "|="
+}
+
+void ConditionalExpression() :
+{}
+{
+  ConditionalOrExpression() [ "?" Expression() ":" ConditionalExpression() ]
+}
+
+void ConditionalOrExpression() :
+{}
+{
+  ConditionalAndExpression() ( "||" ConditionalAndExpression() )*
+}
+
+void ConditionalAndExpression() :
+{}
+{
+  InclusiveOrExpression() ( "&&" InclusiveOrExpression() )*
+}
+
+void InclusiveOrExpression() :
+{}
+{
+  ExclusiveOrExpression() ( "|" ExclusiveOrExpression() )*
+}
+
+void ExclusiveOrExpression() :
+{}
+{
+  AndExpression() ( "^" AndExpression() )*
+}
+
+void AndExpression() :
+{}
+{
+  EqualityExpression() ( "&" EqualityExpression() )*
+}
+
+void EqualityExpression() :
+{}
+{
+  InstanceOfExpression() ( ( "==" | "!=" ) InstanceOfExpression() )*
+}
+
+void InstanceOfExpression() :
+{}
+{
+  RelationalExpression() [ "instanceof" Type() ]
+}
+
+void RelationalExpression() :
+{}
+{
+  ShiftExpression() ( ( "<" | ">" | "<=" | ">=" ) ShiftExpression() )*
+}
+
+void ShiftExpression() :
+{}
+{
+  AdditiveExpression() ( ( "<<" | ">>" | ">>>" ) AdditiveExpression() )*
+}
+
+void AdditiveExpression() :
+{}
+{
+  MultiplicativeExpression() ( ( "+" | "-" ) MultiplicativeExpression() )*
+}
+
+void MultiplicativeExpression() :
+{}
+{
+  UnaryExpression() ( ( "*" | "/" | "%" ) UnaryExpression() )*
+}
+
+void UnaryExpression() :
+{}
+{
+  ( "+" | "-" ) UnaryExpression()
+|
+  PreIncrementExpression()
+|
+  PreDecrementExpression()
+|
+  UnaryExpressionNotPlusMinus()
+}
+
+void PreIncrementExpression() :
+{}
+{
+  "++" PrimaryExpression()
+}
+
+void PreDecrementExpression() :
+{}
+{
+  "--" PrimaryExpression()
+}
+
+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() [ "++" | "--" ]
+}
+
+void CastExpression() :
+{}
+{
+  LOOKAHEAD("(" PrimitiveType())
+  "(" Type() ")" UnaryExpression()
+|
+  "(" Type() ")" UnaryExpressionNotPlusMinus()
+}
+
+void PrimaryExpression() :
+{}
+{
+  PrimaryPrefix() ( LOOKAHEAD(2) PrimarySuffix() )*
+}
+
+void PrimaryPrefix() :
+{}
+{
+  Literal()
+|
+  "this"
+|
+  "super" "." <IDENTIFIER>
+|
+  "(" Expression() ")"
+|
+  AllocationExpression()
+|
+  LOOKAHEAD( ResultType() "." "class" )
+  ResultType() "." "class"
+|
+  Name()
+}
+
+void PrimarySuffix() :
+{}
+{
+  LOOKAHEAD(2)
+  "." "this"
+|
+  LOOKAHEAD(2)
+  "." AllocationExpression()
+|
+  "[" Expression() "]"
+|
+  "." <IDENTIFIER>
+|
+  Arguments()
+}
+
+void Literal() :
+{}
+{
+  <INTEGER_LITERAL>
+|
+  <FLOATING_POINT_LITERAL>
+|
+  <CHARACTER_LITERAL>
+|
+  <STRING_LITERAL>
+|
+  BooleanLiteral()
+|
+  NullLiteral()
+}
+
+void BooleanLiteral() :
+{}
+{
+  "true"
+|
+  "false"
+}
+
+void NullLiteral() :
+{}
+{
+  "null"
+}
+
+void Arguments() :
+{}
+{
+  "(" [ ArgumentList() ] ")"
+}
+
+void ArgumentList() :
+{}
+{
+  Expression() ( "," Expression() )*
+}
+
+void AllocationExpression() :
+{}
+{
+  LOOKAHEAD(2)
+  "new" PrimitiveType() ArrayDimsAndInits()
+|
+  "new" Name()
+    (
+      ArrayDimsAndInits()
+    |
+      Arguments() [ ClassBody() ]
+    )
+}
+
+/*
+ * 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() ";"
+|
+  SwitchStatement()
+|
+  IfStatement()
+|
+  WhileStatement()
+|
+  DoStatement()
+|
+  ForStatement()
+|
+  BreakStatement()
+|
+  ContinueStatement()
+|
+  ReturnStatement()
+|
+  ThrowStatement()
+|
+  SynchronizedStatement()
+|
+  TryStatement()
+}
+
+void LabeledStatement() :
+{}
+{
+  <IDENTIFIER> ":" Statement()
+}
+
+void Block() :
+{}
+{
+  "{" ( BlockStatement() )* "}"
+}
+
+void BlockStatement() :
+{}
+{
+  LOOKAHEAD([ "final" ] Type() <IDENTIFIER>)
+  LocalVariableDeclaration() ";"
+|
+  Statement()
+|
+  UnmodifiedClassDeclaration(false)
+|
+  UnmodifiedInterfaceDeclaration()
+}
+
+void LocalVariableDeclaration() :
+{}
+{
+  [ "final" ] 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()
+  [
+    "++"
+  |
+    "--"
+  |
+    AssignmentOperator() Expression()
+  ]
+}
+
+void SwitchStatement() :
+{}
+{
+  "switch" "(" Expression() ")" "{"
+    ( SwitchLabel() ( BlockStatement() )* )*
+  "}"
+}
+
+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" "(" Expression() ")" Statement() [ LOOKAHEAD(1) "else" Statement() ]
+}
+
+void WhileStatement() :
+{}
+{
+  "while" "(" Expression() ")" Statement()
+}
+
+void DoStatement() :
+{}
+{
+  "do" Statement() "while" "(" Expression() ")" ";"
+}
+
+void ForStatement() :
+{}
+{
+  "for" "(" [ ForInit() ] ";" [ Expression() ] ";" [ ForUpdate() ] ")" Statement()
+}
+
+void ForInit() :
+{}
+{
+  LOOKAHEAD( [ "final" ] Type() <IDENTIFIER> )
+  LocalVariableDeclaration()
+|
+  StatementExpressionList()
+}
+
+void StatementExpressionList() :
+{}
+{
+  StatementExpression() ( "," StatementExpression() )*
+}
+
+void ForUpdate() :
+{}
+{
+  StatementExpressionList()
+}
+
+void BreakStatement() :
+{}
+{
+  "break" [ <IDENTIFIER> ] ";"
+}
+
+void ContinueStatement() :
+{}
+{
+  "continue" [ <IDENTIFIER> ] ";"
+}
+
+void ReturnStatement() :
+{}
+{
+  "return" [ Expression() ] ";"
+}
+
+void ThrowStatement() :
+{}
+{
+  "throw" Expression() ";"
+}
+
+void SynchronizedStatement() :
+{}
+{
+  "synchronized" "(" Expression() ")" Block()
+}
+
+void TryStatement() :
+/*
+ * Semantic check required here to make sure that at least one
+ * finally/catch is present.
+ */
+{}
+{
+  "try" Block()
+  ( "catch" "(" FormalParameter() ")" Block() )*
+  [ "finally" Block() ]
+}
diff --git a/tools/javacc-4.0/examples/Obfuscator/Main.java b/tools/javacc-4.0/examples/Obfuscator/Main.java
new file mode 100644
index 0000000000000000000000000000000000000000..75cd74e10a50c440fed13f020a3ceb2ca9b89680
--- /dev/null
+++ b/tools/javacc-4.0/examples/Obfuscator/Main.java
@@ -0,0 +1,108 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+
+import java.io.*;
+import java.util.*;
+
+public class Main extends Globals {
+
+  /*
+   * This main program collects the input arguments.  If one or more of the three
+   * latter arguments are present, then these files are opened and parsed with the
+   * appropriate parsers.  Then the method Obfuscator.start() is called that does
+   * the actual obfuscation.  Finally, the file map.log is generated.
+   */
+  public static void main(String[] args) throws FileNotFoundException {
+    IdsFile idparser = null;
+    if (args.length < 2 || args.length > 5) {
+      System.out.println("Usage is \"java Main <inputdir> <outputdir> <mapsfile> <nochangeidsfile> <useidsfile>\"");
+      System.out.println("  <inputdir> must be the CLASSPATH directory.");
+      System.out.println("  <mapsfile>, <nochangeidsfile>, and <useidsfile> are optional, but if any of");
+      System.out.println("  these are present, then the ones preceding them must also be present.");
+      return;
+    }
+    inpDir = new File(args[0]);
+    if (!inpDir.isDirectory()) {
+      System.out.println("Error: " + args[0] + " is not a directory.");
+      return;
+    }
+    outDir = new File(args[1]);
+    if (outDir.exists()) {
+      if (!outDir.isDirectory()) {
+        System.out.println("Error: " + args[1] + " is not a directory.");
+        return;
+      }
+    } else {
+      System.out.println(args[1] + " does not exist.  Will create it.");
+      if (!outDir.mkdirs()) {
+        System.out.println("Could not create directory " + args[1]);
+        return;
+      }
+    }
+    if (args.length >= 4) {
+      try {
+        idparser = new IdsFile(new FileInputStream(args[3]));
+        idparser.input(true, args[3]);
+      } catch (ParseException e) {
+        System.out.println("Parse error in " + args[3]);
+        return;
+      }
+    }
+    if (args.length >= 3) {
+      try {
+        MapFile mapparser = new MapFile(new FileInputStream(args[2]));
+        mapparser.input();
+      } catch (ParseException e) {
+        System.out.println("Parse error in " + args[2]);
+        return;
+      }
+    }
+    if (args.length == 5) {
+      try {
+        idparser.ReInit(new FileInputStream(args[4]));
+        idparser.input(false, args[4]);
+      } catch (ParseException e) {
+        System.out.println("Parse error in " + args[4]);
+        return;
+      }
+    }
+    mappings.put("main", "main");
+    Obfuscator.start();
+    System.out.println("Dumping mappings used into map.log.");
+    PrintWriter mstr;
+    try {
+      mstr = new PrintWriter(new FileWriter("map.log"));
+    } catch (IOException e) {
+      System.out.println("Could not create file map.log");
+      throw new Error();
+    }
+    for (Enumeration enum = mappings.keys(); enum.hasMoreElements();) {
+      String from = (String)enum.nextElement();
+      String to = (String)mappings.get(from);
+      mstr.println(from + " -> " + to + ";");
+    }
+    mstr.close();
+  }
+
+}
diff --git a/tools/javacc-4.0/examples/Obfuscator/MapFile.jj b/tools/javacc-4.0/examples/Obfuscator/MapFile.jj
new file mode 100644
index 0000000000000000000000000000000000000000..a36a10c1750347c4b6cfa0f2d8be91482c22930f
--- /dev/null
+++ b/tools/javacc-4.0/examples/Obfuscator/MapFile.jj
@@ -0,0 +1,189 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+
+options {
+  JAVA_UNICODE_ESCAPE = true;
+  STATIC = false;
+}
+
+PARSER_BEGIN(MapFile)
+
+import java.util.*;
+
+public class MapFile {
+}
+
+PARSER_END(MapFile)
+
+/*
+ * Following is the only production in this grammar.  This describes the grammar
+ * of the mapsfile, which is simply a list of maps from actual identifiers to
+ * obfuscated identifiers.  The actions here insert these mappings into the
+ * appropriate Hashtable's in Globals.java.
+ */
+
+void input() :
+	{
+	  Token t1, t2;
+	}
+{
+  (
+    t1=<IDENTIFIER> "->" t2=<IDENTIFIER> ";"
+	{
+	  if (Globals.mappings.get(t1.image) != null) {
+	    if (!t1.image.equals(t2.image)) {
+	      System.out.println("Warning: Map specification of " + t1.image + " to " + t2.image + " overrides entry in <nochangeidsfile>.");
+	    }
+	  }
+	  // truncate size just to be safe on machines like Macs
+          if (t2.image.length() > 24) {
+	    t2.image = t2.image.substring(0,24);
+	  }
+	  Globals.mappings.put(t1.image, t2.image);
+	  Globals.mapTargets.put(t2.image, "");
+	  if (t2.image.length() > 2 && t2.image.substring(0,2).equals("O0")) {
+	    int i = Integer.parseInt(t2.image.substring(2));
+	    if (i > Globals.counter) {
+	      Globals.counter = i;
+	    }
+	  }
+	}
+  )*
+  <EOF>
+}
+
+// Lexical specifications follow (copied from the Java 1.1 grammar)
+
+SKIP : /* WHITE SPACE */
+{
+  " "
+| "\t"
+| "\n"
+| "\r"
+| "\f"
+}
+
+SKIP : /* COMMENTS */
+{
+  <SINGLE_LINE_COMMENT: "//" (~["\n","\r"])* ("\n"|"\r"|"\r\n")>
+| <FORMAL_COMMENT: "/**" (~["*"])* "*" ("*" | (~["*","/"] (~["*"])* "*"))* "/">
+| <MULTI_LINE_COMMENT: "/*" (~["*"])* "*" ("*" | (~["*","/"] (~["*"])* "*"))* "/">
+}
+
+TOKEN : /* RESERVED WORDS */
+{
+  < 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" >
+}
+
+TOKEN : /* IDENTIFIERS */
+{
+  < 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"
+      ]
+  >
+}
diff --git a/tools/javacc-4.0/examples/Obfuscator/Obfuscator.java b/tools/javacc-4.0/examples/Obfuscator/Obfuscator.java
new file mode 100644
index 0000000000000000000000000000000000000000..024ec57a66ae15c93b60bba8bd8c5f0500860b25
--- /dev/null
+++ b/tools/javacc-4.0/examples/Obfuscator/Obfuscator.java
@@ -0,0 +1,263 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+
+import java.io.*;
+import java.util.*;
+
+public class Obfuscator extends Globals {
+
+  // These data structures implement a stack that is used to recursively
+  // walk the input directory structure looking for Java files.
+
+  static String[][] dirStack = new String[100][];
+  static int[] dirStackIndex = new int[100];
+  static int dirStackSize;
+  static File[] dirFile = new File[100];
+
+  static {
+    dirFile[0] = inpDir;
+    dirStackSize = 1;
+    dirStack[dirStackSize] = dirFile[dirStackSize-1].list();
+    dirStackIndex[dirStackSize] = 0;
+  }
+
+  // Returns true if this is a Java file.
+  static boolean javaFile(String name) {
+    if (name.length() < 6) {
+      return false;
+    }
+    if (name.substring(name.length() - 5).equals(".java")) {
+      return true;
+    }
+    return false;
+  }
+
+  // The iterator.  This uses the above datastructures to walk the input
+  // directory tree.  Everytime it finds a Java file or when it cannot find
+  // any more Java file, it returns to the caller.
+  static void nextJavaFile() {
+    while (true) {
+      if (dirStackIndex[dirStackSize] == dirStack[dirStackSize].length) {
+        dirStackSize--;
+        if (dirStackSize == 0) {
+          return;
+        } else {
+          dirStackIndex[dirStackSize]++;
+        }
+      } else {
+        dirFile[dirStackSize] = new File(dirFile[dirStackSize-1],
+                                         dirStack[dirStackSize][dirStackIndex[dirStackSize]]);
+        if (dirStack[dirStackSize][dirStackIndex[dirStackSize]].equals("SCCS")) {
+          dirStackIndex[dirStackSize]++;
+        } else if (dirFile[dirStackSize].isDirectory()) {
+          dirStackSize++;
+          dirStack[dirStackSize] = dirFile[dirStackSize-1].list();
+          dirStackIndex[dirStackSize] = 0;
+        } else if (javaFile(dirStack[dirStackSize][dirStackIndex[dirStackSize]])) {
+          dirStackIndex[dirStackSize]++;
+          return;
+        } else {
+          dirStackIndex[dirStackSize]++;
+        }
+      }
+    }
+  }
+
+  // The main Obfuscator routine.  It calls the iterator for each Java file to
+  // work on.  It then creates the output file, then parses the input Java file
+  // to determine whether or not it has a main program and also to collect the
+  // tokens that make up this file.  It then calls printOutputFile that takes
+  // first token and walks the next field chain printing tokens as it goes along.
+  // Finally a main program is created if necessary.
+  static public void start() {
+    boolean parserInitialized = false;
+    JavaParser parser = null;
+    Token first;
+    while (true) {
+      nextJavaFile();
+      if (dirStackSize == 0) {
+        break;
+      }
+      createOutputFile();
+      System.out.println("Obfuscating " + dirFile[dirStackSize].getPath());
+      System.out.println("       into " + outFile.getPath());
+      try {
+	if (parserInitialized) {
+	  parser.ReInit(new FileInputStream(dirFile[dirStackSize]));
+	} else {
+	  parser = new JavaParser(new FileInputStream(dirFile[dirStackSize]));
+	  parserInitialized = true;
+	}
+        first = parser.CompilationUnit(dirStack[dirStackSize][dirStackIndex[dirStackSize]-1]);
+      } catch (ParseException e1) {
+        System.out.println("Parse error in file " + dirFile[dirStackSize].getPath());
+        throw new Error();
+      } catch (IOException e2) {
+        System.out.println("Could not open file " + dirFile[dirStackSize].getPath());
+        throw new Error();
+      }
+      printOutputFile(first);
+      if (mainExists) {
+        createMainClass();
+      }
+    }
+  }
+
+  static File outFile;
+  static PrintWriter ostr;
+
+  static void createOutputFile() {
+    // sets outFile and ostr
+    outFile = outDir;
+    for (int i = 1; i < dirStackSize; i++) {
+      outFile = new File(outFile, map(dirStack[i][dirStackIndex[i]]));
+      if (outFile.exists()) {
+        if (!outFile.isDirectory()) {
+          System.out.println("Unexpected error!");
+          throw new Error();
+        }
+      } else {
+        if (!outFile.mkdir()) {
+          System.out.println("Could not create directory " + outFile.getPath());
+          throw new Error();
+        }
+      }
+    }
+    String origFileName = dirStack[dirStackSize][dirStackIndex[dirStackSize]-1];
+    String newFileName = map(origFileName.substring(0, origFileName.length() - 5)) + ".java";
+    outFile = new File(outFile, newFileName);
+    try {
+      ostr = new PrintWriter(new FileWriter(outFile));
+    } catch (IOException e) {
+      System.out.println("Could not create file " + outFile.getPath());
+      throw new Error();
+    }
+  }
+
+  static void printOutputFile(Token first) {
+    Token t = first;
+    for (int i = 1; i < t.beginColumn; i++) {
+      ostr.print(" ");
+    }
+    while (true) {
+      if (t.kind == JavaParserConstants.IDENTIFIER) {
+        t.image = map(t.image);
+      }
+      ostr.print(addUnicodeEscapes(t.image));
+      if (t.next == null) {
+        ostr.println("");
+        break;
+      }
+      if (t.endLine != t.next.beginLine) {
+        for (int i = t.endLine; i < t.next.beginLine; i++) {
+          ostr.println("");
+        }
+        for (int i = 1; i < t.next.beginColumn; i++) {
+          ostr.print(" ");
+        }
+      } else {
+        for (int i = t.endColumn+1; i < t.next.beginColumn; i++) {
+          ostr.print(" ");
+        }
+      }
+      t = t.next;
+    }
+    ostr.close();
+  }
+
+  static String addUnicodeEscapes(String str) {
+    String retval = "";
+    char ch;
+    for (int i = 0; i < str.length(); i++) {
+      ch = str.charAt(i);
+      if (ch < 0x20 || ch > 0x7e) {
+	String s = "0000" + Integer.toString(ch, 16);
+	retval += "\\u" + s.substring(s.length() - 4, s.length());
+      } else {
+        retval += ch;
+      }
+    }
+    return retval;
+  }
+
+  // This creates a main program if there was one in the original file.  This
+  // main program has the same name and resides in the same package as the original
+  // file and it simply calls the obfuscated main program.  This allows scripts
+  // to continue to work.
+  static void createMainClass() {
+    PrintWriter mstr;
+    boolean mustCreate = false;
+    File mFile = outDir;
+    for (int i = 1; i < dirStackSize; i++) {
+      mFile = new File(mFile, dirStack[i][dirStackIndex[i]]);
+      mustCreate = mustCreate || !map(dirStack[i][dirStackIndex[i]]).equals(dirStack[i][dirStackIndex[i]]);
+      if (mFile.exists()) {
+        if (!mFile.isDirectory()) {
+          System.out.println("Error: Created file " + mFile.getPath() + ", but need to create a main program with the same path prefix.  Please remove identifiers from the path prefix from your <useidsfile> and run again.");
+          throw new Error();
+        }
+      }
+    }
+    String origFileName = dirStack[dirStackSize][dirStackIndex[dirStackSize]-1];
+    String newFileName = map(origFileName.substring(0, origFileName.length() - 5)) + ".java";
+    if (!mustCreate && origFileName.equals(newFileName)) {
+      return; // this main program has not been obfuscated.
+    }
+    if (!mFile.exists() && !mFile.mkdirs()) {
+      System.out.println("Could not create " + mFile.getPath());
+      throw new Error();
+    }
+    mFile = new File(mFile, origFileName);
+    try {
+      mstr = new PrintWriter(new FileWriter(mFile));
+    } catch (IOException e) {
+      System.out.println("Could not create " + mFile.getPath());
+      throw new Error();
+    }
+    System.out.print("Generating main program ");
+    String pname = "";
+    if (dirStackSize > 1) {
+      for (int i = 1; i < dirStackSize; i++) {
+        pname += "." + dirStack[i][dirStackIndex[i]];
+      }
+      mstr.println("package " + pname.substring(1) + ";");
+      System.out.print(pname.substring(1) + ".");
+      mstr.println("");
+    }
+    System.out.println(origFileName.substring(0, origFileName.length() - 5));
+    mstr.println("public class " + origFileName.substring(0, origFileName.length() - 5) + " {");
+    mstr.println("");
+    mstr.println("  public static void main(String[] args) {");
+    pname = "";
+    for (int i = 1; i < dirStackSize; i++) {
+      pname += map(dirStack[i][dirStackIndex[i]]) + ".";
+    }
+    mstr.println("    " + pname + map(origFileName.substring(0, origFileName.length() - 5)) + ".main(args);");
+    mstr.println("  }");
+    mstr.println("");
+    mstr.println("}");
+    mstr.close();
+  }
+
+}
diff --git a/tools/javacc-4.0/examples/Obfuscator/README b/tools/javacc-4.0/examples/Obfuscator/README
new file mode 100644
index 0000000000000000000000000000000000000000..9cc42654a06808deb9c5ea7919153c9a56bb3059
--- /dev/null
+++ b/tools/javacc-4.0/examples/Obfuscator/README
@@ -0,0 +1,94 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+This directory contains an obfuscation program.  This program takes
+the following inputs:
+
+. An input directory which contains the original Java programs.  This
+  must be the CLASSPATH directory.  All Java files within this
+  directory except those under SCCS directories are considered for
+  obfuscation.
+
+. An output directory into which the obfuscated files are generated.
+  It should be possible to build the obfuscated version by setting the
+  CLASSPATH to this directory.
+
+. A file of mappings of the form:
+      ( originalId "->" obfuscatedId ";" )*
+  This specifies mappings from original identifiers to corresponding
+  obfuscated ones.  This file is optional, and even when it is
+  present, it does not have to specify all identifiers in the input
+  file.
+
+. A file containing identifiers that must not be obfuscated.  This is
+  typically used to prevent references to the standard API's from
+  being changed.  This file is optional.
+
+. A file containing identifiers to be used for obfuscation.  If an
+  identifier is encountered in the original file that does not have a
+  specified mapping and is not an identifier that must not be
+  obfuscated, then identifiers from this file are used for
+  obfuscation.  Once identifiers from this file are exhausted, then
+  identifiers starting with "O0" the letter 'O' followed by the digit
+  '0' are generated automatically.  This file is optional.
+
+The output of the program is:
+
+. An obfuscated version for each input Java file.  Since package and
+  class names are also obfuscated, the directory and file names will
+  be different also.
+
+. A main program for each of the original main programs in their
+  original forms (with the same package and class names) that calls
+  the corresponding obfuscated main program.  This is useful to retain
+  access to the system as before.
+
+. A file containing all the mappings used during the obfuscation
+  process.  This file is in the same syntax as the input mapping file,
+  and therefore it can be used as input for future obfuscations.  This
+  is useful when related systems are obfuscated in different runs of
+  this program.
+
+To build the obfuscator, do the following:
+
+	javacc Java1.1.jj
+	javacc IdsFile.jj
+	javacc MapFile.jj
+	javac *.java
+
+Now the obfuscator is ready for use.  Try it out as follows on the
+example provided:
+
+	java Main input output maps nochangeids useids
+
+And take a look at the input and output directories.
+
+This example illustrates the use of multiple grammar files, some of
+which are used more than once while the system is running.  Take a
+look at the usage of ReInit's and also the actions in the grammar.
+Note how easy it was to include actions into the Java grammar to
+determine whether or not it had a main program.  Also note how easy it
+is to modify this program.
+
+Some comments are present in each of the files that comprise this
+example.
diff --git a/tools/javacc-4.0/examples/Obfuscator/input/package1/Main.java b/tools/javacc-4.0/examples/Obfuscator/input/package1/Main.java
new file mode 100644
index 0000000000000000000000000000000000000000..7d4764ca0ed7a368826bba6f1b3596646d0a37d1
--- /dev/null
+++ b/tools/javacc-4.0/examples/Obfuscator/input/package1/Main.java
@@ -0,0 +1,35 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+package package1;
+
+public class Main {
+
+  public static void main(String[] args) {
+    System.out.println("Calling incr 10 times...");
+    for (int i = 0; i < 10; i++) {
+      System.out.println(package2.Incr.incr());
+    }
+  }
+
+}
diff --git a/tools/javacc-4.0/examples/Obfuscator/input/package2/Incr.java b/tools/javacc-4.0/examples/Obfuscator/input/package2/Incr.java
new file mode 100644
index 0000000000000000000000000000000000000000..cc0685197d883d775faddbcd79770d985c1ac669
--- /dev/null
+++ b/tools/javacc-4.0/examples/Obfuscator/input/package2/Incr.java
@@ -0,0 +1,38 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+package package2;
+
+public class Incr {
+
+  static private int count = 0;
+
+  /**
+   * Returns the next integer value each time it is called.  The
+   * state information is stored in the variable count.
+   */
+  static public int incr() {
+    return count++;
+  }
+
+}
diff --git a/tools/javacc-4.0/examples/Obfuscator/maps b/tools/javacc-4.0/examples/Obfuscator/maps
new file mode 100644
index 0000000000000000000000000000000000000000..be154a8c7609a18362d7a9e6593759b1e7a418a9
--- /dev/null
+++ b/tools/javacc-4.0/examples/Obfuscator/maps
@@ -0,0 +1,4 @@
+// Mappings from original names to obfuscated names
+
+incr -> square_root;
+Incr -> MyMath;
diff --git a/tools/javacc-4.0/examples/Obfuscator/nochangeids b/tools/javacc-4.0/examples/Obfuscator/nochangeids
new file mode 100644
index 0000000000000000000000000000000000000000..10d0a2bfa9446ef3cf60ebc017b5e0353eace4d9
--- /dev/null
+++ b/tools/javacc-4.0/examples/Obfuscator/nochangeids
@@ -0,0 +1,6 @@
+// Identifiers that must not be obfuscated.
+
+System
+out
+println
+String
diff --git a/tools/javacc-4.0/examples/Obfuscator/useids b/tools/javacc-4.0/examples/Obfuscator/useids
new file mode 100644
index 0000000000000000000000000000000000000000..173aa0768ae11763d7659f185870e21effb43764
--- /dev/null
+++ b/tools/javacc-4.0/examples/Obfuscator/useids
@@ -0,0 +1,5 @@
+// Obfuscated identifiers to use (preferably).
+
+fileName
+randomNumber
+html
diff --git a/tools/javacc-4.0/examples/README b/tools/javacc-4.0/examples/README
new file mode 100644
index 0000000000000000000000000000000000000000..2275f34b26e8f275c0f012d314721fbad5a32416
--- /dev/null
+++ b/tools/javacc-4.0/examples/README
@@ -0,0 +1,87 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+This directory contains many examples of JavaCC and JJTree input grammars.
+We recommend you see the examples in the following order.  Each directory
+contains a README file with more detailed instructions:
+
+SimpleExamples:
+	This is a set of very simple JavaCC examples.  After trying these
+	examples out, you should be able to build reasonably complex
+	examples yourself.
+
+MailProcessing:
+	These examples illustrate the use of JavaCC in parsing emacs
+	mail files.  They highlight the use of lexical states.
+
+JJTreeExamples:
+	There are simple input grammars for JJTree, the tree building
+	preprocessor.
+
+CORBA-IDL:
+	This is a grammar for the IDL interface definition language of
+	OMG CORBA 2.0.
+
+JavaGrammars:
+	This directory contains extremely well debugged and maintained
+	Java grammars for both the 1.0.2 and 1.1 versions of the
+	language.
+
+JavaCCGrammar:
+	This directory contains the official JavaCC/JJTree grammar.  This
+	is the grammar based on which JavaCC and JJTree are built.
+
+Transformer:
+	This example illustrates how a Java language extension is defined
+	and transformed back into Java.  This makes use of JJTree.
+
+GUIParsing:
+	These examples illustrate how one may obtain input for parsing
+	or lexical analysis from a GUI, and thereby provide "parsing"
+	of GUI interactions.  In addition, one of these examples
+	illustrates how state machines may be described as lexical
+	specifications.
+
+Obfuscator:
+	This is a complete implementation of a Java obfuscator.  This
+	allows one to take a set of Java source files and modify them
+	into semantically equivalent source files that are much more
+	difficult to read.  This example shows the usage of multiple
+	parsers used from one system.
+
+Interpreter:
+	This is an interpreter for a simple language with declarations,
+	assignments, expressions, conditionals, loops, etc.  It
+	demonstrates really nicely a complex example where JJTree is
+	used to drastically simplify the process of generating parse
+	trees.  All actions are really methods built into the generated
+	tree nodes.
+
+Lookahead:
+	This directory contains the tutorial on LOOKAHEAD along with all
+	examples used in the tutorial.
+
+VTransformer:
+	This directory contains an example of using the Visitor design
+	pattern with JJTree.  Like the Transformer example, it shows how
+	a Java program can be processed into a slightly different form.
diff --git a/tools/javacc-4.0/examples/SimpleExamples/IdList.jj b/tools/javacc-4.0/examples/SimpleExamples/IdList.jj
new file mode 100644
index 0000000000000000000000000000000000000000..aa8b892ce4ab58bfceb4ab7d400d6df79d817954
--- /dev/null
+++ b/tools/javacc-4.0/examples/SimpleExamples/IdList.jj
@@ -0,0 +1,55 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+
+PARSER_BEGIN(IdList)
+
+public class IdList {
+
+  public static void main(String args[]) throws ParseException {
+    IdList parser = new IdList(System.in);
+    parser.Input();
+  }
+
+}
+
+PARSER_END(IdList)
+
+SKIP :
+{
+  " "
+| "\t"
+| "\n"
+| "\r"
+}
+
+TOKEN :
+{
+  < Id: ["a"-"z","A"-"Z"] ( ["a"-"z","A"-"Z","0"-"9"] )* >
+}
+
+void Input() :
+{}
+{
+  ( <Id> )+ <EOF>
+}
diff --git a/tools/javacc-4.0/examples/SimpleExamples/NL_Xlator.jj b/tools/javacc-4.0/examples/SimpleExamples/NL_Xlator.jj
new file mode 100644
index 0000000000000000000000000000000000000000..f6abb5fe280009fbbb6876868fd5ab98471acd48
--- /dev/null
+++ b/tools/javacc-4.0/examples/SimpleExamples/NL_Xlator.jj
@@ -0,0 +1,157 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+
+PARSER_BEGIN(NL_Xlator)
+
+public class NL_Xlator {
+
+  public static void main(String args[]) throws ParseException {
+    NL_Xlator parser = new NL_Xlator(System.in);
+    parser.ExpressionList();
+  }
+
+}
+
+PARSER_END(NL_Xlator)
+
+SKIP :
+{
+  " "
+| "\t"
+| "\n"
+| "\r"
+}
+
+TOKEN :
+{
+  < ID: ["a"-"z","A"-"Z","_"] ( ["a"-"z","A"-"Z","_","0"-"9"] )* >
+|
+  < NUM: ( ["0"-"9"] )+ >
+}
+
+void ExpressionList() :
+{
+	String s;
+}
+{
+	{
+	  System.out.println("Please type in an expression followed by a \";\" or ^D to quit:");
+	  System.out.println("");
+	}
+  ( s=Expression() ";"
+	{
+	  System.out.println(s);
+	  System.out.println("");
+	  System.out.println("Please type in another expression followed by a \";\" or ^D to quit:");
+	  System.out.println("");
+	}
+  )*
+  <EOF>
+}
+
+String Expression() :
+{
+	java.util.Vector termimage = new java.util.Vector();
+	String s;
+}
+{
+  s=Term()
+	{
+	  termimage.addElement(s);
+	}
+  ( "+" s=Term()
+	{
+	  termimage.addElement(s);
+	}
+  )*
+	{
+	  if (termimage.size() == 1) {
+	    return (String)termimage.elementAt(0);
+          } else {
+            s = "the sum of " + (String)termimage.elementAt(0);
+	    for (int i = 1; i < termimage.size()-1; i++) {
+	      s += ", " + (String)termimage.elementAt(i);
+	    }
+	    if (termimage.size() > 2) {
+	      s += ",";
+	    }
+	    s += " and " + (String)termimage.elementAt(termimage.size()-1);
+            return s;
+          }
+	}
+}
+
+String Term() :
+{
+	java.util.Vector factorimage = new java.util.Vector();
+	String s;
+}
+{
+  s=Factor()
+	{
+	  factorimage.addElement(s);
+	}
+  ( "*" s=Factor()
+	{
+	  factorimage.addElement(s);
+	}
+  )*
+	{
+	  if (factorimage.size() == 1) {
+	    return (String)factorimage.elementAt(0);
+          } else {
+            s = "the product of " + (String)factorimage.elementAt(0);
+	    for (int i = 1; i < factorimage.size()-1; i++) {
+	      s += ", " + (String)factorimage.elementAt(i);
+	    }
+	    if (factorimage.size() > 2) {
+	      s += ",";
+	    }
+	    s += " and " + (String)factorimage.elementAt(factorimage.size()-1);
+            return s;
+          }
+	}
+}
+
+String Factor() :
+{
+	Token t;
+	String s;
+}
+{
+  t=<ID>
+	{
+	  return t.image;
+	}
+|
+  t=<NUM>
+	{
+	  return t.image;
+	}
+|
+  "(" s=Expression() ")"
+	{
+	  return s;
+	}
+}
diff --git a/tools/javacc-4.0/examples/SimpleExamples/README b/tools/javacc-4.0/examples/SimpleExamples/README
new file mode 100644
index 0000000000000000000000000000000000000000..844db2c4aa1b0de551b3a39faedd77c04e806226
--- /dev/null
+++ b/tools/javacc-4.0/examples/SimpleExamples/README
@@ -0,0 +1,398 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+This directory contains five examples to get you started using JavaCC.
+Each example is contained in a single grammar file and are listed
+below:
+
+	Simple1.jj
+	Simple2.jj
+	Simple3.jj
+	Simple4.jj
+	NL_Xlator.jj
+	IdList.jj
+
+Once you have tried out and understood each of these examples, you
+should take a look at more complex examples in other sub-directories
+under the examples directory.  But even with just these examples, you
+should be able to get started on reasonable complex grammars.
+
+---------------------------------------------------------------------
+
+Summary Instructions:
+
+If you are a parser and lexical analyzer expert and can understand the
+examples by just reading them, the following instructions show you how
+to get started with javacc.  The instructions below are with respect
+to Simple1.jj, but you can build any parser using the same set of
+commands.
+
+1. Run javacc on the grammar input file to generate a bunch of Java
+   files that implement the parser and lexical analyzer (or token
+   manager):
+
+	javacc Simple1.jj
+
+2. Now compile the resulting Java programs:
+
+	javac *.java
+
+3. The parser is now ready to use.  To run the parser, type:
+
+	java Simple1
+
+The Simple1 parser and others in this directory are designed to take
+input from standard input.  Simple1 recognizes matching braces
+followed by zero or more line terminators and then an end of file.
+
+Examples of legal strings in this grammar are:
+
+  "{}", "{{{{{}}}}}", etc.
+
+Examples of illegal strings are:
+
+  "{{{{", "{}{}", "{}}", "{{}{}}", "{ }", "{x}", etc.
+
+Try typing various different inputs to Simple1.  Remember <control-d>
+may be used to indicate the end of file (this is on the UNIX platform).
+Here are some sample runs:
+
+	% java Simple1
+	{{}}<return>
+	<control-d>
+	%
+
+	% java Simple1
+	{x<return>
+	Lexical error at line 1, column 2.  Encountered: "x"
+	TokenMgrError: Lexical error at line 1, column 2.  Encountered: "x" (120), after : ""
+	        at Simple1TokenManager.getNextToken(Simple1TokenManager.java:146)
+	        at Simple1.getToken(Simple1.java:140)
+	        at Simple1.MatchedBraces(Simple1.java:51)
+	        at Simple1.Input(Simple1.java:10)
+	        at Simple1.main(Simple1.java:6)
+	%
+
+	% java Simple1
+	{}}<return>
+	ParseException: Encountered "}" at line 1, column 3.
+	Was expecting one of:
+	    <EOF> 
+	    "\n" ...
+	    "\r" ...
+
+	        at Simple1.generateParseException(Simple1.java:184)
+	        at Simple1.jj_consume_token(Simple1.java:126)
+	        at Simple1.Input(Simple1.java:32)
+	        at Simple1.main(Simple1.java:6)
+	%
+
+---------------------------------------------------------------------
+
+DETAILED DESCRIPTION OF Simple1.jj:
+
+This is a simple JavaCC grammar that recognizes a set of left braces
+followed by the same number of right braces and finally followed by
+zero or more line terminators and finally an end of file.  Examples of
+legal strings in this grammar are:
+
+  "{}", "{{{{{}}}}}", etc.
+
+Examples of illegal strings are:
+
+  "{{{{", "{}{}", "{}}", "{{}{}}", etc.
+
+This grammar file starts with settings for all the options offered by
+JavaCC.  In this case the option settings are their default values.
+Hence these option settings were really not necessary.  One could as
+well have completely omitted the options section, or omitted one or
+more of the individual option settings.  The details of the individual
+options is described in the JavaCC documentation in the web pages.
+
+Following this is a Java compilation unit enclosed between
+"PARSER_BEGIN(name)" and "PARSER_END(name)".  This compilation unit
+can be of arbitrary complexity.  The only constraint on this
+compilation unit is that it must define a class called "name" - the
+same as the arguments to PARSER_BEGIN and PARSER_END.  This is the
+name that is used as the prefix for the Java files generated by the
+parser generator.  The parser code that is generated is inserted
+immediately before the closing brace of the class called "name".
+
+In the above example, the class in which the parser is generated
+contains a main program.  This main program creates an instance of the
+parser object (an object of type Simple1) by using a constructor that
+takes one argument of type java.io.InputStream ("System.in" in this
+case).
+
+The main program then makes a call to the non-terminal in the grammar
+that it would like to parse - "Input" in this case.  All non-terminals
+have equal status in a JavaCC generated parser, and hence one may
+parse with respect to any grammar non-terminal.
+
+Following this is a list of productions.  In this example, there are
+two productions, that define the non-terminals "Input" and
+"MatchedBraces" respectively.  In JavaCC grammars, non-terminals are
+written and implemented (by JavaCC) as Java methods.  When the
+non-terminal is used on the left-hand side of a production, it is
+considered to be declared and its syntax follows the Java syntax.  On
+the right-hand side its use is similar to a method call in Java.
+
+Each production defines its left-hand side non-terminal followed by a
+colon.  This is followed by a bunch of declarations and statements
+within braces (in both cases in the above example, there are no
+declarations and hence this appears as "{}") which are generated as
+common declarations and statements into the generated method.  This is
+then followed by a set of expansions also enclosed within braces.
+
+Lexical tokens (regular expressions) in a JavaCC input grammar are
+either simple strings ("{", "}", "\n", and "\r" in the above example),
+or a more complex regular expression.  In our example above, there is
+one such regular expression "<EOF>" which is matched by the end of
+file.  All complex regular expressions are enclosed within angular
+brackets.
+
+The first production above says that the non-terminal "Input" expands
+to the non-terminal "MethodBraces" followed by zero or more line
+terminators ("\n" or "\r") and then the end of file.
+
+The second production above says that the non-terminal "MatchedBraces"
+expands to the token "{" followed by an optional nested expansion of
+"MatchedBraces" followed by the token "}".  Square brackets [...]
+in a JavaCC input file indicate that the ... is optional.
+
+[...] may also be written as (...)?.  These two forms are equivalent.
+Other structures that may appear in expansions are:
+
+   e1 | e2 | e3 | ... : A choice of e1, e2, e3, etc.
+   ( e )+             : One or more occurrences of e
+   ( e )*             : Zero or more occurrences of e
+
+Note that these may be nested within each other, so we can have
+something like:
+
+   (( e1 | e2 )* [ e3 ] ) | e4
+
+To build this parser, simply run JavaCC on this file and compile the
+resulting Java files:
+
+	javacc Simple1.jj
+	javac *.java
+
+Now you should be able to run the generated parser.  Make sure that
+the current directory is in your CLASSPATH and type:
+
+	java Simple1
+
+Now type a sequence of matching braces followed by a return and an end
+of file (CTRL-D on UNIX machines).  If this is a problem on your
+machine, you can create a file and pipe it as input to the generated
+parser in this manner (piping also does not work on all machines - if
+this is a problem, just replace "System.in" in the grammar file with
+'new FileInputStream("testfile")' and place your input inside this
+file):
+
+	java Simple1 < myfile
+
+Also try entering illegal sequences such as mismatched braces, spaces,
+and carriage returns between braces as well as other characters and
+take a look at the error messages produced by the parser.
+
+---------------------------------------------------------------------
+
+DETAILED DESCRIPTION OF Simple2.jj:
+
+Simple2.jj is a minor modification to Simple1.jj to allow white space
+characters to be interspersed among the braces.  So then input such
+as:
+
+	"{{  }\n}\n\n"
+
+will now be legal.
+
+Take a look at Simple2.jj.  The first thing you will note is that we
+have omitted the options section.  This does not change anything since
+the options in Simple1.jj were all assigned their default values.
+
+The other difference between this file and Simple1.jj is that this
+file contains a lexical specification - the region that starts with
+"SKIP".  Within this region are 4 regular expressions - space, tab,
+newline, and return.  This says that matches of these regular
+expressions are to be ignored (and not considered for parsing).  Hence
+whenever any of these 4 characters are encountered, they are just
+thrown away.
+
+In addition to SKIP, JavaCC has three other lexical specification
+regions.  These are:
+
+. TOKEN:         This is used to specify lexical tokens (see next example)
+. SPECIAL_TOKEN: This is used to specify lexical tokens that are to be
+                 ignored during parsing.  In this sense, SPECIAL_TOKEN is
+                 the same as SKIP.  However, these tokens can be recovered
+                 within parser actions to be handled appropriately.
+. MORE:          This specifies a partial token.  A complete token is
+                 made up of a sequence of MORE's followed by a TOKEN
+                 or SPECIAL_TOKEN.
+
+Please take a look at some of the more complex grammars such as the
+Java grammars for examples of usage of these lexical specification
+regions.
+
+You may build Simple2 and invoke the generated parser with input from
+the keyboard as standard input.
+
+You can also try generating the parser with the various debug options
+turned on and see what the output looks like.  To do this type:
+
+	javacc -debug_parser Simple2.jj
+	javac Simple2*.java
+	java Simple2
+
+Then type:
+
+	javacc -debug_token_manager Simple2.jj
+	javac Simple2*.java
+	java Simple2
+
+Note that token manager debugging produces a lot of diagnostic
+information and it is typically used to look at debug traces a single
+token at a time.
+
+---------------------------------------------------------------------
+
+DETAILED DESCRIPTION OF Simple3.jj:
+
+Simple3.jj is the third and final version of our matching brace
+detector.  This example illustrates the use of the TOKEN region for
+specifying lexical tokens.  In this case, "{" and "}" are defined as
+tokens and given names LBRACE and RBRACE respectively.  These labels
+can then be used within angular brackets (as in the example) to refer
+to this token.  Typically such token specifications are used for
+complex tokens such as identifiers and literals.  Tokens that are
+simple strings are left as is (in the previous examples).
+
+This example also illustrates the use of actions in the grammar
+productions.  The actions inserted in this example count the number of
+matching braces.  Note the use of the declaration region to declare
+variables "count" and "nested_count".  Also note how the non-terminal
+"MatchedBraces" returns its value as a function return value.
+
+---------------------------------------------------------------------
+
+DETAILED DESCRIPTION OF NL_Xlator.jj:
+
+This example goes into the details of writing regular expressions in
+JavaCC grammar files.  It also illustrates a slightly more complex set
+of actions that translate the expressions described by the grammar
+into English.
+
+The new concept in the above example is the use of more complex
+regular expressions.  The regular expression:
+
+  < ID: ["a"-"z","A"-"Z","_"] ( ["a"-"z","A"-"Z","_","0"-"9"] )* >
+
+creates a new regular expression whose name is ID.  This can be
+referred anywhere else in the grammar simply as <ID>.  What follows in
+square brackets are a set of allowable characters - in this case it is
+any of the lower or upper case letters or the underscore.  This is
+followed by 0 or more occurrences of any of the lower or upper case
+letters, digits, or the underscore.
+
+Other constructs that may appear in regular expressions are:
+
+  ( ... )+	: One or more occurrences of ...
+  ( ... )?	: An optional occurrence of ... (Note that in the case
+                  of lexical tokens, (...)? and [...] are not equivalent)
+  ( r1 | r2 | ... ) : Any one of r1, r2, ...
+
+A construct of the form [...] is a pattern that is matched by the
+characters specified in ... .  These characters can be individual
+characters or character ranges.  A "~" before this construct is a
+pattern that matches any character not specified in ... .  Therefore:
+
+  ["a"-"z"] matches all lower case letters
+  ~[] matches any character
+  ~["\n","\r"] matches any character except the new line characters
+
+When a regular expression is used in an expansion, it takes a value of
+type "Token".  This is generated into the generated parser directory
+as "Token.java".  In the above example, we have defined a variable of
+type "Token" and assigned the value of the regular expression to it.
+
+---------------------------------------------------------------------
+
+DETAILED DESCRIPTION OF IdList.jj:
+
+This example illustrates an important attribute of the SKIP
+specification.  The main point to note is that the regular expressions
+in the SKIP specification are only ignored *between tokens* and not
+*within tokens*.  This grammar accepts any sequence of identifiers
+with white space in between.
+
+A legal input for this grammar is:
+
+"abc xyz123 A B C \t\n aaa"
+
+This is because any number of the SKIP regular expressions are allowed
+in between consecutive <Id>'s.  However, the following is not a legal
+input:
+
+"xyz 123"
+
+This is because the space character after "xyz" is in the SKIP
+category and therefore causes one token to end and another to begin.
+This requires "123" to be a separate token and hence does not match
+the grammar.
+
+If spaces were OK within <Id>'s, then all one has to do is to replace
+the definition of Id to:
+
+TOKEN :
+{
+  < Id: ["a"-"z","A"-"Z"] ( (" ")* ["a"-"z","A"-"Z","0"-"9"] )* >
+}
+
+Note that having a space character within a TOKEN specification does
+not mean that the space character cannot be used in the SKIP
+specification.  All this means is that any space character that
+appears in the context where it can be placed within an identifier
+will participate in the match for <Id>, whereas all other space
+characters will be ignored.  The details of the matching algorithm are
+described in the JavaCC documentation in the web pages.
+
+As a corollary, one must define as tokens anything within which
+characters such as white space characters must not be present.  In the
+above example, if <Id> was defined as a grammar production rather than
+a lexical token as shown below this paragraph, then "xyz 123" would
+have been recognized as a legitimate <Id> (wrongly).
+
+void Id() :
+{}
+{
+  <["a"-"z","A"-"Z"]> ( <["a"-"z","A"-"Z","0"-"9"]> )*
+}
+
+Note that in the above definition of non-terminal Id, it is made up of
+a sequence of single character tokens (note the location of <...>s),
+and hence white space is allowed between these characters.
+
+---------------------------------------------------------------------
diff --git a/tools/javacc-4.0/examples/SimpleExamples/Simple1.jj b/tools/javacc-4.0/examples/SimpleExamples/Simple1.jj
new file mode 100644
index 0000000000000000000000000000000000000000..41c6239d52325019ceb06f219026f440f6df5ed0
--- /dev/null
+++ b/tools/javacc-4.0/examples/SimpleExamples/Simple1.jj
@@ -0,0 +1,68 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+
+options {
+  LOOKAHEAD = 1;
+  CHOICE_AMBIGUITY_CHECK = 2;
+  OTHER_AMBIGUITY_CHECK = 1;
+  STATIC = true;
+  DEBUG_PARSER = false;
+  DEBUG_LOOKAHEAD = false;
+  DEBUG_TOKEN_MANAGER = false;
+  ERROR_REPORTING = true;
+  JAVA_UNICODE_ESCAPE = false;
+  UNICODE_INPUT = false;
+  IGNORE_CASE = false;
+  USER_TOKEN_MANAGER = false;
+  USER_CHAR_STREAM = false;
+  BUILD_PARSER = true;
+  BUILD_TOKEN_MANAGER = true;
+  SANITY_CHECK = true;
+  FORCE_LA_CHECK = false;
+}
+
+PARSER_BEGIN(Simple1)
+
+public class Simple1 {
+
+  public static void main(String args[]) throws ParseException {
+    Simple1 parser = new Simple1(System.in);
+    parser.Input();
+  }
+
+}
+
+PARSER_END(Simple1)
+
+void Input() :
+{}
+{
+  MatchedBraces() ("\n"|"\r")* <EOF>
+}
+
+void MatchedBraces() :
+{}
+{
+  "{" [ MatchedBraces() ] "}"
+}
diff --git a/tools/javacc-4.0/examples/SimpleExamples/Simple2.jj b/tools/javacc-4.0/examples/SimpleExamples/Simple2.jj
new file mode 100644
index 0000000000000000000000000000000000000000..b53015378aee1fe6781a12db3579cea273179531
--- /dev/null
+++ b/tools/javacc-4.0/examples/SimpleExamples/Simple2.jj
@@ -0,0 +1,56 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+
+PARSER_BEGIN(Simple2)
+
+public class Simple2 {
+
+  public static void main(String args[]) throws ParseException {
+    Simple2 parser = new Simple2(System.in);
+    parser.Input();
+  }
+
+}
+
+PARSER_END(Simple2)
+
+SKIP :
+{
+  " "
+| "\t"
+| "\n"
+| "\r"
+}
+
+void Input() :
+{}
+{
+  MatchedBraces() <EOF>
+}
+
+void MatchedBraces() :
+{}
+{
+  "{" [ MatchedBraces() ] "}"
+}
diff --git a/tools/javacc-4.0/examples/SimpleExamples/Simple3.jj b/tools/javacc-4.0/examples/SimpleExamples/Simple3.jj
new file mode 100644
index 0000000000000000000000000000000000000000..552b797f62742596fb23b1f585b2242c65b3600a
--- /dev/null
+++ b/tools/javacc-4.0/examples/SimpleExamples/Simple3.jj
@@ -0,0 +1,64 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+
+PARSER_BEGIN(Simple3)
+
+public class Simple3 {
+
+  public static void main(String args[]) throws ParseException {
+    Simple3 parser = new Simple3(System.in);
+    parser.Input();
+  }
+
+}
+
+PARSER_END(Simple3)
+
+SKIP :
+{
+  " "
+| "\t"
+| "\n"
+| "\r"
+}
+
+TOKEN :
+{
+  <LBRACE: "{">
+| <RBRACE: "}">
+}
+
+void Input() :
+{ int count; }
+{
+  count=MatchedBraces() <EOF>
+  { System.out.println("The levels of nesting is " + count); }
+}
+
+int MatchedBraces() :
+{ int nested_count=0; }
+{
+  <LBRACE> [ nested_count=MatchedBraces() ] <RBRACE>
+  { return ++nested_count; }
+}
diff --git a/tools/javacc-4.0/examples/Transformer/ASTCompilationUnit.java b/tools/javacc-4.0/examples/Transformer/ASTCompilationUnit.java
new file mode 100644
index 0000000000000000000000000000000000000000..dda94dcfaf035be8922a34700767b7c05d2ec6ed
--- /dev/null
+++ b/tools/javacc-4.0/examples/Transformer/ASTCompilationUnit.java
@@ -0,0 +1,55 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+
+/* JJT: 0.2.2 */
+
+import java.io.*;
+
+public class ASTCompilationUnit extends SimpleNode {
+  ASTCompilationUnit(int id) {
+    super(id);
+  }
+
+
+// Manually inserted code begins here
+
+  public void process (PrintWriter ostr) {
+    Token t = begin;
+    ASTSpecialBlock bnode;
+    for (int i = 0; i < jjtGetNumChildren(); i++) {
+      bnode = (ASTSpecialBlock)jjtGetChild(i);
+      do {
+        print(t, ostr);
+        t = t.next;
+      } while (t != bnode.begin);
+      bnode.process(ostr);
+      t = bnode.end.next;
+    }
+    while (t != null) {
+      print(t, ostr);
+      t = t.next;
+    }
+  }
+
+}
diff --git a/tools/javacc-4.0/examples/Transformer/ASTSpecialBlock.java b/tools/javacc-4.0/examples/Transformer/ASTSpecialBlock.java
new file mode 100644
index 0000000000000000000000000000000000000000..61b1518fa00e318f29a75f934c4452f1172351e5
--- /dev/null
+++ b/tools/javacc-4.0/examples/Transformer/ASTSpecialBlock.java
@@ -0,0 +1,49 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+
+/* JJT: 0.2.2 */
+
+import java.io.*;
+
+public class ASTSpecialBlock extends SimpleNode {
+  ASTSpecialBlock(int id) {
+    super(id);
+  }
+
+
+// Manually inserted code begins here
+
+  public void process (PrintWriter ostr) {
+    Token t = begin; // t corresponds to the "{" of the special block.
+    t.image = "{ try {";
+    while (t != end) {
+      print(t, ostr);
+      t = t.next;
+    }
+    // t now corresponds to the last "}" of the special block.
+    t.image = "} }";
+    print(t, ostr);
+  }
+
+}
diff --git a/tools/javacc-4.0/examples/Transformer/README b/tools/javacc-4.0/examples/Transformer/README
new file mode 100644
index 0000000000000000000000000000000000000000..5d5d918470574202507082db6eaafe9db3a7870d
--- /dev/null
+++ b/tools/javacc-4.0/examples/Transformer/README
@@ -0,0 +1,57 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+The example in this directory takes an extension of Java as input and
+converts it into proper Java.  The purpose of this example is to
+illustrate:
+
+1. The use of the "next" field of tokens.
+
+2. To illustrate how one can use JJTree to build a parse tree for a
+   small part of the input and ignore the rest of the file.
+
+3. Combine 1 and 2 to process the portion for which tree nodes are
+   created and leave the rest of the file unchanged.
+
+The Java language extension handled by the grammar (ToyJava.jjt)
+allows catch and finally specifications at the end of method blocks.
+So the following is allowed (as an example):
+
+	void foo() {
+	  ...
+	} catch (Exception e) {
+	  ...
+	}
+
+The grammar file ToyJava.jjt is a modification of Java1.1.jj.  Note
+how we have changed the SKIP tokens to SPECIAL_TOKENS so that the
+output file is identical to the input file.
+
+To try this out, type:
+
+	jjtree ToyJava.jjt
+	javacc ToyJava.jj
+	javac *.java
+	java ToyParser divide.toy divide.java
+
+And then compare divide.java to divide.toy.
diff --git a/tools/javacc-4.0/examples/Transformer/SimpleNode.java b/tools/javacc-4.0/examples/Transformer/SimpleNode.java
new file mode 100644
index 0000000000000000000000000000000000000000..3ad98c2b697933b86f0eaf1b2361e7264d806f14
--- /dev/null
+++ b/tools/javacc-4.0/examples/Transformer/SimpleNode.java
@@ -0,0 +1,132 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+
+/* Generated By:JJTree: Do not edit this line. SimpleNode.java */
+/* JJT: 0.3pre1 */
+
+import java.io.PrintWriter;
+
+public class SimpleNode implements Node {
+  protected Node parent;
+  protected Node[] children;
+  protected int id;
+
+  public SimpleNode(int i) {
+    id = i;
+  }
+
+  public void jjtOpen() {
+  }
+
+  public void jjtClose() {
+  }
+  
+  public void jjtSetParent(Node n) { parent = n; }
+  public Node jjtGetParent() { return parent; }
+
+  public void jjtAddChild(Node n, int i) {
+    if (children == null) {
+      children = new Node[i + 1];
+    } else if (i >= children.length) {
+      Node c[] = new Node[i + 1];
+      System.arraycopy(children, 0, c, 0, children.length);
+      children = c;
+    }
+    children[i] = n;
+  }
+
+  public Node jjtGetChild(int i) {
+    return children[i];
+  }
+
+  public int jjtGetNumChildren() {
+    return (children == null) ? 0 : children.length;
+  }
+
+  /* You can override these two methods in subclasses of SimpleNode to
+     customize the way the node appears when the tree is dumped.  If
+     your output uses more than one line you should override
+     toString(String), otherwise overriding toString() is probably all
+     you need to do. */
+
+  public String toString() { return ToyParserTreeConstants.jjtNodeName[id]; }
+  public String toString(String prefix) { return prefix + toString(); }
+
+  /* Override this method if you want to customize how the node dumps
+     out its children. */
+
+  public void dump(String prefix) {
+    System.out.println(toString(prefix));
+    if (children != null) {
+      for (int i = 0; i < children.length; ++i) {
+	SimpleNode n = (SimpleNode)children[i];
+	if (n != null) {
+	  n.dump(prefix + " ");
+	}
+      }
+    }
+  }
+
+// Manually inserted code begins here
+
+  protected Token begin, end;
+  public void setFirstToken(Token t) { begin = t; }
+  public void setLastToken(Token t) { end = t; }
+
+  public void process (PrintWriter ostr) {
+    System.out.println("Error - this should not be called");
+    throw new Error();
+  }
+
+  // The following method prints token t, as well as all preceding 
+  // special tokens (essentially, white space and comments).
+
+  protected void print(Token t, PrintWriter ostr) {
+    Token tt = t.specialToken;
+    if (tt != null) {
+      while (tt.specialToken != null) tt = tt.specialToken;
+      while (tt != null) {
+        ostr.print(addUnicodeEscapes(tt.image));
+        tt = tt.next;
+      }
+    }
+    ostr.print(addUnicodeEscapes(t.image));
+  }
+
+  private String addUnicodeEscapes(String str) {
+    String retval = "";
+    char ch;
+    for (int i = 0; i < str.length(); i++) {
+      ch = str.charAt(i);
+      if ((ch < 0x20 || ch > 0x7e) && ch != '\t' && ch != '\n' && ch != '\r' && ch != '\f') {
+  	String s = "0000" + Integer.toString(ch, 16);
+  	retval += "\\u" + s.substring(s.length() - 4, s.length());
+      } else {
+        retval += ch;
+      }
+    }
+    return retval;
+  }
+}
+
diff --git a/tools/javacc-4.0/examples/Transformer/ToyJava.jjt b/tools/javacc-4.0/examples/Transformer/ToyJava.jjt
new file mode 100644
index 0000000000000000000000000000000000000000..c32168c66efb12071c86ac999408ffbcdb0ab21a
--- /dev/null
+++ b/tools/javacc-4.0/examples/Transformer/ToyJava.jjt
@@ -0,0 +1,1069 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+
+options {
+  MULTI = true;
+  NODE_DEFAULT_VOID = true;
+  JAVA_UNICODE_ESCAPE = true;
+}
+
+PARSER_BEGIN(ToyParser)
+
+import java.io.*;
+
+public class ToyParser {
+
+  public static void main(String args[]) throws Exception {
+    ToyParser parser;
+    ASTCompilationUnit node;
+    if (args.length == 2) {
+      System.out.println("Toy Preprocessor:  Reading from file " + args[0] + " . . .");
+      try {
+        parser = new ToyParser(new FileInputStream(args[0]));
+      } catch (FileNotFoundException e) {
+        System.out.println("Toy Preprocessor:  File " + args[0] + " not found.");
+        return;
+      }
+    } else {
+      System.out.println("Toy Preprocessor:  Usage is \"java ToyParser inputfile outputfile\"");
+      return;
+    }
+    try {
+      node = parser.CompilationUnit();
+      PrintWriter ostr = new PrintWriter(new FileWriter(args[1]));
+      node.process(ostr);
+      ostr.close();
+      System.out.println("Toy Preprocessor:  Transformation completed successfully.");
+    } catch (ParseException e) {
+      System.out.println("Toy Preprocessor:  Encountered errors during parse.");
+    } catch (IOException e) {
+      System.out.println("Toy Preprocessor:  Could not create file " + args[1]);
+    }
+  }
+
+}
+
+PARSER_END(ToyParser)
+
+
+SPECIAL_TOKEN : /* WHITE SPACE */
+{
+  " "
+| "\t"
+| "\n"
+| "\r"
+| "\f"
+}
+
+SPECIAL_TOKEN : /* COMMENTS */
+{
+  <SINGLE_LINE_COMMENT: "//" (~["\n","\r"])* ("\n"|"\r"|"\r\n")>
+| <FORMAL_COMMENT: "/**" (~["*"])* "*" ("*" | (~["*","/"] (~["*"])* "*"))* "/">
+| <MULTI_LINE_COMMENT: "/*" (~["*"])* "*" ("*" | (~["*","/"] (~["*"])* "*"))* "/">
+}
+
+TOKEN : /* RESERVED WORDS AND LITERALS */
+{
+  < 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" >
+}
+
+TOKEN : /* LITERALS */
+{
+  < 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"]
+            )
+          )
+      )*
+      "\""
+  >
+}
+
+TOKEN : /* IDENTIFIERS */
+{
+  < 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"
+      ]
+  >
+}
+
+TOKEN : /* SEPARATORS */
+{
+  < LPAREN: "(" >
+| < RPAREN: ")" >
+| < LBRACE: "{" >
+| < RBRACE: "}" >
+| < LBRACKET: "[" >
+| < RBRACKET: "]" >
+| < SEMICOLON: ";" >
+| < COMMA: "," >
+| < DOT: "." >
+}
+
+TOKEN : /* OPERATORS */
+{
+  < 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.
+ */
+
+ASTCompilationUnit CompilationUnit() #CompilationUnit :
+{}
+{
+		{
+		  jjtThis.setFirstToken(getToken(1));
+		}
+  [ PackageDeclaration() ]
+  ( ImportDeclaration() )*
+  ( TypeDeclaration() )*
+  <EOF>
+		{
+		  return jjtThis;
+		}
+}
+
+void PackageDeclaration() :
+{}
+{
+  "package" Name() ";"
+}
+
+void ImportDeclaration() :
+{}
+{
+  "import" Name() [ "." "*" ] ";"
+}
+
+void TypeDeclaration() :
+{}
+{
+  LOOKAHEAD( ( "abstract" | "final" | "public" )* "class" )
+  ClassDeclaration()
+|
+  InterfaceDeclaration()
+|
+  ";"
+}
+
+
+/*
+ * Declaration syntax follows.
+ */
+
+void ClassDeclaration() :
+{}
+{
+  ( "abstract" | "final" | "public" )*
+  UnmodifiedClassDeclaration()
+}
+
+void UnmodifiedClassDeclaration() :
+{}
+{
+  "class" <IDENTIFIER> [ "extends" Name() ] [ "implements" NameList() ]
+  ClassBody()
+}
+
+void ClassBody() :
+{}
+{
+  "{" ( ClassBodyDeclaration() )* "}"
+}
+
+void NestedClassDeclaration() :
+{}
+{
+  ( "static" | "abstract" | "final" | "public" | "protected" | "private" )*
+  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" | "public" )*
+  UnmodifiedInterfaceDeclaration()
+}
+
+void NestedInterfaceDeclaration() :
+{}
+{
+  ( "static" | "abstract" | "final" | "public" | "protected" | "private" )*
+  UnmodifiedInterfaceDeclaration()
+}
+
+void UnmodifiedInterfaceDeclaration() :
+{}
+{
+  "interface" <IDENTIFIER> [ "extends" NameList() ]
+  "{" ( InterfaceMemberDeclaration() )* "}"
+}
+
+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" | "protected" | "private" | "static" | "final" | "transient" | "volatile" )*
+  Type() VariableDeclarator() ( "," VariableDeclarator() )* ";"
+}
+
+void VariableDeclarator() :
+{}
+{
+  VariableDeclaratorId() [ "=" VariableInitializer() ]
+}
+
+void VariableDeclaratorId() :
+{}
+{
+  <IDENTIFIER> ( "[" "]" )*
+}
+
+void VariableInitializer() :
+{}
+{
+  ArrayInitializer()
+|
+  Expression()
+}
+
+void ArrayInitializer() :
+{}
+{
+  "{" [ VariableInitializer() ( LOOKAHEAD(2) "," VariableInitializer() )* ] [ "," ] "}"
+}
+
+void MethodDeclaration() :
+		{
+		  Token t;
+		}
+{
+  ( "public" | "protected" | "private" | "static" | "abstract" | "final" | "native" | "synchronized" )*
+  ResultType() MethodDeclarator() [ "throws" NameList() ]
+  (
+		{
+		  t = getToken(1);
+		}
+    Block()
+    [
+      (
+        (
+          ( "catch" "(" FormalParameter() ")" Block() )+
+          [ "finally" Block() ]
+        |
+          "finally" Block()
+        )
+		{
+		  jjtThis.setFirstToken(t);
+		  jjtThis.setLastToken(getToken(0));
+		}
+      ) #SpecialBlock
+    ]
+  |
+    ";"
+  )
+}
+
+void MethodDeclarator() :
+{}
+{
+  <IDENTIFIER> FormalParameters() ( "[" "]" )*
+}
+
+void FormalParameters() :
+{}
+{
+  "(" [ FormalParameter() ( "," FormalParameter() )* ] ")"
+}
+
+void FormalParameter() :
+{}
+{
+  [ "final" ] Type() VariableDeclaratorId()
+}
+
+void ConstructorDeclaration() :
+{}
+{
+  [ "public" | "protected" | "private" ]
+  <IDENTIFIER> FormalParameters() [ "throws" NameList() ]
+  "{"
+    [ LOOKAHEAD(ExplicitConstructorInvocation()) ExplicitConstructorInvocation() ]
+    ( BlockStatement() )*
+  "}"
+}
+
+void ExplicitConstructorInvocation() :
+{}
+{
+  LOOKAHEAD("this" Arguments() ";")
+  "this" Arguments() ";"
+|
+  [ LOOKAHEAD(2) PrimaryExpression() "." ] "super" Arguments() ";"
+}
+
+void Initializer() :
+{}
+{
+  [ "static" ] Block()
+}
+
+
+/*
+ * Type, name and expression syntax follows.
+ */
+
+void Type() :
+{}
+{
+  ( PrimitiveType() | Name() ) ( "[" "]" )*
+}
+
+void PrimitiveType() :
+{}
+{
+  "boolean"
+|
+  "char"
+|
+  "byte"
+|
+  "short"
+|
+  "int"
+|
+  "long"
+|
+  "float"
+|
+  "double"
+}
+
+void ResultType() :
+{}
+{
+  "void"
+|
+  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() :
+{}
+{
+  LOOKAHEAD( PrimaryExpression() AssignmentOperator() )
+  Assignment()
+|
+  ConditionalExpression()
+}
+
+void Assignment() :
+{}
+{
+  PrimaryExpression() AssignmentOperator() Expression()
+}
+
+void AssignmentOperator() :
+{}
+{
+  "=" | "*=" | "/=" | "%=" | "+=" | "-=" | "<<=" | ">>=" | ">>>=" | "&=" | "^=" | "|="
+}
+
+void ConditionalExpression() :
+{}
+{
+  ConditionalOrExpression() [ "?" Expression() ":" ConditionalExpression() ]
+}
+
+void ConditionalOrExpression() :
+{}
+{
+  ConditionalAndExpression() ( "||" ConditionalAndExpression() )*
+}
+
+void ConditionalAndExpression() :
+{}
+{
+  InclusiveOrExpression() ( "&&" InclusiveOrExpression() )*
+}
+
+void InclusiveOrExpression() :
+{}
+{
+  ExclusiveOrExpression() ( "|" ExclusiveOrExpression() )*
+}
+
+void ExclusiveOrExpression() :
+{}
+{
+  AndExpression() ( "^" AndExpression() )*
+}
+
+void AndExpression() :
+{}
+{
+  EqualityExpression() ( "&" EqualityExpression() )*
+}
+
+void EqualityExpression() :
+{}
+{
+  InstanceOfExpression() ( ( "==" | "!=" ) InstanceOfExpression() )*
+}
+
+void InstanceOfExpression() :
+{}
+{
+  RelationalExpression() [ "instanceof" Type() ]
+}
+
+void RelationalExpression() :
+{}
+{
+  ShiftExpression() ( ( "<" | ">" | "<=" | ">=" ) ShiftExpression() )*
+}
+
+void ShiftExpression() :
+{}
+{
+  AdditiveExpression() ( ( "<<" | ">>" | ">>>" ) AdditiveExpression() )*
+}
+
+void AdditiveExpression() :
+{}
+{
+  MultiplicativeExpression() ( ( "+" | "-" ) MultiplicativeExpression() )*
+}
+
+void MultiplicativeExpression() :
+{}
+{
+  UnaryExpression() ( ( "*" | "/" | "%" ) UnaryExpression() )*
+}
+
+void UnaryExpression() :
+{}
+{
+  ( "+" | "-" ) UnaryExpression()
+|
+  PreIncrementExpression()
+|
+  PreDecrementExpression()
+|
+  UnaryExpressionNotPlusMinus()
+}
+
+void PreIncrementExpression() :
+{}
+{
+  "++" PrimaryExpression()
+}
+
+void PreDecrementExpression() :
+{}
+{
+  "--" PrimaryExpression()
+}
+
+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() [ "++" | "--" ]
+}
+
+void CastExpression() :
+{}
+{
+  LOOKAHEAD("(" PrimitiveType())
+  "(" Type() ")" UnaryExpression()
+|
+  LOOKAHEAD("(" Name())
+  "(" Type() ")" UnaryExpressionNotPlusMinus()
+}
+
+void PrimaryExpression() :
+{}
+{
+  PrimaryPrefix() ( LOOKAHEAD(2) PrimarySuffix() )*
+}
+
+void PrimaryPrefix() :
+{}
+{
+  Literal()
+|
+  Name()
+|
+  "this"
+|
+  "super" "." <IDENTIFIER>
+|
+  "(" Expression() ")"
+|
+  AllocationExpression()
+}
+
+void PrimarySuffix() :
+{}
+{
+  LOOKAHEAD(2)
+  "." "this"
+|
+  LOOKAHEAD(2)
+  "." "class"
+|
+  LOOKAHEAD(2)
+  "." AllocationExpression()
+|
+  "[" Expression() "]"
+|
+  "." <IDENTIFIER>
+|
+  Arguments()
+}
+
+void Literal() :
+{}
+{
+  <INTEGER_LITERAL>
+|
+  <FLOATING_POINT_LITERAL>
+|
+  <CHARACTER_LITERAL>
+|
+  <STRING_LITERAL>
+|
+  BooleanLiteral()
+|
+  NullLiteral()
+}
+
+void BooleanLiteral() :
+{}
+{
+  "true"
+|
+  "false"
+}
+
+void NullLiteral() :
+{}
+{
+  "null"
+}
+
+void Arguments() :
+{}
+{
+  "(" [ ArgumentList() ] ")"
+}
+
+void ArgumentList() :
+{}
+{
+  Expression() ( "," Expression() )*
+}
+
+void AllocationExpression() :
+{}
+{
+  LOOKAHEAD(2)
+  "new" PrimitiveType() ArrayDimensions() [ ArrayInitializer() ]
+|
+  "new" Name()
+    (
+      ArrayDimensions() [ ArrayInitializer() ]
+    |
+      Arguments() [ ClassBody() ]
+    )
+}
+
+/*
+ * The second LOOKAHEAD specification below is to parse to PrimarySuffix
+ * if there is an expression between the "[...]".
+ */
+void ArrayDimensions() :
+{}
+{
+  ( LOOKAHEAD(2) "[" Expression() "]" )+ ( LOOKAHEAD(2) "[" "]" )*
+}
+
+
+/*
+ * Statement syntax follows.
+ */
+
+void Statement() :
+{}
+{
+  LOOKAHEAD(2)
+  LabeledStatement()
+|
+  Block()
+|
+  EmptyStatement()
+|
+  StatementExpression() ";"
+|
+  SwitchStatement()
+|
+  IfStatement()
+|
+  WhileStatement()
+|
+  DoStatement()
+|
+  ForStatement()
+|
+  BreakStatement()
+|
+  ContinueStatement()
+|
+  ReturnStatement()
+|
+  ThrowStatement()
+|
+  SynchronizedStatement()
+|
+  TryStatement()
+}
+
+void LabeledStatement() :
+{}
+{
+  <IDENTIFIER> ":" Statement()
+}
+
+void Block() :
+{}
+{
+  "{" ( BlockStatement() )* "}"
+}
+
+void BlockStatement() :
+{}
+{
+  LOOKAHEAD([ "final" ] Type() <IDENTIFIER>)
+  LocalVariableDeclaration() ";"
+|
+  Statement()
+|
+  UnmodifiedClassDeclaration()
+|
+  UnmodifiedInterfaceDeclaration()
+}
+
+void LocalVariableDeclaration() :
+{}
+{
+  [ "final" ] Type() VariableDeclarator() ( "," VariableDeclarator() )*
+}
+
+void EmptyStatement() :
+{}
+{
+  ";"
+}
+
+void StatementExpression() :
+/*
+ * The last expansion of this production accepts more than the legal
+ * Java expansions for StatementExpression.
+ */
+{}
+{
+  PreIncrementExpression()
+|
+  PreDecrementExpression()
+|
+  LOOKAHEAD( PrimaryExpression() AssignmentOperator() )
+  Assignment()
+|
+  PostfixExpression()
+}
+
+void SwitchStatement() :
+{}
+{
+  "switch" "(" Expression() ")" "{"
+    ( SwitchLabel() ( BlockStatement() )* )*
+  "}"
+}
+
+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" "(" Expression() ")" Statement() [ LOOKAHEAD(1) "else" Statement() ]
+}
+
+void WhileStatement() :
+{}
+{
+  "while" "(" Expression() ")" Statement()
+}
+
+void DoStatement() :
+{}
+{
+  "do" Statement() "while" "(" Expression() ")" ";"
+}
+
+void ForStatement() :
+{}
+{
+  "for" "(" [ ForInit() ] ";" [ Expression() ] ";" [ ForUpdate() ] ")" Statement()
+}
+
+void ForInit() :
+{}
+{
+  LOOKAHEAD( [ "final" ] Type() <IDENTIFIER> )
+  LocalVariableDeclaration()
+|
+  StatementExpressionList()
+}
+
+void StatementExpressionList() :
+{}
+{
+  StatementExpression() ( "," StatementExpression() )*
+}
+
+void ForUpdate() :
+{}
+{
+  StatementExpressionList()
+}
+
+void BreakStatement() :
+{}
+{
+  "break" [ <IDENTIFIER> ] ";"
+}
+
+void ContinueStatement() :
+{}
+{
+  "continue" [ <IDENTIFIER> ] ";"
+}
+
+void ReturnStatement() :
+{}
+{
+  "return" [ Expression() ] ";"
+}
+
+void ThrowStatement() :
+{}
+{
+  "throw" Expression() ";"
+}
+
+void SynchronizedStatement() :
+{}
+{
+  "synchronized" "(" Expression() ")" Block()
+}
+
+void TryStatement() :
+/*
+ * Semantic check required here to make sure that at least one
+ * finally/catch is present.
+ */
+{}
+{
+  "try" Block()
+  ( "catch" "(" FormalParameter() ")" Block() )*
+  [ "finally" Block() ]
+}
diff --git a/tools/javacc-4.0/examples/Transformer/divide.toy b/tools/javacc-4.0/examples/Transformer/divide.toy
new file mode 100644
index 0000000000000000000000000000000000000000..3c3d7e73f31bbb8652c0dba58ec8ca8b1220e811
--- /dev/null
+++ b/tools/javacc-4.0/examples/Transformer/divide.toy
@@ -0,0 +1,32 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+class Test {
+
+  int divide(int x, int y) {
+    return x/y;
+  } catch (ArithmeticException e) {
+    return Integer.MAX_VALUE;
+  }
+
+}
diff --git a/tools/javacc-4.0/examples/VTransformer/AddAcceptVisitor.java b/tools/javacc-4.0/examples/VTransformer/AddAcceptVisitor.java
new file mode 100644
index 0000000000000000000000000000000000000000..67da30b093e7ad4dfe0d6b1684cdcd655b6fd219
--- /dev/null
+++ b/tools/javacc-4.0/examples/VTransformer/AddAcceptVisitor.java
@@ -0,0 +1,59 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+
+package VTransformer;
+
+import java.io.PrintStream;
+
+public class AddAcceptVisitor extends UnparseVisitor
+{
+
+  public AddAcceptVisitor(PrintStream o)
+  {
+    super(o);
+  }
+
+
+  public Object visit(ASTClassBodyDeclaration node, Object data)
+  {
+    /* Are we the first child of our parent? */
+    if (node == node.jjtGetParent().jjtGetChild(0)) {
+
+      /** Attempt to make the new code match the indentation of the
+          node. */
+      StringBuffer pre = new StringBuffer("");
+      for (int i = 1; i < node.getFirstToken().beginColumn; ++i) {
+	pre.append(" ");
+      }
+
+      out.println(pre + "");
+      out.println(pre + "/** Accept the visitor. **/");
+      out.println(pre + "public Object jjtAccept(JavaParserVisitor visitor, Object data) {");
+      out.println(pre + "  return visitor.visit(this, data);");
+      out.println(pre + "}");
+    }
+    return super.visit(node, data);
+  }
+
+}
diff --git a/tools/javacc-4.0/examples/VTransformer/Java1.1.jjt b/tools/javacc-4.0/examples/VTransformer/Java1.1.jjt
new file mode 100644
index 0000000000000000000000000000000000000000..2d452e22c9d9eebc8bcfb76419d8f261f8807a54
--- /dev/null
+++ b/tools/javacc-4.0/examples/VTransformer/Java1.1.jjt
@@ -0,0 +1,1066 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+
+options {
+  JAVA_UNICODE_ESCAPE = true;
+
+  STATIC=false;
+  MULTI=true;
+  VISITOR=true;
+  NODE_USES_PARSER=true;
+}
+
+PARSER_BEGIN(JavaParser)
+
+package VTransformer;
+
+public class JavaParser {}
+
+PARSER_END(JavaParser)
+
+
+/* WHITE SPACE */
+
+SPECIAL_TOKEN :
+{
+  " "
+| "\t"
+| "\n"
+| "\r"
+| "\f"
+}
+
+/* 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.
+ */
+
+ASTCompilationUnit CompilationUnit() :
+{}
+{
+  [ PackageDeclaration() ]
+  ( ImportDeclaration() )*
+  ( TypeDeclaration() )*
+  <EOF>
+                {
+		  return jjtThis;
+		}	
+}
+
+void PackageDeclaration() :
+{}
+{
+  "package" Name() ";"
+}
+
+void ImportDeclaration() :
+{}
+{
+  "import" Name() [ "." "*" ] ";"
+}
+
+void TypeDeclaration() :
+{}
+{
+  LOOKAHEAD( ( "abstract" | "final" | "public" )* "class" )
+  ClassDeclaration()
+|
+  InterfaceDeclaration()
+|
+  ";"
+}
+
+
+/*
+ * Declaration syntax follows.
+ */
+
+void ClassDeclaration() :
+{}
+{
+  ( "abstract" | "final" | "public" )*
+  UnmodifiedClassDeclaration()
+}
+
+void UnmodifiedClassDeclaration() :
+{}
+{
+  "class" <IDENTIFIER> [ "extends" Name() ] [ "implements" NameList() ]
+  ClassBody()
+}
+
+void ClassBody() :
+{}
+{
+  "{" ( ClassBodyDeclaration() )* "}"
+}
+
+void NestedClassDeclaration() :
+{}
+{
+  ( "static" | "abstract" | "final" | "public" | "protected" | "private" )*
+  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" | "public" )*
+  UnmodifiedInterfaceDeclaration()
+}
+
+void NestedInterfaceDeclaration() :
+{}
+{
+  ( "static" | "abstract" | "final" | "public" | "protected" | "private" )*
+  UnmodifiedInterfaceDeclaration()
+}
+
+void UnmodifiedInterfaceDeclaration() :
+{}
+{
+  "interface" <IDENTIFIER> [ "extends" NameList() ]
+  "{" ( InterfaceMemberDeclaration() )* "}"
+}
+
+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" | "protected" | "private" | "static" | "final" | "transient" | "volatile" )*
+  Type() VariableDeclarator() ( "," VariableDeclarator() )* ";"
+}
+
+void VariableDeclarator() :
+{}
+{
+  VariableDeclaratorId() [ "=" VariableInitializer() ]
+}
+
+void VariableDeclaratorId() :
+{}
+{
+  <IDENTIFIER> ( "[" "]" )*
+}
+
+void VariableInitializer() :
+{}
+{
+  ArrayInitializer()
+|
+  Expression()
+}
+
+void ArrayInitializer() :
+{}
+{
+  "{" [ VariableInitializer() ( LOOKAHEAD(2) "," VariableInitializer() )* ] [ "," ] "}"
+}
+
+void MethodDeclaration() :
+{}
+{
+  ( "public" | "protected" | "private" | "static" | "abstract" | "final" | "native" | "synchronized" )*
+  ResultType() MethodDeclarator() [ "throws" NameList() ]
+  ( Block() | ";" )
+}
+
+void MethodDeclarator() :
+{}
+{
+  <IDENTIFIER> FormalParameters() ( "[" "]" )*
+}
+
+void FormalParameters() :
+{}
+{
+  "(" [ FormalParameter() ( "," FormalParameter() )* ] ")"
+}
+
+void FormalParameter() :
+{}
+{
+  [ "final" ] Type() VariableDeclaratorId()
+}
+
+void ConstructorDeclaration() :
+{}
+{
+  [ "public" | "protected" | "private" ]
+  <IDENTIFIER> FormalParameters() [ "throws" NameList() ]
+  "{"
+    [ LOOKAHEAD(ExplicitConstructorInvocation()) ExplicitConstructorInvocation() ]
+    ( BlockStatement() )*
+  "}"
+}
+
+void ExplicitConstructorInvocation() :
+{}
+{
+  LOOKAHEAD("this" Arguments() ";")
+  "this" Arguments() ";"
+|
+  [ LOOKAHEAD(2) PrimaryExpression() "." ] "super" Arguments() ";"
+}
+
+void Initializer() :
+{}
+{
+  [ "static" ] Block()
+}
+
+
+/*
+ * Type, name and expression syntax follows.
+ */
+
+void Type() :
+{}
+{
+  ( PrimitiveType() | Name() ) ( "[" "]" )*
+}
+
+void PrimitiveType() :
+{}
+{
+  "boolean"
+|
+  "char"
+|
+  "byte"
+|
+  "short"
+|
+  "int"
+|
+  "long"
+|
+  "float"
+|
+  "double"
+}
+
+void ResultType() :
+{}
+{
+  "void"
+|
+  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() :
+{}
+{
+  "=" | "*=" | "/=" | "%=" | "+=" | "-=" | "<<=" | ">>=" | ">>>=" | "&=" | "^=" | "|="
+}
+
+void ConditionalExpression() :
+{}
+{
+  ConditionalOrExpression() [ "?" Expression() ":" ConditionalExpression() ]
+}
+
+void ConditionalOrExpression() :
+{}
+{
+  ConditionalAndExpression() ( "||" ConditionalAndExpression() )*
+}
+
+void ConditionalAndExpression() :
+{}
+{
+  InclusiveOrExpression() ( "&&" InclusiveOrExpression() )*
+}
+
+void InclusiveOrExpression() :
+{}
+{
+  ExclusiveOrExpression() ( "|" ExclusiveOrExpression() )*
+}
+
+void ExclusiveOrExpression() :
+{}
+{
+  AndExpression() ( "^" AndExpression() )*
+}
+
+void AndExpression() :
+{}
+{
+  EqualityExpression() ( "&" EqualityExpression() )*
+}
+
+void EqualityExpression() :
+{}
+{
+  InstanceOfExpression() ( ( "==" | "!=" ) InstanceOfExpression() )*
+}
+
+void InstanceOfExpression() :
+{}
+{
+  RelationalExpression() [ "instanceof" Type() ]
+}
+
+void RelationalExpression() :
+{}
+{
+  ShiftExpression() ( ( "<" | ">" | "<=" | ">=" ) ShiftExpression() )*
+}
+
+void ShiftExpression() :
+{}
+{
+  AdditiveExpression() ( ( "<<" | ">>" | ">>>" ) AdditiveExpression() )*
+}
+
+void AdditiveExpression() :
+{}
+{
+  MultiplicativeExpression() ( ( "+" | "-" ) MultiplicativeExpression() )*
+}
+
+void MultiplicativeExpression() :
+{}
+{
+  UnaryExpression() ( ( "*" | "/" | "%" ) UnaryExpression() )*
+}
+
+void UnaryExpression() :
+{}
+{
+  ( "+" | "-" ) UnaryExpression()
+|
+  PreIncrementExpression()
+|
+  PreDecrementExpression()
+|
+  UnaryExpressionNotPlusMinus()
+}
+
+void PreIncrementExpression() :
+{}
+{
+  "++" PrimaryExpression()
+}
+
+void PreDecrementExpression() :
+{}
+{
+  "--" PrimaryExpression()
+}
+
+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() [ "++" | "--" ]
+}
+
+void CastExpression() :
+{}
+{
+  LOOKAHEAD("(" PrimitiveType())
+  "(" Type() ")" UnaryExpression()
+|
+  LOOKAHEAD("(" Name())
+  "(" Type() ")" UnaryExpressionNotPlusMinus()
+}
+
+void PrimaryExpression() :
+{}
+{
+  PrimaryPrefix() ( LOOKAHEAD(2) PrimarySuffix() )*
+}
+
+void PrimaryPrefix() :
+{}
+{
+  Literal()
+|
+  "this"
+|
+  "super" "." <IDENTIFIER>
+|
+  "(" Expression() ")"
+|
+  AllocationExpression()
+|
+  LOOKAHEAD( ResultType() "." "class" )
+  ResultType() "." "class"
+|
+  Name()
+}
+
+void PrimarySuffix() :
+{}
+{
+  LOOKAHEAD(2)
+  "." "this"
+|
+  LOOKAHEAD(2)
+  "." AllocationExpression()
+|
+  "[" Expression() "]"
+|
+  "." <IDENTIFIER>
+|
+  Arguments()
+}
+
+void Literal() :
+{}
+{
+  <INTEGER_LITERAL>
+|
+  <FLOATING_POINT_LITERAL>
+|
+  <CHARACTER_LITERAL>
+|
+  <STRING_LITERAL>
+|
+  BooleanLiteral()
+|
+  NullLiteral()
+}
+
+void BooleanLiteral() :
+{}
+{
+  "true"
+|
+  "false"
+}
+
+void NullLiteral() :
+{}
+{
+  "null"
+}
+
+void Arguments() :
+{}
+{
+  "(" [ ArgumentList() ] ")"
+}
+
+void ArgumentList() :
+{}
+{
+  Expression() ( "," Expression() )*
+}
+
+void AllocationExpression() :
+{}
+{
+  LOOKAHEAD(2)
+  "new" PrimitiveType() ArrayDimsAndInits()
+|
+  "new" Name()
+    (
+      ArrayDimsAndInits()
+    |
+      Arguments() [ ClassBody() ]
+    )
+}
+
+/*
+ * The second 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() ";"
+|
+  SwitchStatement()
+|
+  IfStatement()
+|
+  WhileStatement()
+|
+  DoStatement()
+|
+  ForStatement()
+|
+  BreakStatement()
+|
+  ContinueStatement()
+|
+  ReturnStatement()
+|
+  ThrowStatement()
+|
+  SynchronizedStatement()
+|
+  TryStatement()
+}
+
+void LabeledStatement() :
+{}
+{
+  <IDENTIFIER> ":" Statement()
+}
+
+void Block() :
+{}
+{
+  "{" ( BlockStatement() )* "}"
+}
+
+void BlockStatement() :
+{}
+{
+  LOOKAHEAD([ "final" ] Type() <IDENTIFIER>)
+  LocalVariableDeclaration() ";"
+|
+  Statement()
+|
+  UnmodifiedClassDeclaration()
+}
+
+void LocalVariableDeclaration() :
+{}
+{
+  [ "final" ] 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()
+  [
+    "++"
+  |
+    "--"
+  |
+    AssignmentOperator() Expression()
+  ]
+}
+
+void SwitchStatement() :
+{}
+{
+  "switch" "(" Expression() ")" "{"
+    ( SwitchLabel() ( BlockStatement() )* )*
+  "}"
+}
+
+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" "(" Expression() ")" Statement() [ LOOKAHEAD(1) "else" Statement() ]
+}
+
+void WhileStatement() :
+{}
+{
+  "while" "(" Expression() ")" Statement()
+}
+
+void DoStatement() :
+{}
+{
+  "do" Statement() "while" "(" Expression() ")" ";"
+}
+
+void ForStatement() :
+{}
+{
+  "for" "(" [ ForInit() ] ";" [ Expression() ] ";" [ ForUpdate() ] ")" Statement()
+}
+
+void ForInit() :
+{}
+{
+  LOOKAHEAD( [ "final" ] Type() <IDENTIFIER> )
+  LocalVariableDeclaration()
+|
+  StatementExpressionList()
+}
+
+void StatementExpressionList() :
+{}
+{
+  StatementExpression() ( "," StatementExpression() )*
+}
+
+void ForUpdate() :
+{}
+{
+  StatementExpressionList()
+}
+
+void BreakStatement() :
+{}
+{
+  "break" [ <IDENTIFIER> ] ";"
+}
+
+void ContinueStatement() :
+{}
+{
+  "continue" [ <IDENTIFIER> ] ";"
+}
+
+void ReturnStatement() :
+{}
+{
+  "return" [ Expression() ] ";"
+}
+
+void ThrowStatement() :
+{}
+{
+  "throw" Expression() ";"
+}
+
+void SynchronizedStatement() :
+{}
+{
+  "synchronized" "(" Expression() ")" Block()
+}
+
+void TryStatement() :
+/*
+ * Semantic check required here to make sure that at least one
+ * finally/catch is present.
+ */
+{}
+{
+  "try" Block()
+  ( "catch" "(" FormalParameter() ")" Block() )*
+  [ "finally" Block() ]
+}
diff --git a/tools/javacc-4.0/examples/VTransformer/Main.java b/tools/javacc-4.0/examples/VTransformer/Main.java
new file mode 100644
index 0000000000000000000000000000000000000000..33a229694a3397a2c7905016b80b7ec4ad70b4b3
--- /dev/null
+++ b/tools/javacc-4.0/examples/VTransformer/Main.java
@@ -0,0 +1,45 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+
+package VTransformer;
+
+import java.io.*;
+
+public class Main
+{
+  public static void main(String args[]) {
+    System.err.println("Reading from standard input...");
+    JavaParser p = new JavaParser(System.in);
+    try {
+      ASTCompilationUnit cu = p.CompilationUnit();
+      JavaParserVisitor visitor = new AddAcceptVisitor(System.out);
+      cu.jjtAccept(visitor, null);
+      System.err.println("Thank you.");
+    } catch (Exception e) {
+      System.err.println("Oops.");
+      System.err.println(e.getMessage());
+      e.printStackTrace();
+    }
+  }
+}
diff --git a/tools/javacc-4.0/examples/VTransformer/README b/tools/javacc-4.0/examples/VTransformer/README
new file mode 100644
index 0000000000000000000000000000000000000000..3327ea8f12dd5eef1b429d6de4176d29edf11817
--- /dev/null
+++ b/tools/javacc-4.0/examples/VTransformer/README
@@ -0,0 +1,136 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+This directory contains an example of using the Visitor design pattern
+with JJTree.  Like the Transformer example, it shows how a Java
+program can be processed into a slightly different form.
+
+In this case the input code is transformed so that each class has a
+jjtAccept() method inserted.  This might be useful for updating node
+files created with an earlier version of JJTree so that they can be
+used with the Visitor support.
+
+Here is an overview of the source files:
+
+Java1.1.jjt
+
+  This JJTree source file has been slightly modified from the Java 1.1
+  grammar distributed in the JavaGrammars examples directory.  Here
+  are the main differences:
+
+  1) Removed the main method from the parser class;
+
+  2) Added a couple of JJTree options;
+
+  3) Made the CompilationUnit production return a root AST node;
+
+  4) Made white space SPECIAL_TOKENs rather than SKIPs;
+
+  These changes illustrate how a JavaCC grammar can be used with
+  JJTree with very little modification.  In particular, there are no
+  node annotations -- instead each production in the grammar is
+  represented as a node.
+
+Main.java
+
+  Simply calls the parser to create the AST, creates a Visitor, and
+  then asks the root node to accept the visitor.
+
+SimpleNode.java
+
+  This is modified from the automatically generated file.  SimpleNodes
+  now maintain their first and last tokens so that the input can be
+  reconstituted.  The jjtOpen() and jjtClose() methods are used as
+  hooks to collect and store these tokens.  The NODE_USES_PARSER
+  option is specified so that the parser object is available to these
+  methods.
+
+UnparseVisitor.java
+
+  This is a generally useful Visitor that simply unparses the nodes
+  that it visits.  It is intended to be a superclass for
+  transformation-specific Visitors such as AddAcceptVisitor.
+
+AddAcceptVisitor.java
+
+  This is a Visitor for a particular transformation.  It extends
+  UnparseVisitor and overrides methods for those nodes that require
+  special treatment.  In this case, only the visit method for
+  ClassBodyDeclaration nodes needs to be overridden.
+
+  The visitor determines whether the node currently being visited is
+  the first child of its parent, and if so it inserts the new text.
+  It makes an attempt to indent the new text at the same level as the
+  current node.
+
+
+Here's how to build the transformer:
+
+1) Run the JJTree on the grammar.  It will generate many node files
+because the MULTI option is set.
+
+trane% jjtree Java1.1.jjt 
+Java Compiler Compiler Version 2.0 (Tree Builder)
+Copyright (c) 1996-1999 Sun Microsystems, Inc.
+Copyright (c) 1997-1999 Metamata, Inc.
+(type "jjtree" with no arguments for help)
+Reading from file Java1.1.jjt . . .
+File "Node.java" does not exist.  Will create one.
+File "ASTCompilationUnit.java" does not exist.  Will create one.
+File "ASTPackageDeclaration.java" does not exist.  Will create one.
+  ... lots more nodes generated here
+File "ASTSynchronizedStatement.java" does not exist.  Will create one.
+File "ASTTryStatement.java" does not exist.  Will create one.
+Annotated grammar generated successfully in Java1.1.jj
+trane% 
+
+2) Run JavaCC on the generated grammar.
+
+trane% javacc Java1.1.jj
+Java Compiler Compiler Version 2.0 (Parser Generator)
+Copyright (c) 1996-1999 Sun Microsystems, Inc.
+Copyright (c) 1997-1999 Metamata, Inc.
+(type "javacc" with no arguments for help)
+Reading from file Java1.1.jj . . .
+File "TokenMgrError.java" does not exist.  Will create one.
+File "ParseException.java" does not exist.  Will create one.
+File "Token.java" does not exist.  Will create one.
+File "ASCII_UCodeESC_CharStream.java" does not exist.  Will create one.
+Parser generated successfully.
+trane% 
+
+3) Ensure that your class path is set up correctly.  The examples
+directory (above VTransformer) should be in your class path.
+
+4) Compile the Java files
+
+trane% javac Main.java
+
+5) And finally run it.  It works as a filter now, but it would be
+straightforward to make it take file names as arguments.  The
+example below shows how to apply the filter on Main.java itself.
+
+trane% java VTransformer.Main < Main.java > Main.new
+Reading from standard input...
+Thank you.
+trane%
diff --git a/tools/javacc-4.0/examples/VTransformer/SimpleNode.java b/tools/javacc-4.0/examples/VTransformer/SimpleNode.java
new file mode 100644
index 0000000000000000000000000000000000000000..e751766e22cba91a148cef25f2c7f440d1789f8d
--- /dev/null
+++ b/tools/javacc-4.0/examples/VTransformer/SimpleNode.java
@@ -0,0 +1,119 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+
+package VTransformer;
+
+public class SimpleNode implements Node {
+  protected Node parent;
+  protected Node[] children;
+  protected int id;
+  protected JavaParser parser;
+
+  protected Token first, last;
+
+  public SimpleNode(int i) {
+    id = i;
+  }
+
+  public SimpleNode(JavaParser p, int i) {
+    this(i);
+    parser = p;
+  }
+
+  public static Node jjtCreate(JavaParser p, int id) {
+    return new SimpleNode(p, id);
+  }
+
+  public void jjtOpen() {
+    first = parser.getToken(1);	// new
+  }
+
+  public void jjtClose() {
+    last = parser.getToken(0);	// new
+  }
+
+  public Token getFirstToken() { return first; } // new
+  public Token getLastToken() { return last; }   // new
+  
+  public void jjtSetParent(Node n) { parent = n; }
+  public Node jjtGetParent() { return parent; }
+
+  public void jjtAddChild(Node n, int i) {
+    if (children == null) {
+      children = new Node[i + 1];
+    } else if (i >= children.length) {
+      Node c[] = new Node[i + 1];
+      System.arraycopy(children, 0, c, 0, children.length);
+      children = c;
+    }
+    children[i] = n;
+  }
+
+  public Node jjtGetChild(int i) {
+    return children[i];
+  }
+
+  public int jjtGetNumChildren() {
+    return (children == null) ? 0 : children.length;
+  }
+
+  /** Accept the visitor. **/
+  public Object jjtAccept(JavaParserVisitor visitor, Object data) {
+    return visitor.visit(this, data);
+  }
+
+  /** Accept the visitor. **/
+  public Object acceptChildren(JavaParserVisitor visitor, Object data) {
+    if (children != null) {
+      for (int i = 0; i < children.length; ++i) {
+        children[i].jjtAccept(visitor, data);
+      }
+    }
+    return data;
+  }
+
+  /* You can override these two methods in subclasses of SimpleNode to
+     customize the way the node appears when the tree is dumped.  If
+     your output uses more than one line you should override
+     toString(String), otherwise overriding toString() is probably all
+     you need to do. */
+
+  public String toString() { return JavaParserTreeConstants.jjtNodeName[id]; }
+  public String toString(String prefix) { return prefix + toString(); }
+
+  /* Override this method if you want to customize how the node dumps
+     out its children. */
+
+  public void dump(String prefix) {
+    System.out.println(toString(prefix));
+    if (children != null) {
+      for (int i = 0; i < children.length; ++i) {
+	SimpleNode n = (SimpleNode)children[i];
+	if (n != null) {
+	  n.dump(prefix + " ");
+	}
+      }
+    }
+  }
+}
diff --git a/tools/javacc-4.0/examples/VTransformer/UnparseVisitor.java b/tools/javacc-4.0/examples/VTransformer/UnparseVisitor.java
new file mode 100644
index 0000000000000000000000000000000000000000..3b218cc902a7ee95a9e0c3dce2f3ca2e80f79fb2
--- /dev/null
+++ b/tools/javacc-4.0/examples/VTransformer/UnparseVisitor.java
@@ -0,0 +1,521 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements.  Use is subject to license terms.
+ * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries.  Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited.  Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+
+package VTransformer;
+
+import java.io.PrintStream;
+
+public class UnparseVisitor implements JavaParserVisitor
+{
+
+  protected PrintStream out;
+
+
+  public UnparseVisitor(PrintStream o)
+  {
+    out = o;
+  }
+
+
+  public Object print(SimpleNode node, Object data) {
+    Token t1 = node.getFirstToken();
+    Token t = new Token();
+    t.next = t1;
+
+    SimpleNode n;
+    for (int ord = 0; ord < node.jjtGetNumChildren(); ord++) {
+      n = (SimpleNode)node.jjtGetChild(ord);
+      while (true) {
+	t = t.next;
+	if (t == n.getFirstToken()) break;
+	print(t);
+      }
+      n.jjtAccept(this, data);
+      t = n.getLastToken();
+    }
+
+    while (t != node.getLastToken()) {
+      t = t.next;
+      print(t);
+    }
+    return data;
+  }
+  
+  
+  protected void print(Token t) {
+    Token tt = t.specialToken;
+    if (tt != null) {
+      while (tt.specialToken != null) tt = tt.specialToken;
+      while (tt != null) {
+        out.print(addUnicodeEscapes(tt.image));
+        tt = tt.next;
+      }
+    }
+    out.print(addUnicodeEscapes(t.image));
+  }
+
+
+  private String addUnicodeEscapes(String str) {
+    String retval = "";
+    char ch;
+    for (int i = 0; i < str.length(); i++) {
+      ch = str.charAt(i);
+      if ((ch < 0x20 || ch > 0x7e) &&
+	  ch != '\t' && ch != '\n' && ch != '\r' && ch != '\f') {
+  	String s = "0000" + Integer.toString(ch, 16);
+  	retval += "\\u" + s.substring(s.length() - 4, s.length());
+      } else {
+        retval += ch;
+      }
+    }
+    return retval;
+  }
+
+
+  public Object visit(SimpleNode node, Object data)
+  {
+    return print(node, data);
+  }
+
+  public Object visit(ASTCompilationUnit node, Object data)
+  {
+    return print(node, data);
+  }
+
+  public Object visit(ASTPackageDeclaration node, Object data)
+  {
+    return print(node, data);
+  }
+
+  public Object visit(ASTImportDeclaration node, Object data)
+  {
+    return print(node, data);
+  }
+
+  public Object visit(ASTTypeDeclaration node, Object data)
+  {
+    return print(node, data);
+  }
+
+  public Object visit(ASTClassDeclaration node, Object data)
+  {
+    return print(node, data);
+  }
+
+  public Object visit(ASTUnmodifiedClassDeclaration node, Object data)
+  {
+    return print(node, data);
+  }
+
+  public Object visit(ASTClassBody node, Object data)
+  {
+    return print(node, data);
+  }
+
+  public Object visit(ASTNestedClassDeclaration node, Object data)
+  {
+    return print(node, data);
+  }
+
+  public Object visit(ASTClassBodyDeclaration node, Object data)
+  {
+    return print(node, data);
+  }
+
+  public Object visit(ASTMethodDeclarationLookahead node, Object data)
+  {
+    return print(node, data);
+  }
+
+  public Object visit(ASTInterfaceDeclaration node, Object data)
+  {
+    return print(node, data);
+  }
+
+  public Object visit(ASTNestedInterfaceDeclaration node, Object data)
+  {
+    return print(node, data);
+  }
+
+  public Object visit(ASTUnmodifiedInterfaceDeclaration node, Object data)
+  {
+    return print(node, data);
+  }
+
+  public Object visit(ASTInterfaceMemberDeclaration node, Object data)
+  {
+    return print(node, data);
+  }
+
+  public Object visit(ASTFieldDeclaration node, Object data)
+  {
+    return print(node, data);
+  }
+
+  public Object visit(ASTVariableDeclarator node, Object data)
+  {
+    return print(node, data);
+  }
+
+  public Object visit(ASTVariableDeclaratorId node, Object data)
+  {
+    return print(node, data);
+  }
+
+  public Object visit(ASTVariableInitializer node, Object data)
+  {
+    return print(node, data);
+  }
+
+  public Object visit(ASTArrayInitializer node, Object data)
+  {
+    return print(node, data);
+  }
+
+  public Object visit(ASTMethodDeclaration node, Object data)
+  {
+    return print(node, data);
+  }
+
+  public Object visit(ASTMethodDeclarator node, Object data)
+  {
+    return print(node, data);
+  }
+
+  public Object visit(ASTFormalParameters node, Object data)
+  {
+    return print(node, data);
+  }
+
+  public Object visit(ASTFormalParameter node, Object data)
+  {
+    return print(node, data);
+  }
+
+  public Object visit(ASTConstructorDeclaration node, Object data)
+  {
+    return print(node, data);
+  }
+
+  public Object visit(ASTExplicitConstructorInvocation node, Object data)
+  {
+    return print(node, data);
+  }
+
+  public Object visit(ASTInitializer node, Object data)
+  {
+    return print(node, data);
+  }
+
+  public Object visit(ASTType node, Object data)
+  {
+    return print(node, data);
+  }
+
+  public Object visit(ASTPrimitiveType node, Object data)
+  {
+    return print(node, data);
+  }
+
+  public Object visit(ASTResultType node, Object data)
+  {
+    return print(node, data);
+  }
+
+  public Object visit(ASTName node, Object data)
+  {
+    return print(node, data);
+  }
+
+  public Object visit(ASTNameList node, Object data)
+  {
+    return print(node, data);
+  }
+
+  public Object visit(ASTExpression node, Object data)
+  {
+    return print(node, data);
+  }
+
+  public Object visit(ASTAssignmentOperator node, Object data)
+  {
+    return print(node, data);
+  }
+
+  public Object visit(ASTConditionalExpression node, Object data)
+  {
+    return print(node, data);
+  }
+
+  public Object visit(ASTConditionalOrExpression node, Object data)
+  {
+    return print(node, data);
+  }
+
+  public Object visit(ASTConditionalAndExpression node, Object data)
+  {
+    return print(node, data);
+  }
+
+  public Object visit(ASTInclusiveOrExpression node, Object data)
+  {
+    return print(node, data);
+  }
+
+  public Object visit(ASTExclusiveOrExpression node, Object data)
+  {
+    return print(node, data);
+  }
+
+  public Object visit(ASTAndExpression node, Object data)
+  {
+    return print(node, data);
+  }
+
+  public Object visit(ASTEqualityExpression node, Object data)
+  {
+    return print(node, data);
+  }
+
+  public Object visit(ASTInstanceOfExpression node, Object data)
+  {
+    return print(node, data);
+  }
+
+  public Object visit(ASTRelationalExpression node, Object data)
+  {
+    return print(node, data);
+  }
+
+  public Object visit(ASTShiftExpression node, Object data)
+  {
+    return print(node, data);
+  }
+
+  public Object visit(ASTAdditiveExpression node, Object data)
+  {
+    return print(node, data);
+  }
+
+  public Object visit(ASTMultiplicativeExpression node, Object data)
+  {
+    return print(node, data);
+  }
+
+  public Object visit(ASTUnaryExpression node, Object data)
+  {
+    return print(node, data);
+  }
+
+  public Object visit(ASTPreIncrementExpression node, Object data)
+  {
+    return print(node, data);
+  }
+
+  public Object visit(ASTPreDecrementExpression node, Object data)
+  {
+    return print(node, data);
+  }
+
+  public Object visit(ASTUnaryExpressionNotPlusMinus node, Object data)
+  {
+    return print(node, data);
+  }
+
+  public Object visit(ASTCastLookahead node, Object data)
+  {
+    return print(node, data);
+  }
+
+  public Object visit(ASTPostfixExpression node, Object data)
+  {
+    return print(node, data);
+  }
+
+  public Object visit(ASTCastExpression node, Object data)
+  {
+    return print(node, data);
+  }
+
+  public Object visit(ASTPrimaryExpression node, Object data)
+  {
+    return print(node, data);
+  }
+
+  public Object visit(ASTPrimaryPrefix node, Object data)
+  {
+    return print(node, data);
+  }
+
+  public Object visit(ASTPrimarySuffix node, Object data)
+  {
+    return print(node, data);
+  }
+
+  public Object visit(ASTLiteral node, Object data)
+  {
+    return print(node, data);
+  }
+
+  public Object visit(ASTBooleanLiteral node, Object data)
+  {
+    return print(node, data);
+  }
+
+  public Object visit(ASTNullLiteral node, Object data)
+  {
+    return print(node, data);
+  }
+
+  public Object visit(ASTArguments node, Object data)
+  {
+    return print(node, data);
+  }
+
+  public Object visit(ASTArgumentList node, Object data)
+  {
+    return print(node, data);
+  }
+
+  public Object visit(ASTAllocationExpression node, Object data)
+  {
+    return print(node, data);
+  }
+
+  public Object visit(ASTArrayDimsAndInits node, Object data)
+  {
+    return print(node, data);
+  }
+
+  public Object visit(ASTStatement node, Object data)
+  {
+    return print(node, data);
+  }
+
+  public Object visit(ASTLabeledStatement node, Object data)
+  {
+    return print(node, data);
+  }
+
+  public Object visit(ASTBlock node, Object data)
+  {
+    return print(node, data);
+  }
+
+  public Object visit(ASTBlockStatement node, Object data)
+  {
+    return print(node, data);
+  }
+
+  public Object visit(ASTLocalVariableDeclaration node, Object data)
+  {
+    return print(node, data);
+  }
+
+  public Object visit(ASTEmptyStatement node, Object data)
+  {
+    return print(node, data);
+  }
+
+  public Object visit(ASTStatementExpression node, Object data)
+  {
+    return print(node, data);
+  }
+
+  public Object visit(ASTSwitchStatement node, Object data)
+  {
+    return print(node, data);
+  }
+
+  public Object visit(ASTSwitchLabel node, Object data)
+  {
+    return print(node, data);
+  }
+
+  public Object visit(ASTIfStatement node, Object data)
+  {
+    return print(node, data);
+  }
+
+  public Object visit(ASTWhileStatement node, Object data)
+  {
+    return print(node, data);
+  }
+
+  public Object visit(ASTDoStatement node, Object data)
+  {
+    return print(node, data);
+  }
+
+  public Object visit(ASTForStatement node, Object data)
+  {
+    return print(node, data);
+  }
+
+  public Object visit(ASTForInit node, Object data)
+  {
+    return print(node, data);
+  }
+
+  public Object visit(ASTStatementExpressionList node, Object data)
+  {
+    return print(node, data);
+  }
+
+  public Object visit(ASTForUpdate node, Object data)
+  {
+    return print(node, data);
+  }
+
+  public Object visit(ASTBreakStatement node, Object data)
+  {
+    return print(node, data);
+  }
+
+  public Object visit(ASTContinueStatement node, Object data)
+  {
+    return print(node, data);
+  }
+
+  public Object visit(ASTReturnStatement node, Object data)
+  {
+    return print(node, data);
+  }
+
+  public Object visit(ASTThrowStatement node, Object data)
+  {
+    return print(node, data);
+  }
+
+  public Object visit(ASTSynchronizedStatement node, Object data)
+  {
+    return print(node, data);
+  }
+
+  public Object visit(ASTTryStatement node, Object data)
+  {
+    return print(node, data);
+  }
+
+}