BooleanExpressionRecognizer
extends AbstractFSM
in package
Abstract Finite State Machine
Tags
Table of Contents
Constants
- IN_AND_OPERATOR = 2
- IN_LITERAL = 0
- Input symbols
- IN_NOT_OPERATOR = 1
- IN_OR_OPERATOR = 3
- ST_AND_OPERATOR = 3
- ST_LITERAL = 1
- ST_NOT_OPERATOR = 2
- ST_OR_OPERATOR = 4
- ST_START = 0
- State Machine states
Properties
- $_conjunctions : array<string|int, mixed>
- Set of boolean query conjunctions
- $_currentConjunction : array<string|int, mixed>
- Current conjuction
- $_currentState : int|string
- Current state
- $_entryActions : array<string|int, mixed>
- List of entry actions Each action executes when entering the state
- $_exitActions : array<string|int, mixed>
- List of exit actions Each action executes when exiting the state
- $_inputActions : array<string|int, mixed>
- List of input actions Each action executes when entering the state
- $_inputAphabet : array<string|int, mixed>
- Input alphabet
- $_literal : mixed
- Current literal
- $_negativeLiteral : bool
- NOT operator signal
- $_rules : array<string|int, mixed>
- State transition table
- $_states : array<string|int, mixed>
- Machine States alphabet
- $_transitionActions : array<string|int, mixed>
- List of input actions Each action executes when entering the state
Methods
- __construct() : mixed
- Object constructor
- addEntryAction() : void
- Add state entry action.
- addExitAction() : void
- Add state exit action.
- addInputAction() : void
- Add input action (defined by {state, input} pair).
- addInputSymbol() : void
- Add symbol to the input alphabet
- addInputSymbols() : void
- Add symbols to the input alphabet
- addRule() : void
- Add symbol to the input alphabet
- addRules() : void
- Add transition rules
- addState() : void
- Add state to the state machine
- addStates() : void
- Add states to the state machine
- addTransitionAction() : void
- Add transition action (defined by {state, input} pair).
- emptyNotOperatorAction() : void
- default (omitted) + NOT operator processing
- emptyOperatorAction() : void
- default (omitted) operator processing
- finishExpression() : array<string|int, mixed>
- Finish an expression and return result
- getState() : int|string
- Get FSM state.
- literalAction() : void
- Literal processing
- notOperatorAction() : void
- NOT operator processing
- orOperatorAction() : void
- OR operator processing Close current conjunction
- process() : void
- Process an input
- processLiteral() : void
- Process expression literal.
- processOperator() : void
- Process next operator.
- reset() : void
- setState() : void
- Set FSM state.
Constants
IN_AND_OPERATOR
public
mixed
IN_AND_OPERATOR
= 2
IN_LITERAL
Input symbols
public
mixed
IN_LITERAL
= 0
IN_NOT_OPERATOR
public
mixed
IN_NOT_OPERATOR
= 1
IN_OR_OPERATOR
public
mixed
IN_OR_OPERATOR
= 3
ST_AND_OPERATOR
public
mixed
ST_AND_OPERATOR
= 3
ST_LITERAL
public
mixed
ST_LITERAL
= 1
ST_NOT_OPERATOR
public
mixed
ST_NOT_OPERATOR
= 2
ST_OR_OPERATOR
public
mixed
ST_OR_OPERATOR
= 4
ST_START
State Machine states
public
mixed
ST_START
= 0
Properties
$_conjunctions
Set of boolean query conjunctions
private
array<string|int, mixed>
$_conjunctions
= 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(
$_currentConjunction
Current conjuction
private
array<string|int, mixed>
$_currentConjunction
= array()
$_currentState
Current state
private
int|string
$_currentState
= null
$_entryActions
List of entry actions Each action executes when entering the state
private
array<string|int, mixed>
$_entryActions
= array()
[state] => action
$_exitActions
List of exit actions Each action executes when exiting the state
private
array<string|int, mixed>
$_exitActions
= array()
[state] => action
$_inputActions
List of input actions Each action executes when entering the state
private
array<string|int, mixed>
$_inputActions
= array()
[state][input] => action
$_inputAphabet
Input alphabet
private
array<string|int, mixed>
$_inputAphabet
= array()
$_literal
Current literal
private
mixed
$_literal
$_negativeLiteral
NOT operator signal
private
bool
$_negativeLiteral
= false
$_rules
State transition table
private
array<string|int, mixed>
$_rules
= array()
[sourceState][input] => targetState
$_states
Machine States alphabet
private
array<string|int, mixed>
$_states
= array()
$_transitionActions
List of input actions Each action executes when entering the state
private
array<string|int, mixed>
$_transitionActions
= array()
[state1][state2] => action
Methods
__construct()
Object constructor
public
__construct() : mixed
addEntryAction()
Add state entry action.
public
addEntryAction(int|string $state, FSMAction $action) : void
Several entry actions are allowed. Action execution order is defined by addEntryAction() calls
Parameters
- $state : int|string
- $action : FSMAction
Tags
addExitAction()
Add state exit action.
public
addExitAction(int|string $state, FSMAction $action) : void
Several exit actions are allowed. Action execution order is defined by addEntryAction() calls
Parameters
- $state : int|string
- $action : FSMAction
Tags
addInputAction()
Add input action (defined by {state, input} pair).
public
addInputAction(int|string $state, int|string $inputSymbol, FSMAction $action) : void
Several input actions are allowed. Action execution order is defined by addInputAction() calls
Parameters
- $state : int|string
- $inputSymbol : int|string
- $action : FSMAction
Tags
addInputSymbol()
Add symbol to the input alphabet
public
addInputSymbol(int|string $inputSymbol) : void
Parameters
- $inputSymbol : int|string
addInputSymbols()
Add symbols to the input alphabet
public
addInputSymbols(array<string|int, mixed> $inputAphabet) : void
Parameters
- $inputAphabet : array<string|int, mixed>
addRule()
Add symbol to the input alphabet
public
addRule(int|string $sourceState, int|string $input, int|string $targetState[, FSMAction|null $inputAction = null ]) : void
Parameters
- $sourceState : int|string
- $input : int|string
- $targetState : int|string
- $inputAction : FSMAction|null = null
Tags
addRules()
Add transition rules
public
addRules(array<string|int, mixed> $rules) : void
array structure: array( array(sourseState, input, targetState[, inputAction]), array(sourseState, input, targetState[, inputAction]), array(sourseState, input, targetState[, inputAction]), ... )
Parameters
- $rules : array<string|int, mixed>
addState()
Add state to the state machine
public
addState(int|string $state) : void
Parameters
- $state : int|string
addStates()
Add states to the state machine
public
addStates(array<string|int, mixed> $states) : void
Parameters
- $states : array<string|int, mixed>
addTransitionAction()
Add transition action (defined by {state, input} pair).
public
addTransitionAction(int|string $sourceState, int|string $targetState, FSMAction $action) : void
Several transition actions are allowed. Action execution order is defined by addTransitionAction() calls
Parameters
- $sourceState : int|string
- $targetState : int|string
- $action : FSMAction
Tags
emptyNotOperatorAction()
default (omitted) + NOT operator processing
public
emptyNotOperatorAction() : void
emptyOperatorAction()
default (omitted) operator processing
public
emptyOperatorAction() : void
finishExpression()
Finish an expression and return result
public
finishExpression() : array<string|int, mixed>
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(
Tags
Return values
array<string|int, mixed>getState()
Get FSM state.
public
getState() : int|string
Return values
int|string —$state|null
literalAction()
Literal processing
public
literalAction() : void
notOperatorAction()
NOT operator processing
public
notOperatorAction() : void
orOperatorAction()
OR operator processing Close current conjunction
public
orOperatorAction() : void
process()
Process an input
public
process(mixed $input) : void
Parameters
- $input : mixed
Tags
processLiteral()
Process expression literal.
public
processLiteral(AbstractQueryEntry $literal) : void
Parameters
- $literal : AbstractQueryEntry
processOperator()
Process next operator.
public
processOperator(int $operator) : void
Operators are defined by class constants: IN_AND_OPERATOR, IN_OR_OPERATOR and IN_NOT_OPERATOR
Parameters
- $operator : int
reset()
public
reset() : void
Tags
setState()
Set FSM state.
public
setState(int|string $state) : void
No any action is invoked
Parameters
- $state : int|string