| 1 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| 2 |
<html xmlns="http://www.w3.org/1999/xhtml"> |
| 3 |
<!-- |
| 4 |
|
| 5 |
Copyright (c) 2006, Sun Microsystems, Inc. |
| 6 |
All rights reserved. |
| 7 |
|
| 8 |
Redistribution and use in source and binary forms, with or without |
| 9 |
modification, are permitted provided that the following conditions are met: |
| 10 |
|
| 11 |
* Redistributions of source code must retain the above copyright notice, |
| 12 |
this list of conditions and the following disclaimer. |
| 13 |
* Redistributions in binary form must reproduce the above copyright |
| 14 |
notice, this list of conditions and the following disclaimer in the |
| 15 |
documentation and/or other materials provided with the distribution. |
| 16 |
* Neither the name of the Sun Microsystems, Inc. nor the names of its |
| 17 |
contributors may be used to endorse or promote products derived from |
| 18 |
this software without specific prior written permission. |
| 19 |
|
| 20 |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 21 |
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 22 |
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 23 |
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
| 24 |
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 25 |
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 26 |
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 27 |
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 28 |
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 29 |
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
| 30 |
THE POSSIBILITY OF SUCH DAMAGE. |
| 31 |
|
| 32 |
--> |
| 33 |
<head> |
| 34 |
<title>JavaCC Features</title> |
| 35 |
<!-- Changed by: Michael Van De Vanter, 14-Jan-2003 --> |
| 36 |
</head> |
| 37 |
<body bgcolor="#FFFFFF" > |
| 38 |
|
| 39 |
<h1>JavaCC [tm]: Features</h1> |
| 40 |
<p> |
| 41 |
JavaCC [tm] is a Java parser generator written in the Java programming language. It produces pure |
| 42 |
Java code. Both JavaCC and the parsers generated by JavaCC have been |
| 43 |
run on a variety of Java platforms. JavaCC comes with a bunch of |
| 44 |
grammars including Java 1.0.2, Java 1.1, and Java 2 as well as a couple |
| 45 |
of HTML grammars. |
| 46 |
</p> |
| 47 |
<p> |
| 48 |
Specific features of JavaCC are listed below: |
| 49 |
</p> |
| 50 |
<ul> |
| 51 |
<li> |
| 52 |
TOP-DOWN: JavaCC generates top-down (recursive descent) parsers as |
| 53 |
opposed to bottom-up parsers generated by YACC-like tools. This |
| 54 |
allows the use of more general grammars (although left-recursion is |
| 55 |
disallowed). Top-down parsers have a bunch of other advantages |
| 56 |
(besides more general grammars) such as being easier to debug, |
| 57 |
having the ability to parse to any non-terminal in the grammar, and also having the |
| 58 |
ability to pass values (attributes) both up and down the parse |
| 59 |
tree during parsing. |
| 60 |
</li> |
| 61 |
<li> |
| 62 |
LARGE USER COMMUNITY: JavaCC is by far the most popular parser |
| 63 |
generator used with Java applications. We've had over hundreds of |
| 64 |
thousands of downloads and estimate serious users in the many thousands |
| 65 |
(maybe even tens of thousands). Our <a href="mailinglist.html">mailing |
| 66 |
list</a> and newsgroups together have a few thousand participants. |
| 67 |
</li> |
| 68 |
<li> |
| 69 |
LEXICAL AND GRAMMAR SPECIFICATIONS IN ONE FILE: The lexical |
| 70 |
specifications such as regular expressions, strings, etc. and the |
| 71 |
grammar specifications (the BNF) are both written together in the same |
| 72 |
file. It makes grammars easier to read (since it is possible to use |
| 73 |
regular expressions inline in the grammar specification) and also |
| 74 |
easier to maintain. |
| 75 |
</li> |
| 76 |
<li> |
| 77 |
TREE BUILDING PREPROCESSOR: JavaCC comes with JJTree, an extremely |
| 78 |
powerful tree building preprocessor. |
| 79 |
</li> |
| 80 |
<li> |
| 81 |
EXTREMELY CUSTOMIZABLE: JavaCC offers many different options to |
| 82 |
customize its behavior and the behavior of the generated parsers. |
| 83 |
Examples of such options are the kinds of Unicode processing to |
| 84 |
perform on the input stream, the number of tokens of ambiguity |
| 85 |
checking to perform, etc. etc. |
| 86 |
</li> |
| 87 |
<li> |
| 88 |
CERTIFIED TO BE 100% PURE JAVA: JavaCC runs on all Java compliant |
| 89 |
platforms Version 1.1 or later. It has been used on countless different |
| 90 |
machines with no special porting effort - a testimonial to the |
| 91 |
"Write Once, Run Everywhere" aspect of the Java [tm] programming language. |
| 92 |
</li> |
| 93 |
<li> |
| 94 |
DOCUMENT GENERATION: JavaCC includes a tool called JJDoc that |
| 95 |
converts grammar files to documentation files (optionally in html). |
| 96 |
</li> |
| 97 |
<li> |
| 98 |
MANY MANY EXAMPLES: The JavaCC release includes a wide range of |
| 99 |
examples including Java and HTML grammars. The examples, along with |
| 100 |
their documentation, are a great way to get acquainted with JavaCC. |
| 101 |
</li> |
| 102 |
<li> |
| 103 |
INTERNATIONALIZED: The lexical analyzer of JavaCC can handle full |
| 104 |
Unicode input, and lexical specifications may also include any |
| 105 |
Unicode character. This facilitates descriptions of language elements |
| 106 |
such as Java identifiers that allow certain Unicode characters (that are |
| 107 |
not ASCII), but not others. |
| 108 |
</li> |
| 109 |
<li> |
| 110 |
SYNTACTIC AND SEMANTIC LOOKAHEAD SPECIFICATIONS: By default, JavaCC |
| 111 |
generates an LL(1) parser. However, there may be portions of the grammar |
| 112 |
that are not LL(1). JavaCC offers the capabilities of syntactic and |
| 113 |
semantic lookahead to resolve shift-shift ambiguities locally at these |
| 114 |
points. For example, the parser is LL(k) only at such points, but remains LL(1) |
| 115 |
everywhere else for better performance. Shift-reduce and reduce-reduce |
| 116 |
conflicts are not an issue for top-down parsers. |
| 117 |
</li> |
| 118 |
<li> |
| 119 |
PERMITS EXTENDED BNF SPECIFICATIONS: JavaCC allows extended BNF |
| 120 |
specifications - such as <code>(A)*</code>, <code>(A)+</code>, etc. - within the lexical and |
| 121 |
the grammar specifications. Extended BNF relieves the need for |
| 122 |
left-recursion to some extent. In fact, extended BNF is often easier |
| 123 |
to read as in <code>A ::= y(x)*</code> versus <code>A ::= Ax|y</code>. |
| 124 |
</li> |
| 125 |
<li> |
| 126 |
LEXICAL STATES AND LEXICAL ACTIONS: JavaCC offers <I>lex</I>-like lexical |
| 127 |
state and lexical action capabilities. Specific aspects in JavaCC |
| 128 |
that are superior to other tools are the first class status it offers |
| 129 |
concepts such as TOKEN, MORE, SKIP, state changes, etc. This allows |
| 130 |
cleaner specifications as well as better error and warning messages |
| 131 |
from JavaCC. |
| 132 |
</li> |
| 133 |
<li> |
| 134 |
CASE-INSENSITIVE LEXICAL ANALYSIS: Lexical specifications can define |
| 135 |
tokens not to be case sensitive either at the global level for the |
| 136 |
entire lexical specification, or on an individual lexical specification |
| 137 |
basis. |
| 138 |
</li> |
| 139 |
<li> |
| 140 |
EXTENSIVE DEBUGGING CAPABILITIES: Using options DEBUG_PARSER, |
| 141 |
DEBUG_LOOKAHEAD, and DEBUG_TOKEN_MANAGER, one can get in-depth analysis |
| 142 |
of the parsing and the token processing steps. |
| 143 |
</li> |
| 144 |
<li> |
| 145 |
SPECIAL TOKENS: Tokens that are defined as special tokens in the |
| 146 |
lexical specification are ignored during parsing, but these tokens |
| 147 |
are available for processing by the tools. A useful application of |
| 148 |
this is in the processing of comments. |
| 149 |
</li> |
| 150 |
<li> |
| 151 |
VERY GOOD ERROR REPORTING: JavaCC error reporting is among the best in |
| 152 |
parser generators. JavaCC generated parsers are able to clearly point |
| 153 |
out the location of parse errors with complete diagnostic information. |
| 154 |
</li> |
| 155 |
</ul> |
| 156 |
|
| 157 |
</body> |
| 158 |
</html> |