public final class DerivationGenerator extends Object
Constructor and Description |
---|
DerivationGenerator(Grammar grammar)
This builds an object capable of generating derivations for the
given
grammar . |
Modifier and Type | Method and Description |
---|---|
void |
forEachDerivation(String ruleName,
short depth,
Consumer<Derivation> consumer)
Generates all the possible derivations of the non-terminal symbol
in the underlying grammar with the name
ruleName which are
of depth less or equal to depth . |
public DerivationGenerator(Grammar grammar)
grammar
. The same object can be used more than once,
and subsequent calls can be faster thanks to the computations from
the former calls being cached.grammar
- forEachDerivation(String, short, Consumer)
public void forEachDerivation(String ruleName, short depth, Consumer<Derivation> consumer)
ruleName
which are
of depth less or equal to depth
. The consumer
method
is called on each derivation in turn, in increasing order of depth.ruleName
- the non-terminal to derivatedepth
- the maximum depth (inclusive)consumer
- what to do with the generated derivations