Public Member Functions | |
| tokenize ($string) | |
| Breaks a string down to its tokens. | |
| parse ($string) | |
| Parses a string to create a spunQ_IPLStatement. | |
| parseComplexStatement ($string) | |
| Parses a statement that could not be parsed by regular expressions. | |
Static Public Member Functions | |
| static | getInstance () |
| Retrieves Singleton. | |
Public Attributes | |
| const | TOKEN_PARENTHESIS_OPEN = 1 |
| Token: opening parenthesis '('. | |
| const | TOKEN_PARENTHESIS_CLOSE = 2 |
| Token: closing parenthesis ')'. | |
| const | TOKEN_NOT = 4 |
| Token: boolean negation '!'. | |
| const | TOKEN_EQUALS = 8 |
| Token: equality operator '='. | |
| const | TOKEN_NOT_EQUALS = 12 |
| Token: bitwise OR of not and equality operator '!='. | |
| const | TOKEN_LESS = 16 |
| Token: operator less than '<'. | |
| const | TOKEN_LESS_EQUALS = 24 |
| Token: bitwise OR of less than and equality operator '<='. | |
| const | TOKEN_GREATER = 32 |
| Token: operator greater than '>'. | |
| const | TOKEN_GREATER_EQUALS = 40 |
| Token: bitwise OR of greater than and equality operator '>='. | |
| const | TOKEN_BRACKET_OPEN = 64 |
| Token: opening bracket '['. | |
| const | TOKEN_BRACKET_CLOSE = 128 |
| Token: closing bracket ']'. | |
| const | TOKEN_ARRAY_ITEM_SEPARATOR = 256 |
| Token: separator for array contents ','. | |
| const | TOKEN_PROPERTY = 512 |
| Token: An object property. | |
| const | TOKEN_PROPERTY_SEPARATOR = 1024 |
| Token: separator for chained properties '. | |
| const | TOKEN_OR = 2048 |
| Token: boolean OR 'OR'. | |
| const | TOKEN_AND = 4096 |
| Token: boolean AND 'AND'. | |
| const | TOKEN_CONSTANT = 8192 |
| Token: constant string. | |
| const | TOKEN_LIKE = 16384 |
| Token: 'like' operator. | |
| const | TOKEN_NOT_LIKE = 16388 |
| Token: 'like' operator. | |
| const | TOKEN_WHITESPACE = 32768 |
| Token: whitespace. | |
| const | TOKEN_COLON = 65536 |
| Token: colon ':'. | |
| const | TOKEN_NULL = 131072 |
| Token: null 'NULL'. | |
| const | TOKEN_IN = 262144 |
| Token: in operator. | |
| const | TOKEN_NOT_IN = 262148 |
| Token: in operator. | |
Protected Member Functions | |
| __construct () | |
| Constructor. | |
| getTokenUsingRegularExpression ($string, &$i, $regularExpression, $tokenConstant) | |
| Extracts a token using a regular expression. | |
| readConstantToken (&$string, &$i) | |
| Reads a string token and advances the string index. | |
| reduceParenthesisAndBrackets (&$tokens) | |
| Replaces all balanced parenthesis and brackets with according objects. | |
| parseOrStatement ($tokens, $from, $to) | |
| Tries to parse an OR statement. | |
| parseAndStatement ($tokens, $from, $to) | |
| Tries to parse an AND statement. | |
| parseComparison ($tokens, $from, $to) | |
| Tries to parse a comparison. | |
| parseValue ($tokens, $from, $to) | |
| Tries to parse a value. | |
| parsePropertyPath ($tokens, $from, $to) | |
| Tries to parse a value. | |
| parseConstantValue ($tokens, $from, $to) | |
| Tries to parse a constant. | |
| nextNonWhitespaceToken ($tokens, &$i, $to) | |
| Advances a token index to the next non-whitespace token. | |
| checkParsedToken ($tokens, $from, $to, $class) | |
| Checks if a given class is already present in the $tokens array. | |
| createStringAndPosition ($tokens, $offset, &$string, &$position) | |
| Constructs a string and an index for the string from the $tokens array. | |
Protected Attributes | |
| $oneCharacterTokens | |
| Tokens that can easily be mapped to TOKEN_* constants. | |
Private Attributes | |
| $parsedStrings = array() | |
| Cache for strings that have been processed. | |
| $cache | |
Static Private Attributes | |
| static | $instance |
| Singleton instance. | |
Language syntax:
statement:
or-chain
| and-chain
| comparison
| value
or-chain:
statement 'OR' statement
and-chain:
statement 'AND' statement
comparison:
value operator value
value:
'!' value
| property-path
| constant-value
| array '.' property-path
| parenthesis-statement
| parenthesis-statement '.' property-path
property-path:
property property-modifiers
| property property-modifiers '.' property-path
property-modifiers:
<void>
| property-modifier
| property-modifier property-modifiers
property-modifier:
'[' statement ']'
| '[=' statement ']'
constant-value:
'{' property '}'
array:
'[' array-contents ']'
array-contents:
value
| value ',' array-contents
parenthesis-statement:
'(' statement ')'
property:
/[_a-z][_a-z0-9]* /
operator:
'<'
| '>'
| '='
| '<='
| '>='
| '!='
| 'IN'
| '!IN'
| 'LIKE'
| '!LIKE'
Definition at line 73 of file PropertyParser.class.php.
| spunQ_PropertyParser::__construct | ( | ) | [protected] |
Constructor.
Declared to reduce visibility.
Definition at line 242 of file PropertyParser.class.php.
| spunQ_PropertyParser::checkParsedToken | ( | $ | tokens, | |
| $ | from, | |||
| $ | to, | |||
| $ | class | |||
| ) | [protected] |
Checks if a given class is already present in the $tokens array.
Because we are processing some parts of the $tokens array in advance (namely parenthesis and brackets), it is well possible that the expected token is already present as an object in either of the parse* functions. This function checks that an object resides in the token within the range [$from-$to] (ignoring whitespace) and returns the object if it is present or NULL otherwise.
| $tokens | array containing the tokens (and possibly some objects). | |
| $from | The object must be between the $from and $to indexes of the $tokens array. | |
| $to | see $token parameter. | |
| $class | The name of the class to look for. |
Definition at line 736 of file PropertyParser.class.php.
| spunQ_PropertyParser::createStringAndPosition | ( | $ | tokens, | |
| $ | offset, | |||
| &$ | string, | |||
| &$ | position | |||
| ) | [protected] |
Constructs a string and an index for the string from the $tokens array.
Needed to provide some useful feedback to the user. With this function we can display the character number that caused an error.
| $tokens | array containing the tokens (and possibly some objects). | |
| $offset | The token number that had the error. | |
| $string | The string that will be generated (out-parameter). | |
| $position | The position within the string of the bogus token (out-parameter). |
Definition at line 770 of file PropertyParser.class.php.
| static spunQ_PropertyParser::getInstance | ( | ) | [static] |
Retrieves Singleton.
Definition at line 205 of file PropertyParser.class.php.
| spunQ_PropertyParser::getTokenUsingRegularExpression | ( | $ | string, | |
| &$ | i, | |||
| $ | regularExpression, | |||
| $ | tokenConstant | |||
| ) | [protected] |
Extracts a token using a regular expression.
| $string | The string to extract from. | |
| $i | The index of the string the processing should start at. This parameter will point to the index after the extracted string. | |
| $regularExpression | The regular expression to use. Should not contain leading/trailing delimiters. Will be run with the modifiers i (case-insensitive) and s (match newlines). | |
| $tokenConstant | The TOKEN_* constant for this token. |
Definition at line 358 of file PropertyParser.class.php.
| spunQ_PropertyParser::nextNonWhitespaceToken | ( | $ | tokens, | |
| &$ | i, | |||
| $ | to | |||
| ) | [protected] |
Advances a token index to the next non-whitespace token.
| $tokens | array containing the tokens (and possibly some objects). | |
| $i | The index to advance. | |
| $to | The maximum value $i can have. |
Definition at line 709 of file PropertyParser.class.php.
| spunQ_PropertyParser::parse | ( | $ | string | ) |
Parses a string to create a spunQ_IPLStatement.
Tries to parse using regular expressions and passes the string to parseComplexStatement() if it does not work.
| $string | the property path string |
Definition at line 296 of file PropertyParser.class.php.
| spunQ_PropertyParser::parseAndStatement | ( | $ | tokens, | |
| $ | from, | |||
| $ | to | |||
| ) | [protected] |
Tries to parse an AND statement.
Next in chain: comparison
| $tokens | array containing the tokens (and possibly some objects). | |
| $from | Start processing at this index of the tokens array (inclusive). | |
| $to | process up to this index (inclusive). |
Definition at line 509 of file PropertyParser.class.php.
| spunQ_PropertyParser::parseComparison | ( | $ | tokens, | |
| $ | from, | |||
| $ | to | |||
| ) | [protected] |
Tries to parse a comparison.
Next in chain: value
| $tokens | array containing the tokens (and possibly some objects). | |
| $from | Start processing at this index of the tokens array (inclusive). | |
| $to | process up to this index (inclusive). |
Definition at line 551 of file PropertyParser.class.php.
| spunQ_PropertyParser::parseComplexStatement | ( | $ | string | ) |
Parses a statement that could not be parsed by regular expressions.
The parsing is done with the following steps:
| $string | the statement to parse. |
Definition at line 401 of file PropertyParser.class.php.
| spunQ_PropertyParser::parseConstantValue | ( | $ | tokens, | |
| $ | from, | |||
| $ | to | |||
| ) | [protected] |
Tries to parse a constant.
Next in chain: <nothing>
| $tokens | array containing the tokens (and possibly some objects). | |
| $from | Start processing at this index of the tokens array (inclusive). | |
| $to | process up to this index (inclusive). |
Definition at line 682 of file PropertyParser.class.php.
| spunQ_PropertyParser::parseOrStatement | ( | $ | tokens, | |
| $ | from, | |||
| $ | to | |||
| ) | [protected] |
Tries to parse an OR statement.
Next in chain: AND statement
| $tokens | array containing the tokens (and possibly some objects). | |
| $from | Start processing at this index of the tokens array (inclusive). | |
| $to | process up to this index (inclusive). |
Definition at line 473 of file PropertyParser.class.php.
| spunQ_PropertyParser::parsePropertyPath | ( | $ | tokens, | |
| $ | from, | |||
| $ | to | |||
| ) | [protected] |
Tries to parse a value.
Next in chain: propertypath or constant
| $tokens | array containing the tokens (and possibly some objects). | |
| $from | Start processing at this index of the tokens array (inclusive). | |
| $to | process up to this index (inclusive). |
Definition at line 624 of file PropertyParser.class.php.
| spunQ_PropertyParser::parseValue | ( | $ | tokens, | |
| $ | from, | |||
| $ | to | |||
| ) | [protected] |
Tries to parse a value.
Next in chain: propertypath or constant
| $tokens | array containing the tokens (and possibly some objects). | |
| $from | Start processing at this index of the tokens array (inclusive). | |
| $to | process up to this index (inclusive). |
Definition at line 599 of file PropertyParser.class.php.
| spunQ_PropertyParser::readConstantToken | ( | &$ | string, | |
| &$ | i | |||
| ) | [protected] |
Reads a string token and advances the string index.
| $string | The string to read from | |
| $i | the index to start extracting the string from. This parameter will point at the position after the string when the operation finishes. |
| spunQ_PropertyPathException |
Definition at line 374 of file PropertyParser.class.php.
| spunQ_PropertyParser::reduceParenthesisAndBrackets | ( | &$ | tokens | ) | [protected] |
Replaces all balanced parenthesis and brackets with according objects.
Parenthesis will be replaced by the spunQ_IPLStatement they evaluate to and brackets by either spunQ_PLArrayTransformation or spunQ_PLArrayReduction.
| $tokens | array<array<any>> as returned by tokenize(). |
Definition at line 417 of file PropertyParser.class.php.
| spunQ_PropertyParser::tokenize | ( | $ | string | ) |
Breaks a string down to its tokens.
| $string | The string to process |
| spunQ_PropertyPathException |
Definition at line 260 of file PropertyParser.class.php.
spunQ_PropertyParser::$instance [static, private] |
Singleton instance.
Definition at line 199 of file PropertyParser.class.php.
spunQ_PropertyParser::$oneCharacterTokens [protected] |
Initial value:
array(
'(' => self::TOKEN_PARENTHESIS_OPEN,
')' => self::TOKEN_PARENTHESIS_CLOSE,
'[' => self::TOKEN_BRACKET_OPEN,
']' => self::TOKEN_BRACKET_CLOSE,
'<' => self::TOKEN_LESS,
'>' => self::TOKEN_GREATER,
'!' => self::TOKEN_NOT,
'=' => self::TOKEN_EQUALS,
':' => self::TOKEN_COLON,
'.' => self::TOKEN_PROPERTY_SEPARATOR,
',' => self::TOKEN_ARRAY_ITEM_SEPARATOR,
)
Definition at line 216 of file PropertyParser.class.php.
spunQ_PropertyParser::$parsedStrings = array() [private] |
Cache for strings that have been processed.
Definition at line 234 of file PropertyParser.class.php.
| const spunQ_PropertyParser::TOKEN_PROPERTY_SEPARATOR = 1024 |
Token: separator for chained properties '.
'
Definition at line 143 of file PropertyParser.class.php.
1.5.9