SourceForge.net Logo BNF for Java: Class Diagrams


Table of Contents:


Package diagram: Compiler Tee Diagram

Any application has a source and a target, shown in this diagram, with the data flow from source (on the left) to target (on the right). But for a compiler, the compiler itself needs equal prominence, and is shown in this T diagram. The center of the T also indicates processing components of the compiler application.

Compiler Tee Diagram

The T-Diagram is adapted from H. Bratman (1961) Communications of the ACM, 4(3),p.142.


Package diagram: BNF Compiler Applications

The BNF compiler core (that is, the Engine, Scanner, Syntax, ParseTree, and storage) is designed to operate under a choice of applications.

Package diagram: BNF Compiler Applications


Package diagram: BNF package

The packages in this diagram make up the BNF Compiler. The Project interface is the front-end that your application sees, and the Engine is the supervisor at compile time.

Package diagram: BNF Compiler package


Package diagram: BNF Syntax classes

This package implements the syntax elements of the BNF grammar. For any language, these elements are assembled into a Grammar Object whose structure and content define the grammar.

Package diagram: BNF Syntax classes


Package diagram: Compiler Parse Tree

The syntax builds the Parse Tree by parsing non-terminals in the grammar, and reading terminals from the source. Each instance of the Parse Tree is defined by both the grammar and the source. When the source is completely parsed by the grammar, the Parse Tree is complete. The compiler runs a post-parse traversal of the tree, allowing the emitters (extensions) to produce their final output to the target.

Package diagram: Compiler Parse Tree


Package diagram: Source and Terminals

The BNF core defines a source interface, to scan-in terminals from the source, but does not define the implementation. It reads only specified characters, on demand from the grammar. Your character set must be defined in your BNF rules. The scanner uses a mark/reset scheme, to allow unlimited back-track when a syntax rule fails.

The DefaultSource scanner implements a text reader that buffers a text stream.

Package diagram: Source and Terminals


Package diagram: Target and Java Extensions

The BNF language does not define the output of the grammar, but it does allow extensions. BNF for Java implements "code emitters" as Java classes, and provides an AbstractEmitter class that you can extend, as well as an alias scheme, to relate Java class names to grammar meta-identifiers.

The Target is little more than a name. Your extension classes will implement the output.

The Tables provided by the BNF Parser Engine are general-purpose, and freely available to the Extensions. You can implement label a table, a context/content stack, or any other object you need.

Package diagram: Target and Java Extensions


This page of class diagrams shows the state of BNF for Java as of 1 January 2005, when the project was at "pre-alpha" stage. The developer is: Dan Cohen.

These diagrams were drawn with ArgoUML.

The BNF for Java compiler is designed to comform to the standard ISO/IEC 14977:1996 -- Extended BNF


Valid XHTML 1.1!   Valid CSS!