laser.regularlanguage.regularexpression.util
Class ExtendedREToREConverter<L extends LabelInterface>

java.lang.Object
  extended by laser.regularlanguage.regularexpression.AbstractREVisitor<L>
      extended by laser.regularlanguage.regularexpression.util.AbstractREConverter<L>
          extended by laser.regularlanguage.regularexpression.util.ExtendedREToREConverter<L>
Type Parameters:
L - The type of Label associated with the REs.
All Implemented Interfaces:
REVisitor<L>

public class ExtendedREToREConverter<L extends LabelInterface>
extends AbstractREConverter<L>

The ExtendedREToREConverter class converts from an extended RE to a (basic) RE.

NOTE:

An (basic) RE has the following operators choice, concatenation, and kleene star.

An extended RE has the following additional operators (not) class set, dot, exponent, kleene plus, and option.

Author:
Heather M. Conboy (laser-software@cs.umass.edu) FUTURE: For now, the label patterns are not being supported since they may interact badly with the alphabet specification and (not) class set specifications.
See Also:
RE.isExtendedRE()

Field Summary
 
Fields inherited from class laser.regularlanguage.regularexpression.util.AbstractREConverter
reFactory_
 
Fields inherited from class laser.regularlanguage.regularexpression.AbstractREVisitor
result
 
Constructor Summary
ExtendedREToREConverter(REFactory<L> reFactory)
          Creates a new ExtendedREToRE.
 
Method Summary
 void caseChoiceNode(ChoiceNode<L> node, java.lang.Object context)
          Creates a new ChoiceNode with its children converted with respect to the given Alphabet.
 void caseClassSetNode(ClassSetNode<L> node, java.lang.Object context)
          Creates a new ClassSetNode.
 void caseConcatenationNode(ConcatenationNode<L> node, java.lang.Object context)
          Creates a new ConcatenationNode with its children converted with respect to the given Alphabet.
 void caseDotNode(DotNode<L> node, java.lang.Object context)
          Creates a new ClassSetNode that contains all of the Labels in the given Alphabet.
 void caseEmptyNode(EmptyNode<L> node, java.lang.Object context)
          Creates a new EmptyNode.
 void caseEpsilonNode(EpsilonNode<L> node, java.lang.Object context)
          Creates a new EpsilonNode.
 void caseExponentNode(ExponentNode<L> node, java.lang.Object context)
          Creates a new ExponentNode with its child converted with respect to the given Alphabet.
 void caseKleenePlusNode(KleenePlusNode<L> node, java.lang.Object context)
          Creates a new KleenePlusNode with its child converted with respect to the given Alphabet.
 void caseKleeneStarNode(KleeneStarNode<L> node, java.lang.Object context)
          Creates a new KleeneStarNode with its child converted with respect to the given Alphabet.
 void caseLabelNode(LabelNode<L> node, java.lang.Object context)
          Creates a new LabelNode.
 void caseNotClassSetNode(NotClassSetNode<L> node, java.lang.Object context)
          Creates a new ClassSetNode that contains all of the Labels within the Alphabet not mentioned in the NotClassSet.
 void caseOptionNode(OptionNode<L> node, java.lang.Object context)
          Creates a new OptionNode with its child converted with respect to the given Alphabet.
 RE<L> convert(RE<L> theRE)
          Converts from an extended RE to a (basic) RE.
protected  void setUp(RE<L> oldRE)
          Sets up this AbstractREConverter before converting.
protected  void tearDown()
          Tears down this AbstractREFactory after converting.
 
Methods inherited from class laser.regularlanguage.regularexpression.util.AbstractREConverter
convert, getCreateREArgs, getResult, setResult
 
Methods inherited from class laser.regularlanguage.regularexpression.AbstractREVisitor
defaultCase, setResult
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExtendedREToREConverter

public ExtendedREToREConverter(REFactory<L> reFactory)
Creates a new ExtendedREToRE.

Parameters:
reFactory - The REFactory to be used to create new REs (non-null)
Method Detail

convert

public RE<L> convert(RE<L> theRE)
                                     throws REException
Converts from an extended RE to a (basic) RE.

PRECONDITIONS:

Overrides:
convert in class AbstractREConverter<L extends LabelInterface>
Parameters:
theRE - The extended RE to be converted
Returns:
The RE that has been converted
Throws:
REException - if an RE related error occurs

setUp

protected void setUp(RE<L> oldRE)
              throws REException
Sets up this AbstractREConverter before converting.

Overrides:
setUp in class AbstractREConverter<L extends LabelInterface>
Parameters:
oldRE - The old RE to be used as context
Throws:
REException - if the set up cannot be completed successfully

tearDown

protected void tearDown()
Tears down this AbstractREFactory after converting.

Overrides:
tearDown in class AbstractREConverter<L extends LabelInterface>

caseChoiceNode

public void caseChoiceNode(ChoiceNode<L> node,
                           java.lang.Object context)
                    throws REVisitorException
Creates a new ChoiceNode with its children converted with respect to the given Alphabet.

Specified by:
caseChoiceNode in interface REVisitor<L extends LabelInterface>
Overrides:
caseChoiceNode in class AbstractREVisitor<L extends LabelInterface>
Parameters:
node - The ChoiceNode to be converted
context - This is currently not being used
Throws:
REVisitorException - if an error occurs

caseClassSetNode

public void caseClassSetNode(ClassSetNode<L> node,
                             java.lang.Object context)
                      throws REVisitorException
Creates a new ClassSetNode.

NOTE: This is a base case.

Specified by:
caseClassSetNode in interface REVisitor<L extends LabelInterface>
Overrides:
caseClassSetNode in class AbstractREVisitor<L extends LabelInterface>
Parameters:
node - The ClassSetNode to be converted
context - This is currently not being used
Throws:
REVisitorException - if an error occurs

caseConcatenationNode

public void caseConcatenationNode(ConcatenationNode<L> node,
                                  java.lang.Object context)
                           throws REVisitorException
Creates a new ConcatenationNode with its children converted with respect to the given Alphabet.

Specified by:
caseConcatenationNode in interface REVisitor<L extends LabelInterface>
Overrides:
caseConcatenationNode in class AbstractREVisitor<L extends LabelInterface>
Parameters:
node - The ConcatenationNode to be converted
context - This is currently not being used
Throws:
REVisitorException - if an error occurs

caseDotNode

public void caseDotNode(DotNode<L> node,
                        java.lang.Object context)
                 throws REVisitorException
Creates a new ClassSetNode that contains all of the Labels in the given Alphabet.

Specified by:
caseDotNode in interface REVisitor<L extends LabelInterface>
Overrides:
caseDotNode in class AbstractREVisitor<L extends LabelInterface>
Parameters:
node - The DotNode to be converted
context - This is currently not being used
Throws:
REVisitorException - if an error occurs

caseEmptyNode

public void caseEmptyNode(EmptyNode<L> node,
                          java.lang.Object context)
Creates a new EmptyNode.

NOTE: This is a base case.

Specified by:
caseEmptyNode in interface REVisitor<L extends LabelInterface>
Overrides:
caseEmptyNode in class AbstractREVisitor<L extends LabelInterface>
Parameters:
node - The EmptyNode to be converted
context - This is currently not being used
Throws:
REVisitorException - if an error occurs

caseEpsilonNode

public void caseEpsilonNode(EpsilonNode<L> node,
                            java.lang.Object context)
Creates a new EpsilonNode.

NOTE: This is a base case.

Specified by:
caseEpsilonNode in interface REVisitor<L extends LabelInterface>
Overrides:
caseEpsilonNode in class AbstractREVisitor<L extends LabelInterface>
Parameters:
node - The EpsilonNode to be converted
context - This is currently not being used
Throws:
REVisitorException - if an error occurs

caseExponentNode

public void caseExponentNode(ExponentNode<L> node,
                             java.lang.Object context)
                      throws REVisitorException
Creates a new ExponentNode with its child converted with respect to the given Alphabet.

Specified by:
caseExponentNode in interface REVisitor<L extends LabelInterface>
Overrides:
caseExponentNode in class AbstractREVisitor<L extends LabelInterface>
Parameters:
node - The ExponentNode to be converted
context - This is currently not being used
Throws:
REVisitorException - if an error occurs

caseKleenePlusNode

public void caseKleenePlusNode(KleenePlusNode<L> node,
                               java.lang.Object context)
                        throws REVisitorException
Creates a new KleenePlusNode with its child converted with respect to the given Alphabet.

Specified by:
caseKleenePlusNode in interface REVisitor<L extends LabelInterface>
Overrides:
caseKleenePlusNode in class AbstractREVisitor<L extends LabelInterface>
Parameters:
node - The KleenePlusNode to be converted
context - This is currently not being used
Throws:
REVisitorException - if an error occurs

caseKleeneStarNode

public void caseKleeneStarNode(KleeneStarNode<L> node,
                               java.lang.Object context)
                        throws REVisitorException
Creates a new KleeneStarNode with its child converted with respect to the given Alphabet.

Specified by:
caseKleeneStarNode in interface REVisitor<L extends LabelInterface>
Overrides:
caseKleeneStarNode in class AbstractREVisitor<L extends LabelInterface>
Parameters:
node - The KleeneStarNode to be converted
context - This is currently not being used
Throws:
REVisitorException - if an error occurs

caseLabelNode

public void caseLabelNode(LabelNode<L> node,
                          java.lang.Object context)
                   throws REVisitorException
Creates a new LabelNode.

NOTE: This is a base case.

Specified by:
caseLabelNode in interface REVisitor<L extends LabelInterface>
Overrides:
caseLabelNode in class AbstractREVisitor<L extends LabelInterface>
Parameters:
node - The LabelNode to be converted
context - This is currently not being used
Throws:
REVisitorException - if an error occurs

caseNotClassSetNode

public void caseNotClassSetNode(NotClassSetNode<L> node,
                                java.lang.Object context)
                         throws REVisitorException
Creates a new ClassSetNode that contains all of the Labels within the Alphabet not mentioned in the NotClassSet.

Specified by:
caseNotClassSetNode in interface REVisitor<L extends LabelInterface>
Overrides:
caseNotClassSetNode in class AbstractREVisitor<L extends LabelInterface>
Parameters:
node - The NotClassSetNode to be converted
context - This is currently not being used
Throws:
REVisitorException - if an error occurs

caseOptionNode

public void caseOptionNode(OptionNode<L> node,
                           java.lang.Object context)
                    throws REVisitorException
Creates a new OptionNode with its child converted with respect to the given Alphabet.

Specified by:
caseOptionNode in interface REVisitor<L extends LabelInterface>
Overrides:
caseOptionNode in class AbstractREVisitor<L extends LabelInterface>
Parameters:
node - The OptionNode to be converted
context - This is currently not being used
Throws:
REVisitorException - if an error occurs