class Parser extends Core (View source)

Defines the parser of the library.

This is one of the most important components, along with the lexer.

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<string,string> $STATEMENT_PARSERS

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

static array<string,array<string,string|array<string,string>>> $KEYWORD_PARSERS

Array of classes that are used in parsing SQL components.

TokensList|null $list

The list of tokens that are parsed.

Statement[] $statements

List of statements parsed.

int $brackets

The number of opened brackets.

Methods

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

Creates a new error log.

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

No description

void
parse()

Builds the parse trees.

Details

void 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

Return Value

void

Exceptions

ParserException

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

No description

Parameters

string|UtfString|TokensList|null $list

the list of tokens to be parsed

bool $strict

whether strict mode should be enabled or not

void parse()

Builds the parse trees.

Return Value

void

Exceptions

ParserException