PHP Class SqlParser\Lexer

The output of the lexer is affected by the context of the SQL statement.
See also: Context
Afficher le fichier Open project: phpmyadmin/sql-parser Class Usage Examples

Méthodes publiques

Свойство Type Description
$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.

Méthodes publiques

Méthode Description
__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.

Method Details

__construct() public méthode

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() public méthode

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.
Résultat void

getTokens() public static méthode

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.
Résultat TokensList

lex() public méthode

Parses the string and extracts lexemes.
public lex ( ) : void
Résultat void

parseBool() public méthode

Parses a boolean.
public parseBool ( ) : Token
Résultat Token

parseComment() public méthode

Parses a comment.
public parseComment ( ) : Token
Résultat Token

parseDelimiter() public méthode

Parses the delimiter of the query.
public parseDelimiter ( ) : Token
Résultat Token

parseKeyword() public méthode

Parses a keyword.
public parseKeyword ( ) : Token
Résultat Token

parseLabel() public méthode

Parses a label.
public parseLabel ( ) : Token
Résultat Token

parseNumber() public méthode

Parses a number.
public parseNumber ( ) : Token
Résultat Token

parseOperator() public méthode

Parses an operator.
public parseOperator ( ) : Token
Résultat Token

parseString() public méthode

Parses a string.
public parseString ( string $quote = '' ) : Token
$quote string Additional starting symbol.
Résultat Token

parseSymbol() public méthode

Parses a symbol.
public parseSymbol ( ) : Token
Résultat Token

parseUnknown() public méthode

Parses unknown parts of the query.
public parseUnknown ( ) : Token
Résultat Token

parseWhitespace() public méthode

Parses a whitespace.
public parseWhitespace ( ) : Token
Résultat Token

setDelimiter() public méthode

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

Property Details

$DEFAULT_DELIMITER public_oe static_oe property

The default delimiter. This is used, by default, in all new instances.
public static string $DEFAULT_DELIMITER
Résultat string

$PARSER_METHODS public_oe static_oe property

A list of methods that are used in lexing the SQL query.
public static array $PARSER_METHODS
Résultat array

$delimiter public_oe property

This may change during lexing.
public string $delimiter
Résultat string

$delimiterLen public_oe property

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
Résultat integer

$errors public_oe property

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.
See also: Lexer::error()
public LexerException[],SqlParser\Exceptions $errors
Résultat SqlParser\Exceptions\LexerException[]

$last public_oe property

The index of the last parsed character.
public int $last
Résultat integer

$len public_oe property

By storing its length, a lot of time is saved, because parsing methods would call strlen everytime.
public int $len
Résultat integer

$list public_oe property

Tokens extracted from given strings.
public TokensList,sqlparser $list
Résultat TokensList

$str public_oe property

The string to be parsed.
public string|UtfString,sqlparser $str
Résultat string | UtfString

$strict public_oe property

Whether errors should throw exceptions or just be stored.
See also: static::$errors
public bool $strict
Résultat boolean