public class Transformer extends Visitor
code generation. Before
applying this visitor on a grammar, the grammar must have been
simplified, all text-only productions should be
marked as such by applying the TextTester visitor, and all
token-level productions should be marked as such by applying the
Tokenizer visitor. Note that Generifier adds the
appropriate semantic values for generic productions. Further note
that repetitions in transient productions are not desugared (nor
lifted) if the corresponding command line option
("-Orepeated-Ooptional") is set. Finally, note that this
visitor assumes that the entire grammar is contained in a single
module.
This visitor may report errors to the user.| Modifier and Type | Class and Description |
|---|---|
class |
Transformer.Deducer
Visitor to add semantic values.
|
class |
Transformer.Desugarer
Visitor to desugar repetitions and options.
|
class |
Transformer.Lifter
Visitor to lift nested choices, repetitions, and options.
|
class |
Transformer.Typer
Visitor to deduce a production's type.
|
| Modifier and Type | Field and Description |
|---|---|
protected Analyzer |
analyzer
The analyzer.
|
protected AST |
ast
The type operations.
|
static java.lang.String |
ELEMENT_MARKER
The variable marker for bindings in repeated or optional
elements.
|
protected boolean |
hasParseTree
The flag for whether the current module has the
parseTree attribute. |
protected FullProduction |
production
The current (full) production.
|
protected Runtime |
runtime
The runtime.
|
| Constructor and Description |
|---|
Transformer(Runtime runtime,
Analyzer analyzer,
AST ast)
Create a new transformer.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
changesState()
Determine whether the current production changes the global
parser state.
|
protected Production |
current()
Get the current production.
|
protected boolean |
isGeneric()
Determine whether the current production is generic.
|
protected boolean |
isLeftRecursive()
Determine whether the current production is a directly
left-recursive production.
|
protected boolean |
isList()
Determine whether the current production has a list value.
|
protected boolean |
isMemoized()
Determine whether the current production is memoized.
|
protected boolean |
isTextOnly()
Determine whether the current production is text-only.
|
protected boolean |
isToken()
Determine whether the current production is token-level.
|
protected boolean |
isVoid()
Determine whether the current production is void.
|
protected void |
process(FullProduction p)
Process the specified production.
|
protected boolean |
retainOptions()
Determine whether the current production may contain options.
|
protected boolean |
retainRepetitions()
Determine whether the current production may contain repetitions.
|
void |
visit(FullProduction p)
Visit the specified production.
|
void |
visit(Module m)
Visit the specified grammar.
|
dispatch, equals, hashCode, iterate, map, mapInPlace, unableToVisit, visitpublic static final java.lang.String ELEMENT_MARKER
protected final Runtime runtime
protected final Analyzer analyzer
protected final AST ast
protected boolean hasParseTree
parseTree attribute.protected FullProduction production
protected void process(FullProduction p)
p - The production to process.protected boolean isMemoized()
true if the current production is memoized.public boolean changesState()
true if the current production is resetting
or stateful.protected boolean isVoid()
true if the current production is void.protected boolean isTextOnly()
true if the current production is text-only.protected boolean isToken()
true if the current production is token-level.protected boolean isGeneric()
true if the current production is generic.protected boolean isList()
true if the current production has a list value.protected boolean isLeftRecursive()
true if the current production is directly
left-recursive.protected Production current()
protected boolean retainRepetitions()
true if the production may contain
repetitions.protected boolean retainOptions()
true if the production may contain options.public void visit(Module m)
public void visit(FullProduction p)
Copyright © 2014. All Rights Reserved.