xtc.parser
Class VariantSorter.Typer

java.lang.Object
  extended by xtc.tree.Visitor
      extended by xtc.parser.VariantSorter.Typer
Enclosing class:
VariantSorter

public class VariantSorter.Typer
extends Visitor

Visitor to determine a generic production's variant type.


Field Summary
protected  boolean create
          The flag for creating a new variant.
protected  java.util.List<Element> elements
          The list of elements.
protected  java.util.Set<java.lang.String> names
          The set of node names.
protected  FullProduction production
          The current production.
protected  Type type
          The type.
 
Constructor Summary
VariantSorter.Typer()
          Create a new typer.
 
Method Summary
 Type type(Production p, boolean create)
          Determine the specified generic production's variant type.
 Type visit(FullProduction p)
          Visit the specified full production.
 void visit(OrderedChoice c)
          Visit the specified ordered 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

create

protected boolean create
The flag for creating a new variant.


production

protected FullProduction production
The current production.


elements

protected java.util.List<Element> elements
The list of elements.


names

protected java.util.Set<java.lang.String> names
The set of node names.


type

protected Type type
The type.

Constructor Detail

VariantSorter.Typer

public VariantSorter.Typer()
Create a new typer.

Method Detail

type

public Type type(Production p,
                 boolean create)
Determine the specified generic production's variant type.

This method may only be invoked on a generic production that does not yet have a variant type. It tries to match the production's generic node names to an existing variant type. If such a type exists, it returns that type. Next, if the production does not create a generic node (even though it is marked as generic), it returns the error type. Next, if create is true, it returns a new variant type. Otherwise, it returns the error type.

Parameters:
p - The generic production.
create - The flag for creating a new variant.
Returns:
The production's variant type or the error type.

visit

public Type visit(FullProduction p)
Visit the specified full production.


visit

public void visit(OrderedChoice c)
Visit the specified ordered choice.


visit

public void visit(Sequence s)
Visit the specified sequence.



Copyright © 2012. All Rights Reserved.