Lexer
extends AbstractLexer
in package
Scans a DQL query for tokens.
Tags
Table of Contents
Constants
- T_ALIASED_NAME = 100
- T_ALL = 200
- T_AND = 201
- T_ANY = 202
- T_AS = 203
- T_ASC = 204
- T_AVG = 205
- T_BETWEEN = 206
- T_BOTH = 207
- T_BY = 208
- T_CASE = 209
- T_CLOSE_CURLY_BRACE = 19
- T_CLOSE_PARENTHESIS = 6
- T_COALESCE = 210
- T_COMMA = 8
- T_COUNT = 211
- T_DELETE = 212
- T_DESC = 213
- T_DISTINCT = 214
- T_DIVIDE = 9
- T_DOT = 10
- T_ELSE = 215
- T_EMPTY = 216
- T_END = 217
- T_EQUALS = 11
- T_ESCAPE = 218
- T_EXISTS = 219
- T_FALSE = 220
- T_FLOAT = 5
- T_FROM = 221
- T_FULLY_QUALIFIED_NAME = 101
- T_GREATER_THAN = 12
- T_GROUP = 222
- T_HAVING = 223
- T_HIDDEN = 224
- T_IDENTIFIER = 102
- T_IN = 225
- T_INDEX = 226
- T_INNER = 227
- T_INPUT_PARAMETER = 4
- T_INSTANCE = 228
- T_INTEGER = 2
- T_IS = 229
- T_JOIN = 230
- T_LEADING = 231
- T_LEFT = 232
- T_LIKE = 233
- T_LOWER_THAN = 13
- T_MAX = 234
- T_MEMBER = 235
- T_MIN = 236
- T_MINUS = 14
- T_MULTIPLY = 15
- T_NEGATE = 16
- T_NEW = 237
- T_NONE = 1
- T_NOT = 238
- T_NULL = 239
- T_NULLIF = 240
- T_OF = 241
- T_OPEN_CURLY_BRACE = 18
- T_OPEN_PARENTHESIS = 7
- T_OR = 242
- T_ORDER = 243
- T_OUTER = 244
- T_PARTIAL = 245
- T_PLUS = 17
- T_SELECT = 246
- T_SET = 247
- T_SOME = 248
- T_STRING = 3
- T_SUM = 249
- T_THEN = 250
- T_TRAILING = 251
- T_TRUE = 252
- T_UPDATE = 253
- T_WHEN = 254
- T_WHERE = 255
- T_WITH = 256
Properties
- $lookahead : array<string|int, mixed>|null
- The next token in the input.
- $token : array<string|int, mixed>|null
- The last matched/seen token.
- $input : string
- Lexer original input string.
- $peek : int
- Current peek of current lexer position.
- $position : int
- Current lexer position in input string.
- $regex : string|null
- Composed regex for input parsing.
- $tokens : array<int, Token<T, V>>
- Array of scanned tokens.
Methods
- __construct() : mixed
- Creates a new query scanner object.
- getInputUntilPosition() : string
- Retrieve the original lexer's input until a given position.
- getLiteral() : int|string
- Gets the literal for a given token.
- glimpse() : array<string|int, mixed>|null
- Peeks at the next token, returns it and immediately resets the peek.
- isA() : bool
- Checks if given value is identical to the given token.
- isNextToken() : bool
- Checks whether a given token matches the current lookahead.
- isNextTokenAny() : bool
- Checks whether any of the given tokens matches the current lookahead.
- moveNext() : bool
- Moves to the next token in the input string.
- peek() : array<string|int, mixed>|null
- Moves the lookahead token forward.
- reset() : void
- Resets the lexer.
- resetPeek() : void
- Resets the peek pointer to 0.
- resetPosition() : void
- Resets the lexer position on the input to the given position.
- setInput() : void
- Sets the input data to be tokenized.
- skipUntil() : void
- Tells the lexer to skip input tokens until it sees a token with the given value.
- getCatchablePatterns() : array<string|int, string>
- Lexical catchable patterns.
- getModifiers() : string
- Regex modifiers
- getNonCatchablePatterns() : array<string|int, string>
- Lexical non-catchable patterns.
- getType() : T|null
- Retrieve token type. Also processes the token value if necessary.
- scan() : void
- Scans the input string for tokens.
Constants
T_ALIASED_NAME
public
mixed
T_ALIASED_NAME
= 100
Tags
T_ALL
public
mixed
T_ALL
= 200
T_AND
public
mixed
T_AND
= 201
T_ANY
public
mixed
T_ANY
= 202
T_AS
public
mixed
T_AS
= 203
T_ASC
public
mixed
T_ASC
= 204
T_AVG
public
mixed
T_AVG
= 205
T_BETWEEN
public
mixed
T_BETWEEN
= 206
T_BOTH
public
mixed
T_BOTH
= 207
T_BY
public
mixed
T_BY
= 208
T_CASE
public
mixed
T_CASE
= 209
T_CLOSE_CURLY_BRACE
public
mixed
T_CLOSE_CURLY_BRACE
= 19
T_CLOSE_PARENTHESIS
public
mixed
T_CLOSE_PARENTHESIS
= 6
T_COALESCE
public
mixed
T_COALESCE
= 210
T_COMMA
public
mixed
T_COMMA
= 8
T_COUNT
public
mixed
T_COUNT
= 211
T_DELETE
public
mixed
T_DELETE
= 212
T_DESC
public
mixed
T_DESC
= 213
T_DISTINCT
public
mixed
T_DISTINCT
= 214
T_DIVIDE
public
mixed
T_DIVIDE
= 9
T_DOT
public
mixed
T_DOT
= 10
T_ELSE
public
mixed
T_ELSE
= 215
T_EMPTY
public
mixed
T_EMPTY
= 216
T_END
public
mixed
T_END
= 217
T_EQUALS
public
mixed
T_EQUALS
= 11
T_ESCAPE
public
mixed
T_ESCAPE
= 218
T_EXISTS
public
mixed
T_EXISTS
= 219
T_FALSE
public
mixed
T_FALSE
= 220
T_FLOAT
public
mixed
T_FLOAT
= 5
T_FROM
public
mixed
T_FROM
= 221
T_FULLY_QUALIFIED_NAME
public
mixed
T_FULLY_QUALIFIED_NAME
= 101
T_GREATER_THAN
public
mixed
T_GREATER_THAN
= 12
T_GROUP
public
mixed
T_GROUP
= 222
T_HAVING
public
mixed
T_HAVING
= 223
T_HIDDEN
public
mixed
T_HIDDEN
= 224
T_IDENTIFIER
public
mixed
T_IDENTIFIER
= 102
T_IN
public
mixed
T_IN
= 225
T_INDEX
public
mixed
T_INDEX
= 226
T_INNER
public
mixed
T_INNER
= 227
T_INPUT_PARAMETER
public
mixed
T_INPUT_PARAMETER
= 4
T_INSTANCE
public
mixed
T_INSTANCE
= 228
T_INTEGER
public
mixed
T_INTEGER
= 2
T_IS
public
mixed
T_IS
= 229
T_JOIN
public
mixed
T_JOIN
= 230
T_LEADING
public
mixed
T_LEADING
= 231
T_LEFT
public
mixed
T_LEFT
= 232
T_LIKE
public
mixed
T_LIKE
= 233
T_LOWER_THAN
public
mixed
T_LOWER_THAN
= 13
T_MAX
public
mixed
T_MAX
= 234
T_MEMBER
public
mixed
T_MEMBER
= 235
T_MIN
public
mixed
T_MIN
= 236
T_MINUS
public
mixed
T_MINUS
= 14
T_MULTIPLY
public
mixed
T_MULTIPLY
= 15
T_NEGATE
public
mixed
T_NEGATE
= 16
T_NEW
public
mixed
T_NEW
= 237
T_NONE
public
mixed
T_NONE
= 1
T_NOT
public
mixed
T_NOT
= 238
T_NULL
public
mixed
T_NULL
= 239
T_NULLIF
public
mixed
T_NULLIF
= 240
T_OF
public
mixed
T_OF
= 241
T_OPEN_CURLY_BRACE
public
mixed
T_OPEN_CURLY_BRACE
= 18
T_OPEN_PARENTHESIS
public
mixed
T_OPEN_PARENTHESIS
= 7
T_OR
public
mixed
T_OR
= 242
T_ORDER
public
mixed
T_ORDER
= 243
T_OUTER
public
mixed
T_OUTER
= 244
T_PARTIAL
public
mixed
T_PARTIAL
= 245
T_PLUS
public
mixed
T_PLUS
= 17
T_SELECT
public
mixed
T_SELECT
= 246
T_SET
public
mixed
T_SET
= 247
T_SOME
public
mixed
T_SOME
= 248
T_STRING
public
mixed
T_STRING
= 3
T_SUM
public
mixed
T_SUM
= 249
T_THEN
public
mixed
T_THEN
= 250
T_TRAILING
public
mixed
T_TRAILING
= 251
T_TRUE
public
mixed
T_TRUE
= 252
T_UPDATE
public
mixed
T_UPDATE
= 253
T_WHEN
public
mixed
T_WHEN
= 254
T_WHERE
public
mixed
T_WHERE
= 255
T_WITH
public
mixed
T_WITH
= 256
Properties
$lookahead
The next token in the input.
public
array<string|int, mixed>|null
$lookahead
Tags
$token
The last matched/seen token.
public
array<string|int, mixed>|null
$token
Tags
$input
Lexer original input string.
private
string
$input
$peek
Current peek of current lexer position.
private
int
$peek
= 0
$position
Current lexer position in input string.
private
int
$position
= 0
$regex
Composed regex for input parsing.
private
string|null
$regex
$tokens
Array of scanned tokens.
private
array<int, Token<T, V>>
$tokens
= []
Methods
__construct()
Creates a new query scanner object.
public
__construct(string $input) : mixed
Parameters
- $input : string
-
A query string.
getInputUntilPosition()
Retrieve the original lexer's input until a given position.
public
getInputUntilPosition(int $position) : string
Parameters
- $position : int
Return values
stringgetLiteral()
Gets the literal for a given token.
public
getLiteral(T $token) : int|string
Parameters
- $token : T
Return values
int|stringglimpse()
Peeks at the next token, returns it and immediately resets the peek.
public
glimpse() : array<string|int, mixed>|null
Tags
Return values
array<string|int, mixed>|null —The next token or NULL if there are no more tokens ahead.
isA()
Checks if given value is identical to the given token.
public
isA(string $value, int|string $token) : bool
Parameters
- $value : string
- $token : int|string
Return values
boolisNextToken()
Checks whether a given token matches the current lookahead.
public
isNextToken(T $type) : bool
Parameters
- $type : T
Tags
Return values
boolisNextTokenAny()
Checks whether any of the given tokens matches the current lookahead.
public
isNextTokenAny(array<int, T> $types) : bool
Parameters
- $types : array<int, T>
Tags
Return values
boolmoveNext()
Moves to the next token in the input string.
public
moveNext() : bool
Tags
Return values
boolpeek()
Moves the lookahead token forward.
public
peek() : array<string|int, mixed>|null
Tags
Return values
array<string|int, mixed>|null —The next token or NULL if there are no more tokens ahead.
reset()
Resets the lexer.
public
reset() : void
resetPeek()
Resets the peek pointer to 0.
public
resetPeek() : void
resetPosition()
Resets the lexer position on the input to the given position.
public
resetPosition([int $position = 0 ]) : void
Parameters
- $position : int = 0
-
Position to place the lexical scanner.
setInput()
Sets the input data to be tokenized.
public
setInput(string $input) : void
The Lexer is immediately reset and the new input tokenized. Any unprocessed tokens from any previous input are lost.
Parameters
- $input : string
-
The input to be tokenized.
skipUntil()
Tells the lexer to skip input tokens until it sees a token with the given value.
public
skipUntil(T $type) : void
Parameters
- $type : T
-
The token type to skip until.
getCatchablePatterns()
Lexical catchable patterns.
protected
getCatchablePatterns() : array<string|int, string>
Return values
array<string|int, string>getModifiers()
Regex modifiers
protected
getModifiers() : string
Return values
stringgetNonCatchablePatterns()
Lexical non-catchable patterns.
protected
getNonCatchablePatterns() : array<string|int, string>
Return values
array<string|int, string>getType()
Retrieve token type. Also processes the token value if necessary.
protected
getType(mixed &$value) : T|null
Parameters
- $value : mixed
Return values
T|nullscan()
Scans the input string for tokens.
protected
scan(string $input) : void
Parameters
- $input : string
-
A query string.