Abstract Finite State Machine

Take a look on Wikipedia state machine description: http://en.wikipedia.org/wiki/Finite_state_machine

Any type of Transducers (Moore machine or Mealy machine) also may be implemented by using this abstract FSM. process() methods invokes a specified actions which may construct FSM output. Actions may be also used to signal, that we have reached Accept State

category Zend
package Zend_Search_Lucene
subpackage Search
copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
license New BSD License
inherited_from \Zend_Search_Lucene_FSM

 Methods

Object constructor

__construct() 

$states is an array of integers or strings with a list of possible machine states constructor treats fist list element as a sturt state (assignes it to $_current state). It may be reassigned by setState() call. States list may be empty and can be extended later by addState() or addStates() calls.

$inputAphabet is the same as $states, but represents input alphabet it also may be extended later by addInputSymbols() or addInputSymbol() calls.

$rules parameter describes FSM transitions and has a structure: array( array(sourseState, input, targetState[, inputAction]), array(sourseState, input, targetState[, inputAction]), array(sourseState, input, targetState[, inputAction]), ... ) Rules also can be added later by addRules() and addRule() calls.

FSM actions are very flexible and may be defined by addEntryAction(), addExitAction(), addInputAction() and addTransitionAction() calls.

inherited_from \Zend_Search_Lucene_FSM::__construct()

Finite State machine constructor

__construct(array $states = array(), array $inputAphabet = array(), array $rules = array()
Inherited

$states is an array of integers or strings with a list of possible machine states constructor treats fist list element as a sturt state (assignes it to $_current state). It may be reassigned by setState() call. States list may be empty and can be extended later by addState() or addStates() calls.

$inputAphabet is the same as $states, but represents input alphabet it also may be extended later by addInputSymbols() or addInputSymbol() calls.

$rules parameter describes FSM transitions and has a structure: array( array(sourseState, input, targetState[, inputAction]), array(sourseState, input, targetState[, inputAction]), array(sourseState, input, targetState[, inputAction]), ... ) Rules also can be added later by addRules() and addRule() calls.

FSM actions are very flexible and may be defined by addEntryAction(), addExitAction(), addInputAction() and addTransitionAction() calls.

Parameters

$states

array

$inputAphabet

array

$rules

array

Add state entry action.

addEntryAction(integer|string $state, \Zend_Search_Lucene_FSMAction $action) 
Inherited

Several entry actions are allowed. Action execution order is defined by addEntryAction() calls

Parameters

$state

integerstring

$action

\Zend_Search_Lucene_FSMAction

Add state exit action.

addExitAction(integer|string $state, \Zend_Search_Lucene_FSMAction $action) 
Inherited

Several exit actions are allowed. Action execution order is defined by addEntryAction() calls

Parameters

$state

integerstring

$action

\Zend_Search_Lucene_FSMAction

Add input action (defined by {state, input} pair).

addInputAction(integer|string $state, $inputSymbol, \Zend_Search_Lucene_FSMAction $action) 
Inherited

Several input actions are allowed. Action execution order is defined by addInputAction() calls

Parameters

$state

integerstring

$inputSymbol

$action

\Zend_Search_Lucene_FSMAction

Add symbol to the input alphabet

addInputSymbol(integer|string $inputSymbol) 
Inherited

Parameters

$inputSymbol

integerstring

Add symbols to the input alphabet

addInputSymbols(array $inputAphabet) 
Inherited

Parameters

$inputAphabet

array

Add symbol to the input alphabet

addRule(integer|string $sourceState, integer|string $input, integer|string $targetState, \Zend_Search_Lucene_FSMAction|null $inputAction = null
Inherited

Parameters

$sourceState

integerstring

$input

integerstring

$targetState

integerstring

$inputAction

\Zend_Search_Lucene_FSMActionnull

Exceptions

\Zend_Search_Exception

Add transition rules

addRules(array $rules) 
Inherited

array structure: array( array(sourseState, input, targetState[, inputAction]), array(sourseState, input, targetState[, inputAction]), array(sourseState, input, targetState[, inputAction]), ... )

Parameters

$rules

array

Add state to the state machine

addState(integer|string $state) 
Inherited

Parameters

$state

integerstring

Add states to the state machine

addStates(array $states) 
Inherited

Parameters

$states

array

Add transition action (defined by {state, input} pair).

addTransitionAction(integer|string $sourceState, integer|string $targetState, \Zend_Search_Lucene_FSMAction $action) 
Inherited

Several transition actions are allowed. Action execution order is defined by addTransitionAction() calls

Parameters

$sourceState

integerstring

$targetState

integerstring

$action

\Zend_Search_Lucene_FSMAction

default (omitted) + NOT operator processing

emptyNotOperatorAction() 

default (omitted) operator processing

emptyOperatorAction() 

Finish an expression and return result

finishExpression() : array

Result is a set of boolean query conjunctions

Each conjunction is an array of conjunction elements Each conjunction element is presented with two-elements array: array(, )

So, it has a structure: array( array( array(, ), // first literal of first conjuction array(, ), // second literal of first conjuction ... array(, ) ), // end of first conjuction array( array(, ), // first literal of second conjuction array(, ), // second literal of second conjuction ... array(, ) ), // end of second conjuction ... ) // end of structure

Exceptions

\Zend_Search_Lucene_Exception

Returns

array

Get FSM state.

getState() : integer | string
Inherited

Returns

integerstring$state|null

Literal processing

literalAction() 

NOT operator processing

notOperatorAction() 

OR operator processing Close current conjunction

orOperatorAction() 

Process an input

process(mixed $input) 
Inherited

Parameters

$input

mixed

Exceptions

\Zend_Search_Exception

Process expression literal.

processLiteral($literal) 

Parameters

$literal

Process next operator.

processOperator(integer $operator) 

Operators are defined by class constants: IN_AND_OPERATOR, IN_OR_OPERATOR and IN_NOT_OPERATOR

Parameters

$operator

integer

reset()

reset() 
Inherited

Set FSM state.

setState(integer|string $state) 
Inherited

No any action is invoked

Parameters

$state

integerstring

Exceptions

\Zend_Search_Exception

 Properties

 

Set of boolean query conjunctions

$_conjunctions : array

Default

array()

Each conjunction is an array of conjunction elements Each conjunction element is presented with two-elements array: array(, )

So, it has a structure: array( array( array(, ), // first literal of first conjuction array(, ), // second literal of first conjuction ... array(, ) ), // end of first conjuction array( array(, ), // first literal of second conjuction array(, ), // second literal of second conjuction ... array(, ) ), // end of second conjuction ... ) // end of structure

 

Current conjuction

$_currentConjunction : array

Default

array()
 

Current state

$_currentState : integer | string

Default

null
 

List of entry actions Each action executes when entering the state

$_entryActions : array

Default

array()

[state] => action

 

List of exit actions Each action executes when exiting the state

$_exitActions : array

Default

array()

[state] => action

 

List of input actions Each action executes when entering the state

$_inputActions : array

Default

array()

[state][input] => action

 

Input alphabet

$_inputAphabet : array

Default

array()
 

Current literal

$_literal : mixed

Default

 

NOT operator signal

$_negativeLiteral : boolean

Default

false
 

State transition table

$_rules : array

Default

array()

[sourceState][input] => targetState

 

Machine States alphabet

$_states : array

Default

array()
 

List of input actions Each action executes when entering the state

$_transitionActions : array

Default

array()

[state1][state2] => action

 Constants

 

IN_AND_OPERATOR

IN_AND_OPERATOR = 2 
 

Input symbols

IN_LITERAL = 0 
 

IN_NOT_OPERATOR

IN_NOT_OPERATOR = 1 
 

IN_OR_OPERATOR

IN_OR_OPERATOR = 3 
 

ST_AND_OPERATOR

ST_AND_OPERATOR = 3 
 

ST_LITERAL

ST_LITERAL = 1 
 

ST_NOT_OPERATOR

ST_NOT_OPERATOR = 2 
 

ST_OR_OPERATOR

ST_OR_OPERATOR = 4 
 

State Machine states

ST_START = 0