PHP Класс SqlParser\Lexer

The output of the lexer is affected by the context of the SQL statement.
См. также: Context
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$DEFAULT_DELIMITER string The default delimiter. This is used, by default, in all new instances.
$PARSER_METHODS array A list of methods that are used in lexing the SQL query.
$delimiter string This may change during lexing.
$delimiterLen integer Because parseDelimiter can be called a lot, it would perform a lot of calls to strlen, which might affect performance when the delimiter is big.
$errors SqlParser\Exceptions\LexerException[] Usually, the lexing does not stop once an error occurred because that error might be false positive or a partial result (even a bad one) might be needed.
$last integer The index of the last parsed character.
$len integer By storing its length, a lot of time is saved, because parsing methods would call strlen everytime.
$list TokensList Tokens extracted from given strings.
$str string | UtfString The string to be parsed.
$strict boolean Whether errors should throw exceptions or just be stored.

Открытые методы

Метод Описание
__construct ( string | UtfString $str, boolean $strict = false, string $delimiter = null ) Constructor.
error ( string $msg = '', string $str = '', integer $pos, integer $code ) : void Creates a new error log.
getTokens ( string | UtfString $str, boolean $strict = false, string $delimiter = null ) : TokensList Gets the tokens list parsed by a new instance of a lexer.
lex ( ) : void Parses the string and extracts lexemes.
parseBool ( ) : Token Parses a boolean.
parseComment ( ) : Token Parses a comment.
parseDelimiter ( ) : Token Parses the delimiter of the query.
parseKeyword ( ) : Token Parses a keyword.
parseLabel ( ) : Token Parses a label.
parseNumber ( ) : Token Parses a number.
parseOperator ( ) : Token Parses an operator.
parseString ( string $quote = '' ) : Token Parses a string.
parseSymbol ( ) : Token Parses a symbol.
parseUnknown ( ) : Token Parses unknown parts of the query.
parseWhitespace ( ) : Token Parses a whitespace.
setDelimiter ( string $delimiter ) Sets the delimiter.

Описание методов

__construct() публичный Метод

Constructor.
public __construct ( string | UtfString $str, boolean $strict = false, string $delimiter = null )
$str string | UtfString The query to be lexed.
$strict boolean Whether strict mode should be enabled or not.
$delimiter string The delimiter to be used.

error() публичный Метод

Creates a new error log.
public error ( string $msg = '', string $str = '', integer $pos, integer $code ) : void
$msg string The error message.
$str string The character that produced the error.
$pos integer The position of the character.
$code integer The code of the error.
Результат void

getTokens() публичный статический Метод

Gets the tokens list parsed by a new instance of a lexer.
public static getTokens ( string | UtfString $str, boolean $strict = false, string $delimiter = null ) : TokensList
$str string | UtfString The query to be lexed.
$strict boolean Whether strict mode should be enabled or not.
$delimiter string The delimiter to be used.
Результат TokensList

lex() публичный Метод

Parses the string and extracts lexemes.
public lex ( ) : void
Результат void

parseBool() публичный Метод

Parses a boolean.
public parseBool ( ) : Token
Результат Token

parseComment() публичный Метод

Parses a comment.
public parseComment ( ) : Token
Результат Token

parseDelimiter() публичный Метод

Parses the delimiter of the query.
public parseDelimiter ( ) : Token
Результат Token

parseKeyword() публичный Метод

Parses a keyword.
public parseKeyword ( ) : Token
Результат Token

parseLabel() публичный Метод

Parses a label.
public parseLabel ( ) : Token
Результат Token

parseNumber() публичный Метод

Parses a number.
public parseNumber ( ) : Token
Результат Token

parseOperator() публичный Метод

Parses an operator.
public parseOperator ( ) : Token
Результат Token

parseString() публичный Метод

Parses a string.
public parseString ( string $quote = '' ) : Token
$quote string Additional starting symbol.
Результат Token

parseSymbol() публичный Метод

Parses a symbol.
public parseSymbol ( ) : Token
Результат Token

parseUnknown() публичный Метод

Parses unknown parts of the query.
public parseUnknown ( ) : Token
Результат Token

parseWhitespace() публичный Метод

Parses a whitespace.
public parseWhitespace ( ) : Token
Результат Token

setDelimiter() публичный Метод

Sets the delimiter.
public setDelimiter ( string $delimiter )
$delimiter string The new delimiter.

Описание свойств

$DEFAULT_DELIMITER публичное статическое свойство

The default delimiter. This is used, by default, in all new instances.
public static string $DEFAULT_DELIMITER
Результат string

$PARSER_METHODS публичное статическое свойство

A list of methods that are used in lexing the SQL query.
public static array $PARSER_METHODS
Результат array

$delimiter публичное свойство

This may change during lexing.
public string $delimiter
Результат string

$delimiterLen публичное свойство

Because parseDelimiter can be called a lot, it would perform a lot of calls to strlen, which might affect performance when the delimiter is big.
public int $delimiterLen
Результат integer

$errors публичное свойство

Usually, the lexing does not stop once an error occurred because that error might be false positive or a partial result (even a bad one) might be needed.
См. также: Lexer::error()
public LexerException[],SqlParser\Exceptions $errors
Результат SqlParser\Exceptions\LexerException[]

$last публичное свойство

The index of the last parsed character.
public int $last
Результат integer

$len публичное свойство

By storing its length, a lot of time is saved, because parsing methods would call strlen everytime.
public int $len
Результат integer

$list публичное свойство

Tokens extracted from given strings.
public TokensList,sqlparser $list
Результат TokensList

$str публичное свойство

The string to be parsed.
public string|UtfString,sqlparser $str
Результат string | UtfString

$strict публичное свойство

Whether errors should throw exceptions or just be stored.
См. также: static::$errors
public bool $strict
Результат boolean