laser.regularlanguage.util
Class REtoFSAParser<L extends LabelInterface>

java.lang.Object
  extended by laser.regularlanguage.util.REtoFSAParser<L>
Type Parameters:
L - The type of labels used by the REs and FSAs
Direct Known Subclasses:
StringREtoFSAParser

public class REtoFSAParser<L extends LabelInterface>
extends java.lang.Object

The REtoFSAParser class reads in the given RE from the specified input and converts the RE to the corresponding FSA.

Author:
Heather M. Conboy (laser-software@cs.umass.edu)

Constructor Summary
REtoFSAParser(REFactory<L> reFactory, FSAFactoryInterface<L> fsaFactory, RLFactory<L> rlFactory)
          Creates a new REtoFSAParser that will use the given FSA factory to create the FSA.
 
Method Summary
protected  REReader<L> createREReader(REFactory<L> reFactory)
          Creates the appropriate REReader.
protected  REtoFSAConverter<L> createREtoFSAConverter(FSAFactoryInterface<L> fsaFactory, RLFactory<L> rlFactory)
          Creates the appropriate REtoFSAConverter.
 MutableFSAInterface<L> parse(java.io.File inFile)
          Converts from the RE contained in the input File into the corresponding FSA.
 MutableFSAInterface<L> parse(java.io.Reader in)
          Converts from the RE contained in the input Reader into the corresponding FSA.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

REtoFSAParser

public REtoFSAParser(REFactory<L> reFactory,
                     FSAFactoryInterface<L> fsaFactory,
                     RLFactory<L> rlFactory)
Creates a new REtoFSAParser that will use the given FSA factory to create the FSA.

Parameters:
reFactory - The RE factory to be used to create new REs (non-null)
fsaFactory - The FSA factory to be used to create new FSAs (non-null)
rlFactory - The RL factory to be used to help convert between REs and FSAs (non-null)
Method Detail

createREReader

protected REReader<L> createREReader(REFactory<L> reFactory)
Creates the appropriate REReader.

Parameters:
reFactory - The RE factory to be used to create new REs
Returns:
The appropriate REReader

createREtoFSAConverter

protected REtoFSAConverter<L> createREtoFSAConverter(FSAFactoryInterface<L> fsaFactory,
                                                     RLFactory<L> rlFactory)
Creates the appropriate REtoFSAConverter.

Parameters:
fsaFactory - The FSA factory to be used to create new FSAs
rlFactory - The RL factory to be used to convert from RE to FSA args
Returns:
The appropriate REtoFSAConverter

parse

public MutableFSAInterface<L> parse(java.io.File inFile)
                                                    throws FSAInterfaceException,
                                                           java.io.IOException,
                                                           REException
Converts from the RE contained in the input File into the corresponding FSA.

Parameters:
inFile - The input File that contains the RE to be parsed (non-null)
Returns:
The corresponding FSA
Throws:
FSAInterfaceException - if an FSA related error occurs during the conversion
java.io.IOException - if an I/O error occurs
REException - if an RE related error occurs during the conversion

parse

public MutableFSAInterface<L> parse(java.io.Reader in)
                                                    throws FSAInterfaceException,
                                                           java.io.IOException,
                                                           REException
Converts from the RE contained in the input Reader into the corresponding FSA.

Parameters:
in - The input Reader that contains the RE to be parsed (non-null)
Returns:
The corresponding FSA
Throws:
FSAInterfaceException - if an FSA related error occurs during the conversion
java.io.IOException - if an I/O error occurs
REException - if an RE related error occurs during the conversion