Jump to content

JavaCC

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Ainslec (talk | contribs) at 18:11, 5 May 2014 (Added information on Maven Integration, linked to documentation on how to generate GWT compatible parsers, updated most recent version with references, added brief list of features, moved JJTree description to features list). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
JavaCC
Stable release
6.1.1 / May 5, 2014
Repository
PlatformJava Virtual Machine
Typeparser/scanner generator
LicenseBSD
Websitejava.net/projects/javacc
javacc.java.net

JavaCC (Java Compiler Compiler) is an open source parser generator and lexical analyzer generator for the Java programming language. JavaCC is similar to yacc in that it generates a parser from a formal grammar written in EBNF notation, except the output is Java source code.

Unlike yacc, however, JavaCC generates top-down parsers, which limits it to the LL(k) class of grammars (in particular, left recursion cannot be used). JavaCC also generates lexical analyzers in a fashion similar to lex.

JavaCC is licensed under a BSD license.

History

In 1996, Sun Microsystems released a parser generator called Jack. The developers responsible for Jack created their own company called Metamata and changed the Jack name to JavaCC. Metamata eventually became part of WebGain. After WebGain shut down its operations, JavaCC was moved to its current home.

Features

Aside from the expected features of parser generators, JavaCC also has the following features which help to distinguish it from its peers:

  • Generates lightweight pure-Java parsers, with no external dependencies. No jar at all required at runtime.
  • The tree builder that accompanies it, JJTree, constructs its trees from the bottom up.
  • Can optionally generated GWT compatible parser - 6.1.0 and above [1]
  • C++ Code generation (6.0.0 and above)

Maven Integration

The Mojo JavaCC Maven plugin has not been updated in several years, but is forward-compatible with the most recent release via the following POM configuration snippet [2].

<build>
<plugins>
  <plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>javacc-maven-plugin</artifactId>
    <version>2.6</version>
    <executions>
      <execution>
        <goals>
          <goal>javacc</goal>
        </goals>
      </execution>
    </executions>
      <dependencies>
        <dependency>
          <groupId>net.java.dev.javacc</groupId>
          <artifactId>javacc</artifactId>
          <version>6.1.1</version>
        </dependency>
      </dependencies>
  </plugin>
</plugins>
</build>

Where is it used?

Here is a non-comprehensive list of software built using JavaCC:

See also

References

  1. ^ "Building parsers for the web with JavaCC & GWT (Part one)". Chris Ainsley. Retrieved 2014-05-04.
  2. ^ "Configuring the JavaCC Maven Plugin for JavaCC 6.1.1 or above". Chris Ainsley. Retrieved 2014-05-04.