Lexer
class Lexer (View source)
Defines the lexer of the library.
This is one of the most important components, along with the parser.
Depends on context to extract lexemes.
Performs lexical analysis over a SQL statement and splits it in multiple tokens.
The output of the lexer is affected by the context of the SQL statement.
Constants
private KEYWORD_NAME_INDICATORS |
A list of keywords that indicate that the function keyword
is not used as a function |
private OPERATOR_NAME_INDICATORS |
A list of operators that indicate that the function keyword
is not used as a function |
Properties
Exception[] | $errors | List of errors that occurred during lexing. |
|
UtfString | $str | The string to be parsed. |
|
int | $len | The length of |
|
int | $last | The index of the last parsed character. |
|
TokensList | $list | Tokens extracted from given strings. |
|
static string | $defaultDelimiter | The default delimiter. This is used, by default, in all new instances. |
|
string | $delimiter | Statements delimiter. |
|
int | $delimiterLen | The length of the delimiter. |
Methods
No description
Sets the delimiter.
Parses the string and extracts lexemes.
Creates a new error log.
Parses a keyword.
Parses a label.
Parses an operator.
Parses a whitespace.
Parses a comment.
Parses a boolean.
Parses a number.
Parses a string.
Parses a symbol.
Parses unknown parts of the query.
Parses the delimiter of the query.
Details
__construct(UtfString $str, bool $strict = false, string|null $delimiter = null)
No description
void
setDelimiter(string $delimiter)
Sets the delimiter.
void
lex()
Parses the string and extracts lexemes.
void
error(string $msg, string $str = '', int $pos = 0, int $code = 0)
Creates a new error log.
Token|null
parseKeyword()
Parses a keyword.
Token|null
parseLabel()
Parses a label.
Token|null
parseOperator()
Parses an operator.
Token|null
parseWhitespace()
Parses a whitespace.
Token|null
parseComment()
Parses a comment.
Token|null
parseBool()
Parses a boolean.
Token|null
parseNumber()
Parses a number.
Token|null
parseString(string $quote = '')
Parses a string.
Token|null
parseSymbol()
Parses a symbol.
Token|null
parseUnknown()
Parses unknown parts of the query.
Token|null
parseDelimiter()
Parses the delimiter of the query.