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

Finite State machine 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 lexeme

addLexeme() 

Extend lexeme by one char

addLexemeChar() 

Add lexeme modifier

addLexemeModifier() 

Add number lexeme

addNumberLexeme() 

Add query syntax lexeme

addQuerySyntaxLexeme() 

Exceptions

\Zend_Search_Lucene_Search_QueryParserException

Add quoted lexeme

addQuotedLexeme() 

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

Get FSM state.

getState() : integer | string
Inherited

Returns

integerstring$state|null

lexModifierErrException()

lexModifierErrException() 

Process an input

process(mixed $input) 
Inherited

Parameters

$input

mixed

Exceptions

\Zend_Search_Exception

quoteWithinLexemeErrException()

quoteWithinLexemeErrException() 

reset()

reset() 
Inherited

Set FSM state.

setState(integer|string $state) 
Inherited

No any action is invoked

Parameters

$state

integerstring

Exceptions

\Zend_Search_Exception

This method is used to tokenize query string into lexemes

tokenize(string $inputString, string $encoding) : array

Parameters

$inputString

string

$encoding

string

Exceptions

\Zend_Search_Lucene_Search_QueryParserException

Returns

array

wrongNumberErrException()

wrongNumberErrException() 

Position message

_positionMsg() : string

Returns

string

Translate input char to an input symbol of state machine

_translateInput(string $char) : integer

Parameters

$char

string

Returns

integer

 Properties

 

Recognized part of current lexeme

$_currentLexeme : string

Default

 

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()
 

List of recognized lexemes

$_lexemes : array

Default

 

Query string (array of single- or non single-byte characters)

$_queryString : array

Default

 

Current position within a query string Used to create appropriate error messages

$_queryStringPosition : integer

Default

 

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_ASCII_DIGIT

IN_ASCII_DIGIT = 6 
 

IN_CHAR

IN_CHAR = 7 
 

IN_DECIMAL_POINT

IN_DECIMAL_POINT = 5 
 

IN_ESCAPE_CHAR

IN_ESCAPE_CHAR = 3 
 

IN_LEXEME_MODIFIER

IN_LEXEME_MODIFIER = 2 
 

IN_MUTABLE_CHAR

IN_MUTABLE_CHAR = 8 
 

IN_QUOTE

IN_QUOTE = 4 
 

IN_SYNT_CHAR

IN_SYNT_CHAR = 1 
 

Input symbols

IN_WHITE_SPACE = 0 
 

QUERY_ASCIIDIGITS_CHARS

QUERY_ASCIIDIGITS_CHARS = '0123456789' 
 

QUERY_DOUBLECHARLEXEME_CHARS

QUERY_DOUBLECHARLEXEME_CHARS = '|&' 
 

QUERY_LEXEMEMODIFIER_CHARS

QUERY_LEXEMEMODIFIER_CHARS = '~^' 
 

QUERY_MUTABLE_CHARS

QUERY_MUTABLE_CHARS = '+-' 
 

QUERY_SYNT_CHARS

QUERY_SYNT_CHARS = ':()[]{}!|&' 
 

QUERY_WHITE_SPACE_CHARS

QUERY_WHITE_SPACE_CHARS = " \n\r\t" 
 

ST_ERROR

ST_ERROR = 9 
 

ST_ESCAPED_CHAR

ST_ESCAPED_CHAR = 4 
 

ST_ESCAPED_QCHAR

ST_ESCAPED_QCHAR = 5 
 

ST_LEXEME

ST_LEXEME = 2 
 

ST_LEXEME_MODIFIER

ST_LEXEME_MODIFIER = 6 
 

ST_MANTISSA

ST_MANTISSA = 8 
 

ST_NUMBER

ST_NUMBER = 7 
 

ST_QUOTED_LEXEME

ST_QUOTED_LEXEME = 3 
 

ST_SYNT_LEXEME

ST_SYNT_LEXEME = 1 
 

State Machine states

ST_WHITE_SPACE = 0