public abstract class Derivation extends Object
Grammar
, i.e. a possible complete tree built from the
grammar's productions and terminals.
A derivation can be displayed
in its
raw form, or in a more user-friendly fashion using
append(Displayer, Appendable)
and a custom Derivation.Displayer
implementation.
for how to produce derivations automatically
Modifier and Type | Class and Description |
---|---|
static interface |
Derivation.Displayer
This interface is used by
append(Displayer, Appendable) to allow
the display of Derivation objects to be customized. |
static class |
Derivation.NonTerminal
This represents a node in a
Derivation tree, i.e. the realization
of some non-terminal (symbol ) in the grammar via one
of its production (Derivation.NonTerminal.prod ). |
static class |
Derivation.Terminal
This represents a leaf in a
Derivation tree, i.e. some
terminal identified by its symbol number. |
Modifier and Type | Field and Description |
---|---|
short |
symbol
The ordinal of the head symbol in this derivation, i.e. either
the ordinal of the produced non-terminal, or of the leaf terminal.
|
Modifier | Constructor and Description |
---|---|
protected |
Derivation(short symbol) |
Modifier and Type | Method and Description |
---|---|
abstract void |
append(Derivation.Displayer displayer,
Appendable buf)
Appends the representation of the receiver into
buf using displayer |
String |
display(Grammar grammar) |
abstract short |
getHeight() |
static Derivation.NonTerminal |
production(short rule,
short prod,
List<Derivation> derivations) |
static Derivation.Terminal |
terminal(short token) |
String |
toString() |
public final short symbol
public abstract void append(Derivation.Displayer displayer, Appendable buf) throws IOException
buf
using displayer
displayer
- buf
- IOException
public abstract short getHeight()
public String display(Grammar grammar)
grammar
- public static Derivation.NonTerminal production(short rule, short prod, List<Derivation> derivations)
rule
- prod
- derivations
- rule
using the
production prod
and the given sub-derivationspublic static Derivation.Terminal terminal(short token)
token
-