| java.lang.Object xtc.tree.Visitor xtc.parser.VariantSorter
VariantSorter | public class VariantSorter extends Visitor (Code) | | 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.
author: Robert Grimm version: $Revision: 1.31 $ |
Inner Class :public class Registrar extends Visitor | |
Inner Class :public class Typer extends Visitor | |
ast | final protected AST ast(Code) | | The type operations.
|
elements | protected List<Element> elements(Code) | | The list of elements representing the current alternative.
|
hasChanged | protected boolean hasChanged(Code) | | The flag for whether productions have changed in push mode.
|
isGeneric | protected boolean isGeneric(Code) | | The flag for whether the current production is generic. We need
to track this information in an explicit flag, because this
visitor processes choices and sequences that will be lifted into
their own productions.
|
isPushMode | protected boolean isPushMode(Code) | | The flag for whether the current mode is push or pull.
|
malformed | protected Map<Node, Node> malformed(Code) | | The set of AST nodes resulting in an error.
|
productions | protected List<Production> productions(Code) | | The productions to be processed in push mode.
|
types | protected List<Type> types(Code) | | The current types. In push mode, the list contains exactly one
variant type, which is being pushed through productions. In pull
mode, the list contains the types of all alternatives, which may
be variant types, type parameters, and error types and which are
unified in
VariantSorter.visit(FullProduction) .
|
VariantSorter | public VariantSorter(Runtime runtime, Analyzer analyzer, AST ast)(Code) | | Create a new variant sorter.
Parameters: runtime - The runtime. Parameters: analyzer - The analyzer utility. Parameters: ast - The type operations. |
merge | protected Type merge(VariantT v1, VariantT v2, Production p)(Code) | | Merge the two variants. This method merges the second variant
into the first variant, which must be polymorphic. If the second
variant also is polymorphic, it simply adds the second variant's
tuples to the first variant. Otherwise, it tries to create a new
tuple with the second variant's original name and then adds that
tuple to the first variant.
Parameters: v1 - The first variant. Parameters: v2 - The second variant. Parameters: p - The production for error reporting. The first variant or the error type in case of errors. |
pushPull | protected void pushPull(Module m)(Code) | | Push and pull any variant types.
Parameters: m - The grammar. |
recurse | protected void recurse(Element e)(Code) | | Recurse on the specified element. If the element is an
optionally bound nonterminal, this method processes the
corresponding production. If the element is an optionally bound
sequence or choice, this method processes the sequence or choice.
Otherwise, it reports an error condition and returns.
Parameters: e - The element. |
setType | protected void setType(Production p, Type t)(Code) | | Set the specified production's type to the specified type. This
method preserves the original type's generic attribute, unless
the specified type is the error type.
Parameters: p - The production. Parameters: t - The type. |
visit | public void visit(Module m)(Code) | | Visit the specified grammar.
|
visit | public void visit(Sequence s)(Code) | | Visit the specified sequence.
|
|
|