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):||25 April 2009|
|PDF File Size:||4.92 Mb|
|ePub File Size:||18.23 Mb|
|Price:||Free* [*Free Regsitration Required]|
User actions other than the final one can only access the children on the stack. As will be seen later, non-terminals on the right hand sides of productions are written as method calls, so the passing of values up and down the tree are done using exactly the same paradigm as method call and return.
The intention is to make it possible for parsers to implement error documdntation and continue with the node stack in a known state.
Hence identifiers, strings, characters, etc. The names of constants are derived by prepending JJT to the uppercase names of nodes, with dot symbols “. A character list is a way of defining a set of characters. When set to true, every call to the token manager’s method “getNextToken” see the description of the Java Compiler Compiler API will cause documentatioon call to a used defined method “CommonTokenAction” after the token has been scanned in by the token manager.
A match for this kind of complex regular expression unit is any character dockmentation is allowed by the character dockmentation. By default when this option is falselookahead ambiguity checking is performed for all choice points where the default lookahead of 1 is used. A quick and dirty way to do what most real parsers do, namely generate an abstract syntax tree, is to javscc the tree classes in the JJ file, like so:.
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 choices requiring unbounded look ahead. The interface provides methods for operations such as setting the parent of the node, and for adding children and retrieving them. 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.
At least one lookahead constraint must be present. What this means is that when expanding an E and looking at an id, we wouldn’t know if that id is starting an assignment or is just a variable, unless we examine not just the id, but also the following token.
The set of legal parses allowed by an expansion choice is a legal parse of any one of the contained expansions. A legal match for a character list is any character in this set. You notate a definite node like this: You can use this class as a template or superclass for your node implementations, or you can modify it to suit.
A character list describes a set of characters. It will not be closed, although the user-defined node scope hook closeNodeHook might be called with it as a parameter.
Sometimes no number of lookahead tokens is sufficient for the parser. The matches of this unit are all the matches of this other regular expression. This can be useful when implementing preorder and postorder traversals.
This is an expansion or expansion choices that is used for the purpose of determining whether or not the particular choice that this local lookahead specification applies to is to be taken. See the description of the lookahead algorithm for complete details on how lookahead works. This is useful when there is the need to recognize something that is not context-free or for whatever reason is very difficult to write a grammar for.
A character descriptor can be a single character string literal, in which case it describes a singleton set containing that character; or it is two single character string literals separated by a “-“, in which case, it describes the set of all characters in the range between and including these two characters.
We recommend the following step-by-step process to learning JavaCC: Then a legal match of the unit is either the empty string or any legal match of the nested choices. The final user action in a node scope is different from all the others. Yeah, it’s pretty ugly, but you didn’t write it yourself, right? This lookahead limit applies only to the choice point at the location of the local lookahead specification.
However, the token manager’s behavior is. Setting it to false causes errors due to parse errors to be reported in somewhat less detail. This document describes how to use JJTree, and how you can interface your parser to it. See Node Javadc Hooks above.
This is located under the examples directory in a directory called JJTreeExamples. If this option is set to true, then the parser is generated to accept tokens from any token manager of type “TokenManager” – this interface is generated into the generated parser directory. This facilitates some performance improvements.
This is a description to how the token manager works. There are four kinds:.
JavaCC Grammar Files
This provides the complete syntax of the grammar file along jwvacc a detailed description of these constructs. This is a boolean option whose default value is true. That many nodes are popped from the stack and made the children of the new node, which is then pushed on the stack itself. Node Scopes and User Actions Each docuemntation is associated with a node scope. This is generated into the method parsing the non-terminal at the appropriate location.
The default action is to generate a token manager that works on the specified grammar documentaion. The only reason to set this option to false is to improve performance.