xtc.parser
Class ElementVoider

java.lang.Object
  extended by xtc.tree.Visitor
      extended by xtc.parser.ElementVoider

public class ElementVoider
extends Visitor

Visitor to void ordered choices, repetitions, and options. This visitor voids ordered choices, repetitions, and options, if all expressions appearing in such an expression are either void nonterminals or explicitly voided. It requires that a grammar has been resolved into a single module, that text-only productions have been marked as such, and that all expressions have been simplified.

Version:
$Revision: 1.15 $
Author:
Robert Grimm

Field Summary
protected  Analyzer analyzer
          The analyzer utility.
protected  boolean hasValue
          The flag for potentially having a value.
protected  boolean isLastElement
          The flag for the last element.
protected  boolean isTopLevel
          The flag for the top-level element.
protected  Runtime runtime
          The runtime.
protected  boolean suppressVoided
          The flag for suppressing the insertion of voided elements.
 
Constructor Summary
ElementVoider(Runtime runtime, Analyzer analyzer)
          Create a new element voider.
 
Method Summary
 Action visit(Action a)
          Visit the specified action.
 Binding visit(Binding b)
          Visit the specified binding.
 Element visit(Element e)
          Visit the specified element.
 void visit(FullProduction p)
          Visit the specified full production.
 void visit(Module m)
          Visit the specified self-contained module.
 NonTerminal visit(NonTerminal nt)
          Visit the specified nonterminal.
 Element visit(OrderedChoice c)
          Visit the specified ordered choice.
 ParserAction visit(ParserAction pa)
          Visit the specified parser action.
 Element visit(Predicate p)
          Visit the specified predicate.
 Element visit(Quantification q)
          Visit the specified quantification.
 Element visit(Sequence s)
          Visit the specified sequence.
 StringMatch visit(StringMatch m)
          Visit the specified string match.
 VoidedElement visit(VoidedElement v)
          Visit the specified voided element.
protected  Element wrap(Element el)
          Wrap the specified element in a voiding operator.
 
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
The flag for the top-level element.


isLastElement

protected boolean isLastElement
The flag for the last element.


suppressVoided

protected boolean suppressVoided
The flag for suppressing the insertion of voided elements.


hasValue

protected boolean hasValue
The flag for potentially having a value.

Constructor Detail

ElementVoider

public ElementVoider(Runtime runtime,
                     Analyzer analyzer)
Create a new element voider.

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

wrap

protected Element wrap(Element el)
Wrap the specified element in a voiding operator.

Parameters:
el - The element to wrap.
Returns:
The wrapped element.

visit

public void visit(Module m)
Visit the specified self-contained module.


visit

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


visit

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


visit

public Element visit(Quantification q)
Visit the specified quantification.


visit

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


visit

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


visit

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


visit

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


visit

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


visit

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


visit

public Action visit(Action a)
Visit the specified action.


visit

public NonTerminal visit(NonTerminal nt)
Visit the specified nonterminal.


visit

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



Copyright © 2012. All Rights Reserved.