|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectgate.fsm.FSM
public class FSM
This class implements a standard Finite State Machine. It is used for both deterministic and non-deterministic machines.
| Field Summary | |
|---|---|
private Collection |
allStates
The set of states for this FSM |
(package private) int |
bpeId
|
protected State |
currentState
Two members used by forEachState(). |
protected Transition |
currentTransition
|
private static boolean |
DEBUG
Debug flag |
private Set<AbstractSet> |
dStates
|
protected State |
finalState
The final state of this FSM (usually only valid during construction). |
private State |
initialState
The initial state of this FSM. |
private Map<AbstractSet,State> |
newStates
|
HashMap<String,String> |
ruleHash
|
private ArrayList<RuleTime> |
ruleTimes
|
| Fields inherited from interface gate.jape.JapeConstants |
|---|
ALL_STYLE, APPELT_STYLE, BRILL_STYLE, DEFAULT_PRIORITY, FIRST_STYLE, INDENT_PADDING, KLEENE_PLUS, KLEENE_QUERY, KLEENE_STAR, MULTI_SPAN_BINDING, NO_BINDING, NO_KLEENE_OP, ONCE_STYLE, SINGLE_SPAN_BINDING |
| Constructor Summary | |
|---|---|
protected |
FSM()
The constructor that all the other constructors should call. |
protected |
FSM(ComplexPatternElement cpe)
Builds a FSM starting from a ComplexPatternElement. |
|
FSM(Rule rule)
Builds a FSM starting from a rule. |
|
FSM(SinglePhaseTransducer spt)
Builds a standalone FSM starting from a single phase transducer. |
| Method Summary | |
|---|---|
protected void |
addRules(PrioritisedRuleList rules)
Do the work involved in creating an FSM from a PrioritisedRuleList. |
String |
asGraphViz(boolean includeConstraints)
Returns a representation of this FSM in the GraphViz graph-visualization language. |
private State |
convertComplexPE(State startState,
ComplexPatternElement cpe,
LinkedList<String> labels)
Receives a state to start from and a complex pattern element. |
private String |
currentBasicBinding(BasicPatternElement bpe)
|
private String |
currentBinding(ComplexPatternElement cpe,
int indent)
|
private String |
currentLHSBinding(LeftHandSide lhs)
|
private void |
decorateStates()
|
void |
eliminateVoidTransitions()
Converts this FSM from a non-deterministic to a deterministic one by eliminating all the unrestricted transitions. |
(package private) String |
encodeForGraphViz(Map<String,String> m)
Given a Map, encodes its keys and values as strings suitable for use as a GraphViz label. |
protected void |
forEachState(Runnable r)
Iterates over all the states in this FSM, setting currentState and currentTransition, then calling the given Runnable callback. |
private State |
generateStates(State startState,
ComplexPatternElement cpe,
LinkedList<String> labels)
Receives a state to start from and a complex pattern element. |
Map<State,SimpleArraySet<Transition>> |
getAllStates()
|
String |
getGML()
Returns a GML (Graph Modelling Language) representation of the transition graph of this FSM. |
State |
getInitialState()
Gets the initial state of this FSM |
ArrayList<RuleTime> |
getRuleTimes()
|
private AbstractSet<State> |
lambdaClosure(AbstractSet<State> s)
|
protected void |
setRule(Rule rule)
Do the work involved in creating an FSM from a Rule. |
protected FSM |
spawn(ComplexPatternElement currentPattern)
A factory method for new FSMs like this one, given a ComplexPatternElement object. |
protected FSM |
spawn(Rule r)
A factory method for new FSMs like this one, given a Rule object. |
String |
toString()
Returns a textual description of this FSM. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
private ArrayList<RuleTime> ruleTimes
private static final boolean DEBUG
protected State currentState
protected Transition currentTransition
private State initialState
protected State finalState
private transient Collection allStates
private transient Map<AbstractSet,State> newStates
private transient Set<AbstractSet> dStates
int bpeId
public HashMap<String,String> ruleHash
| Constructor Detail |
|---|
protected FSM()
public FSM(SinglePhaseTransducer spt)
spt - the single phase transducer to be used for building this FSM.public FSM(Rule rule)
rule - the rule to be used for the building process.protected FSM(ComplexPatternElement cpe)
cpe - the ComplexPatternElement to be used for the building process.| Method Detail |
|---|
public ArrayList<RuleTime> getRuleTimes()
private void decorateStates()
protected void addRules(PrioritisedRuleList rules)
protected void setRule(Rule rule)
protected FSM spawn(Rule r)
protected FSM spawn(ComplexPatternElement currentPattern)
public State getInitialState()
private State convertComplexPE(State startState,
ComplexPatternElement cpe,
LinkedList<String> labels)
startState - the state to start fromcpe - the pattern to be recognizedlabels - the bindings name for all the annotation accepted along
the way. This is actually a list of Strings. It is necessary to use
a list because of the recursive definition of ComplexPatternElement.
private State generateStates(State startState,
ComplexPatternElement cpe,
LinkedList<String> labels)
startState - the state to start fromcpe - the pattern to be recognizedlabels - the bindings name for all the annotation accepted along
the way. This is actually a list of Strings. It is necessary to use
a list because of the recursive definition of ComplexPatternElement.
public void eliminateVoidTransitions()
private AbstractSet<State> lambdaClosure(AbstractSet<State> s)
protected void forEachState(Runnable r)
public Map<State,SimpleArraySet<Transition>> getAllStates()
public String asGraphViz(boolean includeConstraints)
includeConstraints - whether to include a stringified representation of each
transition object as part of its label. The default is false.
String encodeForGraphViz(Map<String,String> m)
public String getGML()
public String toString()
toString in class Object
private String currentBinding(ComplexPatternElement cpe,
int indent)
private String currentBasicBinding(BasicPatternElement bpe)
private String currentLHSBinding(LeftHandSide lhs)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||