dk.brics.string.grammar
Class Grammar

java.lang.Object
  extended by dk.brics.string.grammar.Grammar

public class Grammar
extends Object

Context-free grammar with regular operations.

Author:
Anders Møller <amoeller@cs.au.dk>

Constructor Summary
Grammar()
          Constructs new empty grammar.
 
Method Summary
 void addAutomatonProduction(Nonterminal a, Automaton reg)
          Adds new automaton production [a -> reg].
 void addBinaryProduction(Nonterminal a, BinaryOperation op, Nonterminal b, Nonterminal c)
          Adds new binary operation production [a -> op2(b,c)].
 void addEpsilonProduction(Nonterminal a)
          Adds new epsilon production [a -> ""].
 Nonterminal addNonterminal()
          Adds new nonterminal.
 void addPairProduction(Nonterminal a, Nonterminal b, Nonterminal c)
          Adds new pair production [a -> b c].
 void addUnaryProduction(Nonterminal a, UnaryOperation op, Nonterminal b)
          Adds new unary operation production [a -> op1(b)].
 void addUnitProduction(Nonterminal a, Nonterminal b)
          Adds new unit production [a -> b].
 void approximateNonLinear(Collection<Nonterminal> hotspots)
          See RegularApproximation.
 void approximateOperationCycles()
          Breaks operation cycles using AssertionCycleApproximation and then approximates the remaining operation cycles with OperationCycleApproximation.
 String getCharsets()
          See OperationCycleApproximation.getCharsets().
 StronglyConnectedComponents<Nonterminal,Component> getComponents(boolean find_recursion_kinds)
          Finds the strongly connected components and their recursion kinds.
 List<Nonterminal> getNonterminals()
          Returns the (unmodifiable) list of nonterminals in this grammar.
 int getNumberOfComponents()
          Returns number of components.
 int getNumberOfNonLinearComponents()
          Returns number of non-linear components.
 int getNumberOfNonterminals()
          Returns number of nonterminals in this grammar.
 int getNumberOfOperationCycles()
          See OperationCycleApproximation.countCycles().
 int getNumberOfProductions()
          Returns number of productions in this grammar.
 String toString()
          Returns string representation of this grammar.
 void visitProductions(ProductionVisitor v)
          Visits all productions with the given visitor.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Grammar

public Grammar()
Constructs new empty grammar.

Method Detail

addAutomatonProduction

public void addAutomatonProduction(Nonterminal a,
                                   Automaton reg)
Adds new automaton production [a -> reg]. Ignored if reg is empty.


addBinaryProduction

public void addBinaryProduction(Nonterminal a,
                                BinaryOperation op,
                                Nonterminal b,
                                Nonterminal c)
Adds new binary operation production [a -> op2(b,c)].


addEpsilonProduction

public void addEpsilonProduction(Nonterminal a)
Adds new epsilon production [a -> ""].


addNonterminal

public Nonterminal addNonterminal()
Adds new nonterminal.


addPairProduction

public void addPairProduction(Nonterminal a,
                              Nonterminal b,
                              Nonterminal c)
Adds new pair production [a -> b c].


addUnaryProduction

public void addUnaryProduction(Nonterminal a,
                               UnaryOperation op,
                               Nonterminal b)
Adds new unary operation production [a -> op1(b)].


addUnitProduction

public void addUnitProduction(Nonterminal a,
                              Nonterminal b)
Adds new unit production [a -> b]. Ignored if a==b.


approximateNonLinear

public void approximateNonLinear(Collection<Nonterminal> hotspots)
See RegularApproximation.


approximateOperationCycles

public void approximateOperationCycles()
Breaks operation cycles using AssertionCycleApproximation and then approximates the remaining operation cycles with OperationCycleApproximation.


getCharsets

public String getCharsets()
See OperationCycleApproximation.getCharsets().


getComponents

public StronglyConnectedComponents<Nonterminal,Component> getComponents(boolean find_recursion_kinds)
Finds the strongly connected components and their recursion kinds.


getNonterminals

public List<Nonterminal> getNonterminals()
Returns the (unmodifiable) list of nonterminals in this grammar.


getNumberOfComponents

public int getNumberOfComponents()
Returns number of components.


getNumberOfNonLinearComponents

public int getNumberOfNonLinearComponents()
Returns number of non-linear components.


getNumberOfNonterminals

public int getNumberOfNonterminals()
Returns number of nonterminals in this grammar.


getNumberOfOperationCycles

public int getNumberOfOperationCycles()
See OperationCycleApproximation.countCycles().


getNumberOfProductions

public int getNumberOfProductions()
Returns number of productions in this grammar.


toString

public String toString()
Returns string representation of this grammar.

Overrides:
toString in class Object

visitProductions

public void visitProductions(ProductionVisitor v)
Visits all productions with the given visitor.



Copyright © 2003-2009 Anders Møller, Aske Simon Christensen, Asger Feldthaus.