PHP 클래스 SqlParser\Lexer

The output of the lexer is affected by the context of the SQL statement.
또한 보기: Context
파일 보기 프로젝트 열기: phpmyadmin/sql-parser 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$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