xtc.parser
Class GrammarVisitor

java.lang.Object
  extended by xtc.tree.Visitor
      extended by xtc.parser.GrammarVisitor
Direct Known Subclasses:
ChoiceExpander, DeadProductionEliminator, DuplicateProductionFolder, GenericVoider, Inliner, PrefixFolder, ProductionVoider, ProductionVoider.Tester, ReferenceCounter, Renamer, RootFinder, Simplifier, TerminalOptimizer, Tokenizer, Transformer.Lifter, TransientMarker

public abstract class GrammarVisitor
extends Visitor

The parent class of all grammar module visitors. This class provides a skeleton visitor for processing grammars and self-contained modules, while maintaining a set of useful flags.

Version:
$Revision: 1.24 $
Author:
Robert Grimm

Field Summary
protected  Analyzer analyzer
          The analyzer utility.
protected  boolean isBound
          Flag for whether the current element is bound.
protected  boolean isLastElement
          Flag for whether the current element is the last element of a sequence.
protected  boolean isPredicate
          Flag for whether the current element is in a predicate.
protected  boolean isRepeatedOnce
          Flag for whether the current element is repeated at least once.
protected  boolean isTopLevel
          Flag for whether the current element is the top-level element of a production.
protected  boolean isVoided
          Flag for whether the current element is voided.
protected  boolean needsSequence
          Flag for whether the parent element requires that the directly embedded elements are sequences for code generation.
protected  Runtime runtime
          The runtime.
protected  boolean transformInPlace
          Flag for whether to transform ordered choices, repetition, and options in place, instead of creating a new production.
 
Constructor Summary
GrammarVisitor(Runtime runtime, Analyzer analyzer)
          Create a new grammar visitor.
 
Method Summary
 Element visit(Binding b)
          Visit the specified binding.
 CharCase visit(CharCase c)
          Visit the specified character case.
 Element visit(CharSwitch s)
          Visit the specified character switch.
 Element visit(Element e)
          Visit the specified element.
 java.lang.Object visit(Grammar g)
          Visit the specified grammar.
 java.lang.Object visit(Module m)
          Visit the specified self-contained module.
 Element visit(Option o)
          Visit the specified option.
 Element visit(OrderedChoice c)
          Visit the specified ordered choice.
 Element visit(ParserAction pa)
          Visit the specified parser action.
 Element visit(Predicate p)
          Visit the specified predicate.
 Production visit(Production p)
          Visit the specified production.
 Element visit(Repetition r)
          Visit the specified repetition.
 Element visit(SemanticPredicate p)
          Visit the specified semantic predicate.
 Element visit(Sequence s)
          Visit the specified sequence.
 Element visit(StringMatch m)
          Visit the specified string match.
 Element visit(VoidedElement v)
          Visit the specified voided element.
 
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

runtime

protected final Runtime runtime
The runtime.


analyzer

protected final Analyzer analyzer
The analyzer utility.


isTopLevel

protected boolean isTopLevel
Flag for whether the current element is the top-level element of a production.


isVoided

protected boolean isVoided
Flag for whether the current element is voided.


isBound

protected boolean isBound
Flag for whether the current element is bound.


isLastElement

protected boolean isLastElement
Flag for whether the current element is the last element of a sequence.


isPredicate

protected boolean isPredicate
Flag for whether the current element is in a predicate.


isRepeatedOnce

protected boolean isRepeatedOnce
Flag for whether the current element is repeated at least once.


needsSequence

protected boolean needsSequence
Flag for whether the parent element requires that the directly embedded elements are sequences for code generation. It is used by the Simplifier to avoid stripping sequences that need to be restored later on again.


transformInPlace

protected boolean transformInPlace
Flag for whether to transform ordered choices, repetition, and options in place, instead of creating a new production. This flag is used by the lifter visitor.

Constructor Detail

GrammarVisitor

public GrammarVisitor(Runtime runtime,
                      Analyzer analyzer)
Create a new grammar visitor.

Parameters:
runtime - The runtime.
analyzer - The analyzer utility.
Method Detail

visit

public java.lang.Object visit(Grammar g)
Visit the specified grammar.


visit

public java.lang.Object visit(Module m)
Visit the specified self-contained module.


visit

public Production visit(Production p)
Visit the specified production.


visit

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


visit

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


visit

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


visit

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


visit

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


visit

public Element visit(SemanticPredicate p)
Visit the specified semantic predicate.


visit

public Element visit(VoidedElement v)
Visit the specified voided element.


visit

public Element visit(Binding b)
Visit the specified binding.


visit

public Element visit(StringMatch m)
Visit the specified string match.


visit

public CharCase visit(CharCase c)
Visit the specified character case.


visit

public Element visit(CharSwitch s)
Visit the specified character switch.


visit

public Element visit(ParserAction pa)
Visit the specified parser action.


visit

public Element visit(Element e)
Visit the specified element. This method provides the default implementation for nonterminals, terminals (besides character switches), node markers, actions, parse tree nodes, null literals, and value elements.



Copyright © 2012. All Rights Reserved.