- Type Parameters:
T
- the terminal token type of the grammarR
- the result type of the generator
- All Known Implementing Classes:
DerivationTreeGenerator
,SentenceGenerator
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Generator interface for generating sentences/derivation trees
from a given grammar.
- Since:
- 7.1
- Version:
- 7.1
-
Method Summary
Modifier and TypeMethodDescriptionGenerates a new sentence from the given grammar.Maps the generated result from typeR
to typeR1
.static <T> List
<Cfg.Symbol<T>> select
(Cfg.NonTerminal<T> rule, Cfg<T> cfg, SymbolIndex index) Standard algorithm for selecting a list of alternative symbols from the givenrule
.
-
Method Details
-
generate
Generates a new sentence from the given grammar. If the generation of the sentence fails, an empty list is returned.- Parameters:
cfg
- the generating grammar- Returns:
- a newly created result
-
map
Maps the generated result from typeR
to typeR1
.- Type Parameters:
R1
- the target type- Parameters:
f
- the mapping function- Returns:
- a new generator with target type
R1
- Throws:
NullPointerException
- if the mapping function isnull
-
select
Standard algorithm for selecting a list of alternative symbols from the givenrule
.- Type Parameters:
T
- the terminal type- Parameters:
rule
- the rule to select the alternative fromcfg
- the grammar to select the alternative fromindex
- the symbol selection strategy- Returns:
- the selected symbols
- Throws:
NullPointerException
- if one of the arguments isnull
-