DocLexer
extends AbstractLexer
in package
Simple lexer for docblock annotations.
Table of Contents
- T_AT = 101
- T_CLOSE_CURLY_BRACES = 102
- T_CLOSE_PARENTHESIS = 103
- T_COLON = 112
- T_COMMA = 104
- T_EQUALS = 105
- T_FALSE = 106
- T_FLOAT = 4
- T_IDENTIFIER = 100
- T_INTEGER = 2
- T_MINUS = 113
- T_NAMESPACE_SEPARATOR = 107
- T_NONE = 1
- T_NULL = 111
- T_OPEN_CURLY_BRACES = 108
- T_OPEN_PARENTHESIS = 109
- T_STRING = 3
- T_TRUE = 110
- $lookahead : array<string|int, mixed>|null
- The next token in the input.
- $token : array<string|int, mixed>|null
- The last matched/seen token.
- $noCase : array<string, int>
- $withCase : array<string, int>
- $input : string
- Lexer original input string.
- $peek : int
- Current peek of current lexer position.
- $position : int
- Current lexer position in input string.
- $regex : string
- Composed regex for input parsing.
- $tokens : array<string|int, mixed>
- Array of scanned tokens.
- 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.
- nextTokenIsAdjacent() : bool
- Whether the next token starts immediately, or if there were non-captured symbols before that
- 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, mixed>
- Lexical catchable patterns.
- getModifiers() : string
- Regex modifiers
- getNonCatchablePatterns() : array<string|int, mixed>
- Lexical non-catchable patterns.
- getType() : int|string|null
- Retrieve token type. Also processes the token value if necessary.
- scan() : void
- Scans the input string for tokens.
Constants
T_AT
public
mixed
T_AT
= 101
T_CLOSE_CURLY_BRACES
public
mixed
T_CLOSE_CURLY_BRACES
= 102
T_CLOSE_PARENTHESIS
public
mixed
T_CLOSE_PARENTHESIS
= 103
T_COLON
public
mixed
T_COLON
= 112
T_COMMA
public
mixed
T_COMMA
= 104
T_EQUALS
public
mixed
T_EQUALS
= 105
T_FALSE
public
mixed
T_FALSE
= 106
T_FLOAT
public
mixed
T_FLOAT
= 4
T_IDENTIFIER
public
mixed
T_IDENTIFIER
= 100
T_INTEGER
public
mixed
T_INTEGER
= 2
T_MINUS
public
mixed
T_MINUS
= 113
T_NAMESPACE_SEPARATOR
public
mixed
T_NAMESPACE_SEPARATOR
= 107
T_NONE
public
mixed
T_NONE
= 1
T_NULL
public
mixed
T_NULL
= 111
T_OPEN_CURLY_BRACES
public
mixed
T_OPEN_CURLY_BRACES
= 108
T_OPEN_PARENTHESIS
public
mixed
T_OPEN_PARENTHESIS
= 109
T_STRING
public
mixed
T_STRING
= 3
T_TRUE
public
mixed
T_TRUE
= 110
Properties
$lookahead
The next token in the input.
public
array<string|int, mixed>|null
$lookahead
$token
The last matched/seen token.
public
array<string|int, mixed>|null
$token
$noCase
protected
array<string, int>
$noCase
= ['@' => self::T_AT, ',' => self::T_COMMA, '(' => self::T_OPEN_PARENTHESIS, ')' => self::T_CLOSE_PARENTHESIS, '{' => self::T_OPEN_CURLY_BRACES, '}' => self::T_CLOSE_CURLY_BRACES, '=' => self::T_EQUALS, ':' => self::T_COLON, '-' => self::T_MINUS, '\' => self::T_NAMESPACE_SEPARATOR]
$withCase
protected
array<string, int>
$withCase
= ['true' => self::T_TRUE, 'false' => self::T_FALSE, 'null' => self::T_NULL]
$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
$regex
$tokens
Array of scanned tokens.
private
array<string|int, mixed>
$tokens
= []
Each token is an associative array containing three items:
- 'value' : the string value of the token in the input string
- 'type' : the type of the token (identifier, numeric, string, input parameter, none)
- 'position' : the position of the token in the input string
Methods
getInputUntilPosition()
Retrieve the original lexer's input until a given position.
public
getInputUntilPosition(int $position) : string
Parameters
- $position : int
Return values
string —getLiteral()
Gets the literal for a given token.
public
getLiteral(int|string $token) : int|string
Parameters
- $token : int|string
Return values
int|string —glimpse()
Peeks at the next token, returns it and immediately resets the peek.
public
glimpse() : array<string|int, mixed>|null
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(mixed $value, int|string $token) : bool
Parameters
- $value : mixed
- $token : int|string
Return values
bool —isNextToken()
Checks whether a given token matches the current lookahead.
public
isNextToken(int|string $token) : bool
Parameters
- $token : int|string
Return values
bool —isNextTokenAny()
Checks whether any of the given tokens matches the current lookahead.
public
isNextTokenAny(array<string|int, mixed> $tokens) : bool
Parameters
- $tokens : array<string|int, mixed>
Return values
bool —moveNext()
Moves to the next token in the input string.
public
moveNext() : bool
Return values
bool —nextTokenIsAdjacent()
Whether the next token starts immediately, or if there were non-captured symbols before that
public
nextTokenIsAdjacent() : bool
Return values
bool —peek()
Moves the lookahead token forward.
public
peek() : array<string|int, mixed>|null
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
Return values
void —resetPeek()
Resets the peek pointer to 0.
public
resetPeek() : void
Return values
void —resetPosition()
Resets the lexer position on the input to the given position.
public
resetPosition(int $position) : void
Parameters
- $position : int
-
Position to place the lexical scanner.
Return values
void —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.
Return values
void —skipUntil()
Tells the lexer to skip input tokens until it sees a token with the given value.
public
skipUntil(string $type) : void
Parameters
- $type : string
-
The token type to skip until.
Return values
void —getCatchablePatterns()
Lexical catchable patterns.
protected
getCatchablePatterns() : array<string|int, mixed>
Return values
array<string|int, mixed> —getModifiers()
Regex modifiers
protected
getModifiers() : string
Return values
string —getNonCatchablePatterns()
Lexical non-catchable patterns.
protected
getNonCatchablePatterns() : array<string|int, mixed>
Return values
array<string|int, mixed> —getType()
Retrieve token type. Also processes the token value if necessary.
protected
getType(mixed &$value) : int|string|null
Parameters
- $value : mixed
Return values
int|string|null —scan()
Scans the input string for tokens.
protected
scan(string $input) : void
Parameters
- $input : string
-
A query string.