DOCUMENTATION. CONTACT. The Java Parser Generator. Java Compiler Compiler™ (JavaCC™) is the most popular parser generator for use with Java™ . By following the links from this page you should be able to obtain all necessary documentation on JavaCC. In addition to these links there is also some useful. 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.

Author: Faegal Moogular
Country: Zambia
Language: English (Spanish)
Genre: Photos
Published (Last): 6 December 2014
Pages: 467
PDF File Size: 16.41 Mb
ePub File Size: 17.46 Mb
ISBN: 478-4-49618-876-4
Downloads: 62052
Price: Free* [*Free Regsitration Required]
Uploader: Mitilar

Using JavaCC In practice, the scanning and parsing phases of a compiler are handled by code that is generated by a parser generator. Hence identifiers, strings, characters, etc.

This is located under the examples directory in a directory called JJTreeExamples.

There are two common shorthands for conditional nodes: By using this site, you agree to the Terms of Use and Privacy Policy.

The tree documentafion that accompanies it, JJTree, constructs its trees from the bottom up. These classes, methods, and variables are typically used from the actions that are embedded in a JavaCC grammar.

JavaCC – Wikipedia

This is then followed by a list of regular expression specifications that describe in more detail the lexical entities of this regular expression production. In such cases, it’s best to leave this option at its default value. Since each non-terminal is translated documeentation a method in the generated parser, this style of writing the non-terminal makes this association documentatoin. 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.


A local lookahead specification is used to influence the way the generated parser makes choices at the various choice points in the grammar. The generated parser documentarion contains everything in the compilation unit and, in addition, contains the generated parser code that is included at the end of the parser class.

Examples JJTree is distributed with some simple examples containing a grammar that parses arithmetic expressions. JavaCC can resolve choices based on the next k input tokens, and so can handle LL k grammars automatically; by use of “lookahead specifications”, it can also resolve documenfation requiring unbounded look ahead. A regular expression may also be a more complex regular expression using which more involved regular expression than string literals can be defined.

A conditional node descriptor expression can be any boolean expression. By default when this option is falselookahead ambiguity checking is performed for all choice points where the default lookahead of 1 is used. However, these files contain boilerplate code and are the same for any grammar and may be reused across grammars provided the grammars use compatible options.

The token manager creates a Token object for each match of such a regular expression and returns it to the parser.

JavaCC API Documentation

If this option is set to true, then the token manager is generated to read characters from any character stream reader of type “CharStream.


In this case, a legal match of the unit is any legal match of the nested choices. There are four kinds of productions in JavaCC. See Node Scope Hooks above. This option is used to obtain debugging information from the generated token manager.

Using JavaCC

These declarations and statements are written into the generated token manager and are accessible from within lexical actions. Non-terminals may not be used in an expansion in a manner that introduces left-recursion.

The default for this is true. So the parser needs to look at the next two symbols.

Typically, this option is set to false when you wish to generate only the token manager and use it without the associated parser. The parenthesized set of expansion choices can be suffixed optionally by:.

JavaCC™: Grammar Files

This method throws a ParseError exception when there is a lexical error, i. Default values for lookahead constraints: For the above example, the generated parser will look like: All AST nodes must implement this interface.

A match for this kind of complex regular expression unit is any character that is allowed by the character list.