HumHub Documentation (unofficial)

QueryLexer extends AbstractFSM
in package

Abstract Finite State Machine

Tags
category

Zend

subpackage

Search

Table of Contents

Constants

IN_ASCII_DIGIT  = 6
IN_CHAR  = 7
IN_DECIMAL_POINT  = 5
IN_ESCAPE_CHAR  = 3
IN_LEXEME_MODIFIER  = 2
IN_MUTABLE_CHAR  = 8
IN_QUOTE  = 4
IN_SYNT_CHAR  = 1
IN_WHITE_SPACE  = 0
Input symbols
QUERY_ASCIIDIGITS_CHARS  = '0123456789'
QUERY_DOUBLECHARLEXEME_CHARS  = '|&'
QUERY_LEXEMEMODIFIER_CHARS  = '~^'
QUERY_MUTABLE_CHARS  = '+-'
QUERY_SYNT_CHARS  = ':()[]{}!|&'
QUERY_WHITE_SPACE_CHARS  = " \n\r\t"
ST_ERROR  = 9
ST_ESCAPED_CHAR  = 4
ST_ESCAPED_QCHAR  = 5
ST_LEXEME  = 2
ST_LEXEME_MODIFIER  = 6
ST_MANTISSA  = 8
ST_NUMBER  = 7
ST_QUOTED_LEXEME  = 3
ST_SYNT_LEXEME  = 1
ST_WHITE_SPACE  = 0
State Machine states

Properties

$_currentLexeme  : string
Recognized part of current lexeme
$_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
$_lexemes  : array<string|int, mixed>
List of recognized lexemes
$_queryString  : array<string|int, mixed>
Query string (array of single- or non single-byte characters)
$_queryStringPosition  : int
Current position within a query string Used to create appropriate error messages
$_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
Finite State machine 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
addLexeme()  : void
Add lexeme
addLexemeChar()  : void
Extend lexeme by one char
addLexemeModifier()  : void
Add lexeme modifier
addNumberLexeme()  : void
Add number lexeme
addQuerySyntaxLexeme()  : void
Add query syntax lexeme
addQuotedLexeme()  : void
Add quoted lexeme
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).
getState()  : int|string
Get FSM state.
lexModifierErrException()  : void
process()  : void
Process an input
quoteWithinLexemeErrException()  : void
reset()  : void
setState()  : void
Set FSM state.
tokenize()  : array<string|int, mixed>
This method is used to tokenize query string into lexemes
wrongNumberErrException()  : void
_positionMsg()  : string
Position message
_translateInput()  : int
Translate input char to an input symbol of state machine

Constants

IN_DECIMAL_POINT

public mixed IN_DECIMAL_POINT = 5

IN_LEXEME_MODIFIER

public mixed IN_LEXEME_MODIFIER = 2

IN_MUTABLE_CHAR

public mixed IN_MUTABLE_CHAR = 8

IN_WHITE_SPACE

Input symbols

public mixed IN_WHITE_SPACE = 0

QUERY_ASCIIDIGITS_CHARS

public mixed QUERY_ASCIIDIGITS_CHARS = '0123456789'

QUERY_DOUBLECHARLEXEME_CHARS

public mixed QUERY_DOUBLECHARLEXEME_CHARS = '|&'

QUERY_LEXEMEMODIFIER_CHARS

public mixed QUERY_LEXEMEMODIFIER_CHARS = '~^'

QUERY_MUTABLE_CHARS

public mixed QUERY_MUTABLE_CHARS = '+-'

QUERY_SYNT_CHARS

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

QUERY_WHITE_SPACE_CHARS

public mixed QUERY_WHITE_SPACE_CHARS = " \n\r\t"

ST_ESCAPED_CHAR

public mixed ST_ESCAPED_CHAR = 4

ST_ESCAPED_QCHAR

public mixed ST_ESCAPED_QCHAR = 5

ST_LEXEME_MODIFIER

public mixed ST_LEXEME_MODIFIER = 6

ST_QUOTED_LEXEME

public mixed ST_QUOTED_LEXEME = 3

ST_WHITE_SPACE

State Machine states

public mixed ST_WHITE_SPACE = 0

Properties

$_currentLexeme

Recognized part of current lexeme

private string $_currentLexeme

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

$_lexemes

List of recognized lexemes

private array<string|int, mixed> $_lexemes

$_queryString

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

private array<string|int, mixed> $_queryString

$_queryStringPosition

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

private int $_queryStringPosition

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

Finite State machine constructor

public __construct() : mixed

$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.

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
throws
InvalidArgumentException

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
throws
InvalidArgumentException

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
throws
InvalidArgumentException

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>

addLexeme()

Add lexeme

public addLexeme() : void

addLexemeChar()

Extend lexeme by one char

public addLexemeChar() : void

addLexemeModifier()

Add lexeme modifier

public addLexemeModifier() : void

addNumberLexeme()

Add number lexeme

public addNumberLexeme() : void

addQuotedLexeme()

Add quoted lexeme

public addQuotedLexeme() : void

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
throws
InvalidArgumentException
throws
RuntimeException

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
throws
InvalidArgumentException

getState()

Get FSM state.

public getState() : int|string
Return values
int|string

$state|null

lexModifierErrException()

public lexModifierErrException() : void

quoteWithinLexemeErrException()

public quoteWithinLexemeErrException() : void

tokenize()

This method is used to tokenize query string into lexemes

public tokenize(string $inputString, string $encoding) : array<string|int, mixed>
Parameters
$inputString : string
$encoding : string
Tags
throws
QueryParserException
Return values
array<string|int, mixed>

wrongNumberErrException()

public wrongNumberErrException() : void

_positionMsg()

Position message

private _positionMsg() : string
Return values
string

_translateInput()

Translate input char to an input symbol of state machine

private _translateInput(string $char) : int
Parameters
$char : string
Return values
int

        
On this page

Search results