API Documentation

Zend/Search/Lucene/FSM.php

Show: inherited
Table of Contents

Zend Framework

LICENSE

This source file is subject to the new BSD license that is bundled with this package in the file LICENSE.txt. It is also available through the world-wide-web at this URL: http://framework.zend.com/license/new-bsd If you did not receive a copy of the license and are unable to obtain it through the world-wide-web, please send an email to license@zend.com so we can send you a copy immediately.

Category
Zend  
Copyright
Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)  
License
New BSD License  
Package
Zend_Search_Lucene  
Version
$Id: FSM.php 24594 2012-01-05 21:27:01Z matthew $  

\Zend_Search_Lucene_FSM

Package: Zend\Search\Lucene

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

Children
\Zend_Search_Lucene_Search_QueryLexer
\Zend_Search_Lucene_Search_BooleanExpressionRecognizer
\Zend_Search_Lucene_Search_QueryParser
Category
Zend  
Copyright
Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)  
License
New BSD License  

Properties

Propertyprivateinteger|string  $_currentState= 'null'

Current state

Default valuenullDetails
Type
integerstring
Propertyprivatearray  $_entryActions= 'array()'

List of entry actions Each action executes when entering the state

[state] => action

Default valuearray()Details
Type
array
Propertyprivatearray  $_exitActions= 'array()'

List of exit actions Each action executes when exiting the state

[state] => action

Default valuearray()Details
Type
array
Propertyprivatearray  $_inputActions= 'array()'

List of input actions Each action executes when entering the state

[state][input] => action

Default valuearray()Details
Type
array
Propertyprivatearray  $_inputAphabet= 'array()'

Input alphabet

Default valuearray()Details
Type
array
Propertyprivatearray  $_rules= 'array()'

State transition table

[sourceState][input] => targetState

Default valuearray()Details
Type
array
Propertyprivatearray  $_states= 'array()'

Machine States alphabet

Default valuearray()Details
Type
array
Propertyprivatearray  $_transitionActions= 'array()'

List of input actions Each action executes when entering the state

[state1][state2] => action

Default valuearray()Details
Type
array

Methods

methodpublic__construct( array $states = array(), array $inputAphabet = array(), array $rules = array() ) : void

Finite State machine constructor

$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
Name Type Description
$states array
$inputAphabet array
$rules array
methodpublicaddEntryAction( integer|string $state, \Zend_Search_Lucene_FSMAction $action ) : void

Add state entry action.

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

Parameters
Name Type Description
$state integer|string
$action \Zend_Search_Lucene_FSMAction
methodpublicaddExitAction( integer|string $state, \Zend_Search_Lucene_FSMAction $action ) : void

Add state exit action.

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

Parameters
Name Type Description
$state integer|string
$action \Zend_Search_Lucene_FSMAction
methodpublicaddInputAction( integer|string $state,  $inputSymbol, \Zend_Search_Lucene_FSMAction $action ) : void

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

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

Parameters
Name Type Description
$state integer|string
$inputSymbol
$action \Zend_Search_Lucene_FSMAction
methodpublicaddInputSymbol( integer|string $inputSymbol ) : void

Add symbol to the input alphabet

Parameters
Name Type Description
$inputSymbol integer|string
methodpublicaddInputSymbols( array $inputAphabet ) : void

Add symbols to the input alphabet

Parameters
Name Type Description
$inputAphabet array
methodpublicaddRule( integer|string $sourceState, integer|string $input, integer|string $targetState, \Zend_Search_Lucene_FSMAction|null $inputAction = null ) : void

Add symbol to the input alphabet

Parameters
Name Type Description
$sourceState integer|string
$input integer|string
$targetState integer|string
$inputAction \Zend_Search_Lucene_FSMAction|null
Throws
Exception Description
\Zend_Search_Exception
methodpublicaddRules( array $rules ) : void

Add transition rules

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

Parameters
Name Type Description
$rules array
methodpublicaddState( integer|string $state ) : void

Add state to the state machine

Parameters
Name Type Description
$state integer|string
methodpublicaddStates( array $states ) : void

Add states to the state machine

Parameters
Name Type Description
$states array
methodpublicaddTransitionAction( integer|string $sourceState, integer|string $targetState, \Zend_Search_Lucene_FSMAction $action ) : void

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

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

Parameters
Name Type Description
$sourceState integer|string
$targetState integer|string
$action \Zend_Search_Lucene_FSMAction
methodpublicgetState( ) : integer|string

Get FSM state.

Returns
Type Description
integer|string $state|null
methodpublicprocess( mixed $input ) : void

Process an input

Parameters
Name Type Description
$input mixed
Throws
Exception Description
\Zend_Search_Exception
methodpublicreset( ) : void

methodpublicsetState( integer|string $state ) : void

Set FSM state.

No any action is invoked

Parameters
Name Type Description
$state integer|string
Throws
Exception Description
\Zend_Search_Exception
Documentation was generated by DocBlox 0.15.1.