|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectxtc.tree.Visitor
xtc.parser.VariantSorter
public class VariantSorter
Visitor to infer a grammar's variants.
This visitor assumes that the entire grammar is contained in a single module. It also assumes that the grammar's real root has been annotated and that directly left-recursive productions have not been transformed into equivalent right-iterations.
| Nested Class Summary | |
|---|---|
class |
VariantSorter.Registrar
Visitor to register all generic node names with the type operations class. |
class |
VariantSorter.Typer
Visitor to determine a generic production's variant type. |
| Field Summary | |
|---|---|
protected Analyzer |
analyzer
The analyzer. |
protected AST |
ast
The type operations. |
protected java.util.List<Element> |
elements
The list of elements representing the current alternative. |
protected VariantSorter.Typer |
gtyper
The generic production typer. |
protected boolean |
hasChanged
The flag for whether productions have changed in push mode. |
protected boolean |
isGeneric
The flag for whether the current production is generic. |
protected boolean |
isPushMode
The flag for whether the current mode is push or pull. |
protected java.util.Map<Node,Node> |
malformed
The set of AST nodes resulting in an error. |
protected FullProduction |
production
The current production. |
protected java.util.List<Production> |
productions
The productions to be processed in push mode. |
protected Runtime |
runtime
The runtime. |
protected java.util.List<Type> |
types
The current types. |
| Constructor Summary | |
|---|---|
VariantSorter(Runtime runtime,
Analyzer analyzer,
AST ast)
Create a new variant sorter. |
|
| Method Summary | |
|---|---|
protected Type |
merge(VariantT v1,
VariantT v2,
Production p)
Merge the two variants. |
protected void |
pushPull(Module m)
Push and pull any variant types. |
protected void |
recurse(Element e)
Recurse on the specified element. |
protected void |
setType(Production p,
Type t)
Set the specified production's type to the specified type. |
void |
visit(FullProduction p)
Visit the specified production. |
void |
visit(Module m)
Visit the specified grammar. |
void |
visit(OrderedChoice c)
Visit the specified choice. |
void |
visit(Sequence s)
Visit the specified sequence. |
| 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 |
|---|
protected final Runtime runtime
protected final Analyzer analyzer
protected final AST ast
protected final VariantSorter.Typer gtyper
protected java.util.Map<Node,Node> malformed
protected boolean isPushMode
protected java.util.List<Production> productions
protected boolean hasChanged
protected java.util.List<Type> types
visit(FullProduction).
protected FullProduction production
protected boolean isGeneric
protected java.util.List<Element> elements
| Constructor Detail |
|---|
public VariantSorter(Runtime runtime,
Analyzer analyzer,
AST ast)
runtime - The runtime.analyzer - The analyzer utility.ast - The type operations.| Method Detail |
|---|
protected Type merge(VariantT v1,
VariantT v2,
Production p)
v1 - The first variant.v2 - The second variant.p - The production for error reporting.
protected void setType(Production p,
Type t)
p - The production.t - The type.protected void pushPull(Module m)
m - The grammar.public void visit(Module m)
public void visit(FullProduction p)
public void visit(OrderedChoice c)
public void visit(Sequence s)
protected void recurse(Element e)
e - The element.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||