xtc.parser
Class Transformer.Lifter

java.lang.Object
  extended by xtc.tree.Visitor
      extended by xtc.parser.GrammarVisitor
          extended by xtc.parser.Transformer.Lifter
Enclosing class:
Transformer

public class Transformer.Lifter
extends GrammarVisitor

Visitor to lift nested choices, repetitions, and options. This visitor also ensures that repeated, optional, and predicated elements are sequences.


Field Summary
 
Fields inherited from class xtc.parser.GrammarVisitor
analyzer, isBound, isLastElement, isPredicate, isRepeatedOnce, isTopLevel, isVoided, needsSequence, runtime, transformInPlace
 
Constructor Summary
Transformer.Lifter()
          Create a new lifter.
 
Method Summary
protected  Binding bind(Element e)
          Bind the specified element.
protected  void lift(Type type, NonTerminal nt, OrderedChoice c)
          Create a new production with the specified type, nonterminal, and ordered choice.
protected  Sequence process(Element e, boolean bound)
          Process the specified repeated, optional, or predicated element.
 Element visit(Option o)
          Visit the specified option.
 Element visit(OrderedChoice c)
          Visit the specified ordered choice.
 Element visit(Predicate p)
          Visit the specified predicate.
 Element visit(Repetition r)
          Visit the specified repetition.
 
Methods inherited from class xtc.parser.GrammarVisitor
visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit
 
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
 

Constructor Detail

Transformer.Lifter

public Transformer.Lifter()
Create a new lifter.

Method Detail

bind

protected Binding bind(Element e)
Bind the specified element.

Parameters:
e - The element.
Returns:
The bound element.

process

protected Sequence process(Element e,
                           boolean bound)
Process the specified repeated, optional, or predicated element. This method processes the specified element, lifting it and adding a binding for its value, either only if necessary. The result is a sequence to fulfill the corresponding code generation requirement.

Parameters:
e - The element.
bound - The flag for whether the element's value is bound.
Returns:
The resulting sequence.

lift

protected void lift(Type type,
                    NonTerminal nt,
                    OrderedChoice c)
Create a new production with the specified type, nonterminal, and ordered choice. This method creates the production, using the current production's attributes and text-only and token-level marks, recursively processes the productions, and adds it to the grammar.

Parameters:
type - The type.
nt - The nonterminal.
c - The ordered choice.

visit

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

Overrides:
visit in class GrammarVisitor

visit

public Element visit(Repetition r)
Visit the specified repetition.

Overrides:
visit in class GrammarVisitor

visit

public Element visit(Option o)
Visit the specified option.

Overrides:
visit in class GrammarVisitor

visit

public Element visit(Predicate p)
Visit the specified predicate.

Overrides:
visit in class GrammarVisitor


Copyright © 2012. All Rights Reserved.