geneseo.cs.compiler
Class FiniteTransducer
java.lang.Object
|
+--geneseo.cs.compiler.FiniteTransducer
- Direct Known Subclasses:
- MinimLTransducer
- public abstract class FiniteTransducer
- extends java.lang.Object
Represents finite transducers in a fairly general way. At its heart, a
transducer is something that accepts characters as input, and based on its
internal state, returns a set of "action flags" that the client will
presumably interpret as directions to do certain things. Sets of action flags are
integers, with individual bits within the integer nominally representing
individual flags. Bit fields, however, can also be used to encode actions
with more than "do" vs "don't do" values. A transducer also updates its
state on each input character. Transducers are table-driven, with tables
indexed by state and character class, and containing next states and action
flags. To be useful, a transducer needs a way of initializing its
table and classifying characters, so this class is an abstract base
class that must be extended to produce transducers for specific
applications.
Method Summary |
abstract int |
classify(int c)
Classify a character. |
int |
getState()
Find out what state a finite transducer is in. |
int |
process(int c)
Process a character. |
void |
reset()
Put a finite transducer into its start state. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
FiniteTransducer
public FiniteTransducer(Transition[][] t)
- Initialize a finite transducer with its transition table.
- Parameters:
t
- The transition table.
reset
public void reset()
- Put a finite transducer into its start state.
getState
public int getState()
- Find out what state a finite transducer is in. This message is most likely to be
useful for debugging a transducer or tracing its actions; most interactions
between clients and transducers should be communicated via action flags.
- Returns:
- The transducer's current state.
process
public int process(int c)
- Process a character.
- Parameters:
c
- The character to process. The character is represented as an
integer so that finite transducers can process data not normally
thought of as characters, e.g., inputs from sensors.- Returns:
- The action flags associated with the transition this character
causes the transducer to take.
classify
public abstract int classify(int c)
- Classify a character. Subclasses must define this method in such a way
that it classifies whatever data the particular subclass's transducers
process into classes appropriate to those transducers.
- Parameters:
c
- The character to classify. This "character" is represented by
an integer so that finite transducers can process data not normally
represented as characters, e.g., sensor inputs.- Returns:
- The character's class.