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.
|Published (Last):||16 January 2011|
|PDF File Size:||17.95 Mb|
|ePub File Size:||16.69 Mb|
|Price:||Free* [*Free Regsitration Required]|
An exception thrown by an expansion within a node scope that is not caught within the node scope is caught by JJTree itself. JJTree operates in one of two modes, simple and multi for want of better terms.
Ready to jump in?
A bunch of useful constants. This walks over the node’s children in turn, asking them to accept the visitor.
The regular expressions in this regular expression production describe tokens in the grammar. This label may be used to refer to this regular expression from expansion units or from within other regular expressions. The children can now be accessed via the node’s methods such as jjtGetChild. Options may be specified either here in the grammar file, or from the command line.
This file is generated into the generated parser directory. If you want to suppress the creation of a node for a production you can use the following syntax: There are four kinds of productions in JavaCC. Visitor Support JJTree provides some basic support for the visitor design pattern. In addition, the two methods – getToken int i and getNextToken can also be used in actions to traverse the token list.
Such an exception will probably be handled incorrectly. If the lookahead limit is not provided and if the syntactic lookahead is provided, then the lookahead limit defaults to the largest integer value Following this is a description of what kind of regular expression production this is see below for what this means.
JavaCC™: Documentation Index
Where getSymbolTable documentatiom a user-defined method to return a symbol table structure for the node. A complex regular expression unit can be a parenthesized set of complex regular expression choices. There are four kinds:. 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.
You can insert calls to the following methods to control this tracing activity:. When the production signature is decorated perhaps implicitly with the default nodethe scope is the entire right hand side of the production including its declaration block. Such references in regular expressions cannot introduce loops in the dependency between tokens.
This is the number of tokens considered in checking choices of the form “A B This is located under the examples directory in a directory called JJTreeExamples.
There can only be one token manager declaration in a JavaCC grammar file. This is because the [ White space in the grammar files also follows the same conventions as for the Java programming language.
When the code within it executes, the node’s children have already been popped from the stack and added to the documentxtion, which has itself been pushed onto the stack. Each character descriptor describes a single character or a range of characters see character descriptor belowand this is added to the set of characters of the character list. A definite node descriptor expression can be any integer expression, although literal integer constants are by far the most common expressions.
In the sample code used below, it is assumed that the name of the generated parser is “TheParser”. Tokens in the grammar files follow the same conventions as for the Java programming language.
To help the user in customizing error messages generated by the parser and lexer, the user is offered the facilities described in this section. You can use methods in this member to manipulate the node stack. 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.
You must remove left recursion before writing your grammar rules in JavaCC. JavaCC also generates lexical analyzers in a fashion similar to lex. Unlike the other two lookahead constraints that are ignored at non-choice points, semantic lookahead is always evaluated. An alternate syntax for this construct is to enclose the expansion choices within brackets “[ The toString method is convenient, though it might trick you into believing we made a code generator that targets LISP.
The FirstToken is automatically set up on entry to a node scope; the LastToken is automatically set up on exit from a node scope. The jjtree state object provides methods for you to manipulate the contents of the stack in your actions if the basic JJTree mechanisms are not sufficient.
Some checks such as detection of left recursion, detection of ambiguity, and bad usage of empty expansions may documentatiin suppressed for faster parser generation by setting this option to false.
Increasing this can give you more comprehensive ambiguity information at the cost of navacc processing time. A conditional node descriptor expression can be any boolean expression. It is often useful to keep track of each node’s first and last token so that input can be easily reproduced again.
You notate a conditional node like this: JJTree doesn’t specify how many times the expression will be evaluated. If the local lookahead specification is not at a choice point, then the syntactic lookahead is ignored – hence a default value is not relevant.
A character list describes a set of characters. Explicitly setting this option allows the user to separate the parser from the tree files. The signature of this method is: The name of the visitor interface is constructed by appending Visitor to the name of the parser.
Instead all access must be made through the parser interface. Expansion choices are written as a list of one or more expansions separated by ” “s.