API Documentation

Search/Lucene/Search/QueryLexer.php

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-2011 Zend Technologies USA Inc. (http://www.zend.com)  
license
New BSD License  
package
Zend_Search_Lucene  
subpackage
Search  
version
$Id: QueryLexer.php 23775 2011-03-01 17:25:24Z ralph $  

\Zend_Search_Lucene_Search_QueryLexer

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

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

Constants

Constant  ST_WHITE_SPACE = '0'

State Machine states

Constant  ST_SYNT_LEXEME = '1'
Constant  ST_LEXEME = '2'
Constant  ST_QUOTED_LEXEME = '3'
Constant  ST_ESCAPED_CHAR = '4'
Constant  ST_ESCAPED_QCHAR = '5'
Constant  ST_LEXEME_MODIFIER = '6'
Constant  ST_NUMBER = '7'
Constant  ST_MANTISSA = '8'
Constant  ST_ERROR = '9'
Constant  IN_WHITE_SPACE = '0'

Input symbols

Constant  IN_SYNT_CHAR = '1'
Constant  IN_LEXEME_MODIFIER = '2'
Constant  IN_ESCAPE_CHAR = '3'
Constant  IN_QUOTE = '4'
Constant  IN_DECIMAL_POINT = '5'
Constant  IN_ASCII_DIGIT = '6'
Constant  IN_CHAR = '7'
Constant  IN_MUTABLE_CHAR = '8'
Constant  QUERY_WHITE_SPACE_CHARS = ' \n\r\t'
Constant  QUERY_SYNT_CHARS = ':()[]{}!|&'
Constant  QUERY_MUTABLE_CHARS = '+-'
Constant  QUERY_DOUBLECHARLEXEME_CHARS = '|&'
Constant  QUERY_LEXEMEMODIFIER_CHARS = '~^'
Constant  QUERY_ASCIIDIGITS_CHARS = '0123456789'

Properties

Propertyprivatestring  $_currentLexeme= ''

Recognized part of current lexeme

Details
Type
string
Propertyprivatearray  $_lexemes= ''

List of recognized lexemes

Details
Type
array
Propertyprivatearray  $_queryString= ''

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

Details
Type
array
Propertyprivateinteger  $_queryStringPosition= ''

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

Details
Type
integer

Methods

methodpublic__construct( ) : 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.

methodprivate_positionMsg( ) : string

Position message

Returns
Type Description
string
methodprivate_translateInput( string $char ) : integer

Translate input char to an input symbol of state machine

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

Add state entry action.

Inherited from: \Zend_Search_Lucene_FSM::addEntryAction()

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.

Inherited from: \Zend_Search_Lucene_FSM::addExitAction()

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

Inherited from: \Zend_Search_Lucene_FSM::addInputAction()

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

Inherited from: \Zend_Search_Lucene_FSM::addInputSymbol()
Parameters
Name Type Description
$inputSymbol integer|string
methodpublicaddInputSymbols( array $inputAphabet ) : void

Add symbols to the input alphabet

Inherited from: \Zend_Search_Lucene_FSM::addInputSymbols()
Parameters
Name Type Description
$inputAphabet array
methodpublicaddLexeme( ) : void

Add lexeme

methodpublicaddLexemeChar( ) : void

Extend lexeme by one char

methodpublicaddLexemeModifier( ) : void

Add lexeme modifier

methodpublicaddNumberLexeme( ) : void

Add number lexeme

methodpublicaddQuerySyntaxLexeme( ) : void

Add query syntax lexeme

methodpublicaddQuotedLexeme( ) : void

Add quoted lexeme

methodpublicaddRule( integer|string $sourceState, integer|string $input, integer|string $targetState, \Zend_Search_Lucene_FSMAction|null $inputAction = null ) : void

Add symbol to the input alphabet

Inherited from: \Zend_Search_Lucene_FSM::addRule()
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

Inherited from: \Zend_Search_Lucene_FSM::addRules()

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

Inherited from: \Zend_Search_Lucene_FSM::addState()
Parameters
Name Type Description
$state integer|string
methodpublicaddStates( array $states ) : void

Add states to the state machine

Inherited from: \Zend_Search_Lucene_FSM::addStates()
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).

Inherited from: \Zend_Search_Lucene_FSM::addTransitionAction()

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.

Inherited from: \Zend_Search_Lucene_FSM::getState()
Returns
Type Description
integerstring $state|null
methodpubliclexModifierErrException( ) : void

methodpublicprocess( mixed $input ) : void

Process an input

Inherited from: \Zend_Search_Lucene_FSM::process()
Parameters
Name Type Description
$input mixed
Throws
Exception Description
\Zend_Search_Exception
methodpublicquoteWithinLexemeErrException( ) : void

methodpublicreset( ) : void
methodpublicsetState( integer|string $state ) : void

Set FSM state.

Inherited from: \Zend_Search_Lucene_FSM::setState()

No any action is invoked

Parameters
Name Type Description
$state integer|string
Throws
Exception Description
\Zend_Search_Exception
methodpublictokenize( string $inputString, string $encoding ) : array

This method is used to tokenize query string into lexemes

Parameters
Name Type Description
$inputString string
$encoding string
Returns
Type Description
array
Throws
Exception Description
\Zend_Search_Lucene_Search_QueryParserException
methodpublicwrongNumberErrException( ) : void

Documentation was generated by DocBlox 0.13.3.