class Parser extends Core (View source)

Takes multiple tokens (contained in a Lexer instance) as input and builds a parse tree.

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 array $STATEMENT_PARSERS

Array of classes that are used in parsing the SQL statements.

static array $KEYWORD_PARSERS

Array of classes that are used in parsing SQL components.

TokensList $list

The list of tokens that are parsed.

Statement[] $statements

List of statements parsed.

int $brackets

The number of opened brackets.

Methods

error(string $msg, Token|null $token = null, int $code = 0)

Creates a new error log.

__construct(string|UtfString|TokensList $list = null, bool $strict = false)

No description

parse()

Builds the parse trees.

Details

error(string $msg, Token|null $token = null, int $code = 0)

Creates a new error log.

Parameters

string $msg

the error message

Token|null $token

the token that produced the error

int $code

the code of the error

Exceptions

ParserException

throws the exception, if strict mode is enabled.

__construct(string|UtfString|TokensList $list = null, bool $strict = false)

No description

Parameters

string|UtfString|TokensList $list

the list of tokens to be parsed

bool $strict

whether strict mode should be enabled or not

parse()

Builds the parse trees.

Exceptions

ParserException