Lexer
class Lexer extends Core (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.
Properties
bool | $strict | Whether errors should throw exceptions or just be stored. |
from Core |
Exception[] | $errors | List of errors that occurred during lexing. |
from Core |
static string[] | $PARSER_METHODS | A list of methods that are used in lexing the SQL query. |
|
string|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 | $DEFAULT_DELIMITER | The default delimiter. This is used, by default, in all new instances. |
|
string | $delimiter | Statements delimiter. |
|
int | $delimiterLen | The length of the delimiter. |
Methods
Creates a new error log.
Sets the delimiter.
Parses the string and extracts lexemes.
Parses a keyword.
Parses a label.
Parses an operator.
Parses a whitespace.
Parses a comment.
Parses a number.
Parses a string.
Parses a symbol.
Parses unknown parts of the query.
Parses the delimiter of the query.
Details
void
error(string $msg, string $str = '', int $pos = 0, int $code = 0)
Creates a new error log.
static TokensList
getTokens(string|UtfString $str, bool $strict = false, string $delimiter = null)
Gets the tokens list parsed by a new instance of a lexer.
__construct(string|UtfString $str, bool $strict = false, string $delimiter = null)
No description
void
setDelimiter(string $delimiter)
Sets the delimiter.
void
lex()
Parses the string and extracts lexemes.
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.