JavaCC
Sign in to saveJavaCC (Java Compiler Compiler) is an open-source parser generator and lexical analyzer generator written in the Java programming language.
Key facts
- Software.name
- JavaCC
- Software.developer
- Oracle
- Software.latest release version
- 7.0.10
- Software.platform
- Java Virtual Machine
- Software.genre
- parser/scanner generator
- Software.license
- BSD
via Wikipedia infobox
Source code
Java Compiler Compiler (JavaCC) is the most popular parser generator for use with Java applications. In addition to the parser generator itself, JavaCC provides other standard capabilities related to parser generation such as tree building (via a tool called JJTree included with JavaCC), actions and debugging. All you need to run a JavaCC parser, once generated, is a Java Runtime Environment (JRE). JavaCC generates top-down (recursive descent) parsers as opposed to bottom-up parsers generated by YACC-like tools. This allows the use of more general grammars, although left-recursion is disallowed. Top-down parsers have a number of other advantages (besides more general grammars) such as being easier to debug, having the ability to parse to any non-terminal in the grammar, and also having the ability to pass values (attributes) both up and down the parse tree during parsing. By default, JavaCC generates an LL(1) parser. However, there may be portions of grammar that are not LL(1) . JavaCC offers the capabilities of syntactic and semantic lookahead to resolve shift-shift ambiguities locally at these points. For example, the parser is LL(k) only at such points, but remains LL(1) everywhere else for better performance. Shift-reduce and reduce-reduce conflicts are not an issue for top-down parsers. JavaCC generates parsers that are 100% pure Java, so there is no runtime dependency on JavaCC and no special porting effort required to run on different machine platforms. The lexical specifications (such as regular expressions, strings) and the grammar specifications (the BNF) are both written together in the same file. It makes grammars easier to read since it is possible to use regular expressions inline in the grammar specification, and also easier to maintain. The lexical analyzer of JavaCC can handle full Unicode input, and lexical specifications may also include any Unicode character. This facilitates descriptions of language elements such as Java identifiers that allow certain Unicode characters (that are not ASCII), but not others. JavaCC offers Lex)-like lexical state and lexical action capabilities. Specific aspects in JavaCC that are superior to other tools are the first class status it offers concepts such as TOKEN , MORE , SKIP and state changes. This allows cleaner specifications as well as better error and warning messages from JavaCC. Tokens that are defined as special tokens in the lexical specification are ignored during parsing, but these tokens are available for processing by the tools. A useful application of this is in the processing of comments. Lexical specifications can define tokens not to be case-sensitive either at the global level for the entire lexical specification, or on an individual lexical specification basis. JavaCC also includes JJDoc, a tool that converts grammar files to documentation files, optionally in HTML. JavaCC offers many options to customize its behavior and the behavior of the generated parsers. Examples of such options are the kinds of Unicode processing to perform on the input stream, the number of tokens of ambiguity checking to perform etc. JavaCC error reporting is among the best in parser generators. JavaCC generated parsers are able to clearly point out the location of parse errors with complete diagnostic information. Using options DEBUG PARSER , DEBUG LOOKAHEAD , and DEBUG TOKEN MANAGER , users can get in-depth analysis of the parsing and the token processing steps. The JavaCC release includes a wide range of examples including Java and HTML grammars. The examples, along with their documentation, are a great way to get acquainted with JavaCC. The following JavaCC grammar example recognizes matching braces followed by zero or more line terminators and then an end of file. The RECOMMENDED version is version 8 : it separates the parser (the core) from the generators (for the different languages); development and maintenance effort will be mainly on this version. This
Excerpt from the source-code README · 25,254 chars · not written by Vinony
Wikidata facts
- Official website
- javacc.org
Show 2 more facts
- source code repository URL
- github.com/javacc/javacc
- software version identifier
- 7.0.13
Sources (2)
via Wikidata · CC0
~2 min read
Article
5 sectionsContents
- History
- Uses
- See also
- References
- External links
JavaCC (Java Compiler Compiler) is an open-source parser generator and lexical analyzer generator written in the Java programming language.
JavaCC is similar to yacc in that it generates a parser from a formal grammar written in EBNF notation. Unlike yacc, however, JavaCC generates top-down parsers. 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. JavaCC also generates lexical analyzers in a fashion similar to lex. The tree builder that accompanies it, JJTree, constructs its trees from the bottom up.