| 1 |
/* Copyright (c) 2006, Sun Microsystems, Inc. |
| 2 |
* All rights reserved. |
| 3 |
* |
| 4 |
* Redistribution and use in source and binary forms, with or without |
| 5 |
* modification, are permitted provided that the following conditions are met: |
| 6 |
* |
| 7 |
* * Redistributions of source code must retain the above copyright notice, |
| 8 |
* this list of conditions and the following disclaimer. |
| 9 |
* * Redistributions in binary form must reproduce the above copyright |
| 10 |
* notice, this list of conditions and the following disclaimer in the |
| 11 |
* documentation and/or other materials provided with the distribution. |
| 12 |
* * Neither the name of the Sun Microsystems, Inc. nor the names of its |
| 13 |
* contributors may be used to endorse or promote products derived from |
| 14 |
* this software without specific prior written permission. |
| 15 |
* |
| 16 |
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 17 |
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 18 |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 19 |
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
| 20 |
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 21 |
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 22 |
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 23 |
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 24 |
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 25 |
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
| 26 |
* THE POSSIBILITY OF SUCH DAMAGE. |
| 27 |
*/ |
| 28 |
|
| 29 |
This directory contains a bunch of Java grammars: |
| 30 |
|
| 31 |
Java1.0.2.jj: |
| 32 |
This is our most thoroughly tested Java grammar. It is a |
| 33 |
faithful rendering of the language syntax as specified by the |
| 34 |
Java Language Specification by Gosling, Joy, and Steele. |
| 35 |
|
| 36 |
Java.1.0.2LS.jj: |
| 37 |
This is a minor modification of Java1.0.2.jj which uses |
| 38 |
lexical states to express the comment tokens. While this is a |
| 39 |
cleaner grammar, it has not been tested as thoroughly as the |
| 40 |
previous grammar. Over time, we will make this grammar our |
| 41 |
primary grammar and delete Java1.0.2.jj. |
| 42 |
|
| 43 |
Java1.1.jj: |
| 44 |
This is the grammar that includes the Java 1.1 language |
| 45 |
extensions. It is based on the Java Language Specification |
| 46 |
by Gosling, Joy, and Steele augmented by the inner class |
| 47 |
document released with JDK 1.1. |
| 48 |
|
| 49 |
Java1.1noLA.jj: |
| 50 |
Same as Java1.1.jj, but all explicit syntactic lookaheads |
| 51 |
are replaced by semantic lookaheads to minimize the space |
| 52 |
requirements of the generated parser. To do the same kind |
| 53 |
of optimization for your grammar, please see file OPTIMIZING |
| 54 |
in this directory. |
| 55 |
|
| 56 |
To build a parser from a .jj file, simply type: |
| 57 |
|
| 58 |
"javacc <grammar-file>" |
| 59 |
|
| 60 |
in this directory. The files that comprise the Java parser are |
| 61 |
generated into this directory. |
| 62 |
|
| 63 |
Compile these files using "javac". |
| 64 |
|
| 65 |
JavaParser.java contains a main program that takes input from either |
| 66 |
the standard input or from the file specified as the argument to |
| 67 |
"java". i.e., A Java program can be parser in either of the following |
| 68 |
ways: |
| 69 |
|
| 70 |
java JavaParser < javafile |
| 71 |
java JavaParser javafile |