xtc.parser
Class TextTester

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

public class TextTester
extends Visitor

Visitor to identify text-only productions. A production is text-only if it does not define a semantic value beyond declaring a string value and references only other text-only productions (if any). Notably, a text-only production may not contain parser actions, semantic actions that reference CodeGenerator.VALUE, or bindings to CodeGenerator.VALUE. Note that this visitor only detects such productions but does not add appropriate value elements.

Version:
$Revision: 1.42 $
Author:
Robert Grimm
See Also:
Transformer

Field Summary
protected  Analyzer analyzer
          The analyzer utility.
protected  boolean isTextOnly
          Flag for whether the current production is text-only.
protected  Runtime runtime
          The runtime.
 
Constructor Summary
TextTester(Runtime runtime, Analyzer analyzer)
          Create a new text tester.
 
Method Summary
static void markTextOnly(Production p, boolean verbose)
          Mark the specified production as text-only.
 void visit(Action a)
          Visit the specified action.
 void visit(Binding b)
          Visit the specified binding.
 void visit(CharCase c)
          Visit the specified character case.
 void visit(CharSwitch s)
          Visit the specified character switch.
 void visit(Element e)
          Visit the specified element.
 void visit(Grammar g)
          Visit the specified grammar.
 void visit(Module m)
          Visit the specified grammar.
 void visit(NodeMarker m)
          Visit the specified node marker.
 void visit(NonTerminal nt)
          Visit the specified nonterminal.
 void visit(NullLiteral l)
          Visit the specified null literal.
 void visit(OrderedChoice c)
          Visit the specified ordered choice.
 void visit(ParserAction pa)
          Visit the specified parser action.
 void visit(Predicate p)
          Visit the specified predicate.
 void visit(Production p)
          Visit the specified production.
 void visit(Sequence s)
          Visit the specified sequence.
 void visit(Terminal t)
          Visit the specified terminal.
 void visit(UnaryOperator op)
          Visit the specified unary 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.


isTextOnly

protected boolean isTextOnly
Flag for whether the current production is text-only.

Constructor Detail

TextTester

public TextTester(Runtime runtime,
                  Analyzer analyzer)
Create a new text tester.

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

visit

public void visit(Grammar g)
Visit the specified grammar.


visit

public void visit(Module m)
Visit the specified grammar.


visit

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


visit

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


visit

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


visit

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


visit

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


visit

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


visit

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


visit

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


visit

public void visit(Terminal t)
Visit the specified terminal.


visit

public void visit(UnaryOperator op)
Visit the specified unary operator. This method provides the default implementation for repetitions, options, syntactic predicates, voided elements, and string matches.


visit

public void visit(NullLiteral l)
Visit the specified null literal.


visit

public void visit(NodeMarker m)
Visit the specified node marker.


visit

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


visit

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


visit

public void visit(Element e)
Visit the specified element. This method provides the default implementation for parse tree nodes and value elements.


markTextOnly

public static void markTextOnly(Production p,
                                boolean verbose)
Mark the specified production as text-only.

Parameters:
p - The production.
verbose - The flag for whether to be verbose.


Copyright © 2012. All Rights Reserved.