|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectxtc.tree.Visitor
xtc.parser.Transformer
public class Transformer
Visitor to transform productions. This visitor lifts repetitions,
options, and nested choices into their own productions, desugars
reptitions and options, and adds the appropriate semantic values to
expressions that require them. It also ensures that repeated,
optional, and predicated elements are sequences, thus fulfilling
the requirements for 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.
| Nested Class Summary | |
|---|---|
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. |
| Field Summary | |
|---|---|
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 Summary | |
|---|---|
Transformer(Runtime runtime,
Analyzer analyzer,
AST ast)
Create a new transformer. |
|
| Method Summary | |
|---|---|
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. |
| Methods inherited from class xtc.tree.Visitor |
|---|
dispatch, equals, hashCode, iterate, map, mapInPlace, unableToVisit, visit |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public 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
| Constructor Detail |
|---|
public Transformer(Runtime runtime,
Analyzer analyzer,
AST ast)
runtime - The runtime.analyzer - The analyzer utility.ast - The type operations.| Method Detail |
|---|
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)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||