dk.brics.servletvalidator
Class SingleProductionNonTerminalRemovalVisitor

java.lang.Object
  extended by dk.brics.servletvalidator.grammar.AbstractGrammarEntityVisitor
      extended by dk.brics.servletvalidator.SingleProductionNonTerminalRemovalVisitor
All Implemented Interfaces:
GrammarEntityVisitor

public class SingleProductionNonTerminalRemovalVisitor
extends AbstractGrammarEntityVisitor

Removes all non terminals that have only 1 production that is only used in 1 place by inlining its production everywhere where it is used. Especially when the grammar is first created this helps readability a lot and improves analysis performance.


Field Summary
 
Fields inherited from class dk.brics.servletvalidator.grammar.AbstractGrammarEntityVisitor
marked
 
Constructor Summary
SingleProductionNonTerminalRemovalVisitor()
           
 
Method Summary
 void apply(Grammar g)
           
 void out(NonTerminal nonTerminal)
           
 boolean shouldPrettyPrint()
          If this method returns true the grammar will be printed to debug after the visitor has run
 
Methods inherited from class dk.brics.servletvalidator.grammar.AbstractGrammarEntityVisitor
apply, apply, apply, getPath, in, in, in, isMarked, mark, out, out, print
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SingleProductionNonTerminalRemovalVisitor

public SingleProductionNonTerminalRemovalVisitor()
Method Detail

apply

public void apply(Grammar g)
Specified by:
apply in interface GrammarEntityVisitor
Overrides:
apply in class AbstractGrammarEntityVisitor

out

public void out(NonTerminal nonTerminal)
Specified by:
out in interface GrammarEntityVisitor
Overrides:
out in class AbstractGrammarEntityVisitor

shouldPrettyPrint

public boolean shouldPrettyPrint()
Description copied from class: AbstractGrammarEntityVisitor
If this method returns true the grammar will be printed to debug after the visitor has run

Specified by:
shouldPrettyPrint in interface GrammarEntityVisitor
Overrides:
shouldPrettyPrint in class AbstractGrammarEntityVisitor


Copyright © 2008 Mathias Schwarz.