| 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 many examples of JavaCC and JJTree input grammars. |
| 30 |
We recommend you see the examples in the following order. Each directory |
| 31 |
contains a README file with more detailed instructions: |
| 32 |
|
| 33 |
SimpleExamples: |
| 34 |
This is a set of very simple JavaCC examples. After trying these |
| 35 |
examples out, you should be able to build reasonably complex |
| 36 |
examples yourself. |
| 37 |
|
| 38 |
MailProcessing: |
| 39 |
These examples illustrate the use of JavaCC in parsing emacs |
| 40 |
mail files. They highlight the use of lexical states. |
| 41 |
|
| 42 |
JJTreeExamples: |
| 43 |
There are simple input grammars for JJTree, the tree building |
| 44 |
preprocessor. |
| 45 |
|
| 46 |
CORBA-IDL: |
| 47 |
This is a grammar for the IDL interface definition language of |
| 48 |
OMG CORBA 2.0. |
| 49 |
|
| 50 |
JavaGrammars: |
| 51 |
This directory contains extremely well debugged and maintained |
| 52 |
Java grammars for both the 1.0.2 and 1.1 versions of the |
| 53 |
language. |
| 54 |
|
| 55 |
JavaCCGrammar: |
| 56 |
This directory contains the official JavaCC/JJTree grammar. This |
| 57 |
is the grammar based on which JavaCC and JJTree are built. |
| 58 |
|
| 59 |
Transformer: |
| 60 |
This example illustrates how a Java language extension is defined |
| 61 |
and transformed back into Java. This makes use of JJTree. |
| 62 |
|
| 63 |
GUIParsing: |
| 64 |
These examples illustrate how one may obtain input for parsing |
| 65 |
or lexical analysis from a GUI, and thereby provide "parsing" |
| 66 |
of GUI interactions. In addition, one of these examples |
| 67 |
illustrates how state machines may be described as lexical |
| 68 |
specifications. |
| 69 |
|
| 70 |
Obfuscator: |
| 71 |
This is a complete implementation of a Java obfuscator. This |
| 72 |
allows one to take a set of Java source files and modify them |
| 73 |
into semantically equivalent source files that are much more |
| 74 |
difficult to read. This example shows the usage of multiple |
| 75 |
parsers used from one system. |
| 76 |
|
| 77 |
Interpreter: |
| 78 |
This is an interpreter for a simple language with declarations, |
| 79 |
assignments, expressions, conditionals, loops, etc. It |
| 80 |
demonstrates really nicely a complex example where JJTree is |
| 81 |
used to drastically simplify the process of generating parse |
| 82 |
trees. All actions are really methods built into the generated |
| 83 |
tree nodes. |
| 84 |
|
| 85 |
Lookahead: |
| 86 |
This directory contains the tutorial on LOOKAHEAD along with all |
| 87 |
examples used in the tutorial. |
| 88 |
|
| 89 |
VTransformer: |
| 90 |
This directory contains an example of using the Visitor design |
| 91 |
pattern with JJTree. Like the Transformer example, it shows how |
| 92 |
a Java program can be processed into a slightly different form. |