public static interface Derivation.Displayer
Derivation.append(Displayer, Appendable)
to allow
the display of Derivation
objects to be customized. The interface defines
several callback routines which are called by the displaying engine and can be
used to produce whatever structured output one wants from a derivation tree.
It is guaranteed that the methods in Derivation.Displayer
are called in a sequence
X
that follows these inductive rules:
X
is a single call to terminal(Appendable, short)
;
X
is a call to production(Appendable, short, short)
followed by either of:
enter(Appendable)
followed by any non-negative number
of X
, each followed by next(Appendable)
, ending
with one X
and a call to leave(Appendable)
.
Modifier and Type | Field and Description |
---|---|
static Derivation.Displayer |
RAW
An implementation of
Derivation.Displayer which
displays the derivations exactly as they are stored |
Modifier and Type | Method and Description |
---|---|
void |
enter(Appendable app)
Enters the sub-derivations of a production
|
void |
leave(Appendable app)
Completes the sub-derivations of a production
|
void |
next(Appendable app)
Separates two sub-derivations of a production
|
static Derivation.Displayer |
ofGrammar(Grammar grammar,
int initialIndent)
The result is printed as if starting at column
initialIndent . |
void |
production(Appendable app,
short rule,
short prod)
Displays a production for the given rule and production ordinals
|
void |
terminal(Appendable app,
short token)
Displays a terminal with the given token ordinal
|
static final Derivation.Displayer RAW
Derivation.Displayer
which
displays the derivations exactly as they are storedvoid terminal(Appendable app, short token) throws IOException
app
- token
- IOException
void production(Appendable app, short rule, short prod) throws IOException
app
- rule
- prod
- IOException
void enter(Appendable app) throws IOException
app
- IOException
void next(Appendable app) throws IOException
app
- IOException
void leave(Appendable app) throws IOException
app
- IOException
static Derivation.Displayer ofGrammar(Grammar grammar, int initialIndent)
initialIndent
.grammar
- initialIndent
- Derivation.Displayer
which
pretty-prints the derivation by interpreting it with
respect to the given grammar