Skip to content

Latest commit

 

History

21 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Java grammar for Iguana

A Java 14 grammar for Iguana, written in Iggy and based on the syntax described in the Java Language Specification. The grammar is defined in java.iggy and can be browsed or run in the playground.

The grammar has three notable design choices:

  • Expressions use a natural, ambiguous form. Precedence and associativity select the intended tree without splitting expressions into a hierarchy of nonterminals. The disambiguation documentation explains the notation.
  • Layout is the whitespace and comments that may occur between grammar symbols. The rule Layout = (WhiteSpace | Comment)* !>> WhiteSpace !>> Comment uses follow restrictions to prevent the repetition from stopping while more whitespace or another comment remains. This makes the choice between continuing and stopping decidable with one token of lookahead, so Layout is LL(1). Layout appears between nearly every pair of symbols, making this optimization particularly important for performance. The documentation covers layout and the measured effect of the LL(1) optimization.
  • Contextual keywords such as var, yield, and the module-system words are reserved only where the grammar expects them. The single-phase parsing documentation explains how token matching follows the grammar context.

Development

The Rust sources under src/ are generated from java.iggy and should not be edited directly. After changing the grammar, regenerate the parser and rebuild it:

iguana generate --grammar java.iggy --output .
cargo build --release

The repository has golden-file tests for individual language features and corpus tests against OpenJDK, Spring, and Elasticsearch:

cargo run --release -- --dir tests --ext java --start CompilationUnit --check-sexpr
cargo run --release -- --corpus-test

See Developing grammars for the complete workflow.

License

Licensed under either of MIT or Apache-2.0 at your option.

Copyright (c) 2026 Ali Afroozeh.

Trademark

Java is a registered trademark of Oracle and/or its affiliates. This project is not affiliated with or endorsed by Oracle.

About

Java grammar for Iguana

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages