‪TYPO3CMS  ‪main
TYPO3\CMS\Core\Database\Schema\Parser\Parser Class Reference

Public Member Functions

 __construct (private readonly Lexer $lexer,)
 
list< Table > parse (string $statement)
 
 getAST (string $statement)
 

Private Member Functions

 match (int $token)
 
 syntaxError (string $expected='', ?Token $token=null)
 
 semanticError (string $message='')
 
 createStatement ()
 
 createTableStatement ()
 
 createTableClause ()
 
 createDefinition ()
 
 createDefinitionItem ()
 
 createIndexDefinitionItem ()
 
 createForeignKeyDefinitionItem ()
 
 indexName ()
 
 indexType ()
 
 indexOptions ()
 
 createColumnDefinitionItem ()
 
 columnDataType ()
 
 columnDefaultValue ()
 
 dataTypeLength (bool $required=false)
 
 dataTypeDecimals ()
 
 numericDataTypeOptions ()
 
 fractionalSecondsPart ()
 
 characterDataTypeOptions ()
 
 enumerationDataTypeOptions ()
 
 valueList ()
 
 valueListItem ()
 
 referenceDefinition ()
 
 indexColumnName ()
 
 referenceOption ()
 
 tableOptions ()
 
 tableOptionValue ()
 
 schemaObjectName ()
 

Private Attributes

string $statement
 

Detailed Description

An LL(*) recursive-descent parser for MySQL CREATE TABLE statements. Parses a CREATE TABLE statement, reports any errors in it, and generates an AST.

Definition at line 74 of file Parser.php.

Constructor & Destructor Documentation

◆ __construct()

TYPO3\CMS\Core\Database\Schema\Parser\Parser::__construct ( private readonly Lexer  $lexer)

Definition at line 79 of file Parser.php.

Member Function Documentation

◆ characterDataTypeOptions()

◆ columnDataType()

TYPO3\CMS\Core\Database\Schema\Parser\Parser::columnDataType ( )
private

DataType ::= BIT[(length)] | TINYINT[(length)] [UNSIGNED] [ZEROFILL] | SMALLINT[(length)] [UNSIGNED] [ZEROFILL] | MEDIUMINT[(length)] [UNSIGNED] [ZEROFILL] | INT[(length)] [UNSIGNED] [ZEROFILL] | INTEGER[(length)] [UNSIGNED] [ZEROFILL] | BIGINT[(length)] [UNSIGNED] [ZEROFILL] | REAL[(length,decimals)] [UNSIGNED] [ZEROFILL] | DOUBLE[(length,decimals)] [UNSIGNED] [ZEROFILL] | FLOAT[(length,decimals)] [UNSIGNED] [ZEROFILL] | DECIMAL[(length[,decimals])] [UNSIGNED] [ZEROFILL] | NUMERIC[(length[,decimals])] [UNSIGNED] [ZEROFILL] | DATE | TIME[(fsp)] | TIMESTAMP[(fsp)] | DATETIME[(fsp)] | YEAR | CHAR[(length)] [BINARY] [CHARACTER SET charset_name] [COLLATE collation_name] | VARCHAR(length) [BINARY] [CHARACTER SET charset_name] [COLLATE collation_name] | BINARY[(length)] | VARBINARY(length) | TINYBLOB | BLOB | MEDIUMBLOB | LONGBLOB | TINYTEXT [BINARY] [CHARACTER SET charset_name] [COLLATE collation_name] | TEXT [BINARY] [CHARACTER SET charset_name] [COLLATE collation_name] | MEDIUMTEXT [BINARY] [CHARACTER SET charset_name] [COLLATE collation_name] | LONGTEXT [BINARY] [CHARACTER SET charset_name] [COLLATE collation_name] | ENUM(value1,value2,value3,...) [CHARACTER SET charset_name] [COLLATE collation_name] | SET(value1,value2,value3,...) [CHARACTER SET charset_name] [COLLATE collation_name] | JSON

Exceptions
StatementException

Definition at line 710 of file Parser.php.

References TYPO3\CMS\Core\Database\Schema\Parser\Parser\characterDataTypeOptions(), TYPO3\CMS\Core\Database\Schema\Parser\Parser\dataTypeDecimals(), TYPO3\CMS\Core\Database\Schema\Parser\Parser\dataTypeLength(), TYPO3\CMS\Core\Database\Schema\Parser\Parser\enumerationDataTypeOptions(), TYPO3\CMS\Core\Database\Schema\Parser\Parser\fractionalSecondsPart(), TYPO3\CMS\Core\Database\Schema\Parser\Parser\match(), TYPO3\CMS\Core\Database\Schema\Parser\Parser\numericDataTypeOptions(), TYPO3\CMS\Core\Database\Schema\Parser\Parser\syntaxError(), TYPO3\CMS\Core\Database\Schema\Parser\Lexer\T_BIGINT, TYPO3\CMS\Core\Database\Schema\Parser\Lexer\T_BINARY, TYPO3\CMS\Core\Database\Schema\Parser\Lexer\T_BIT, TYPO3\CMS\Core\Database\Schema\Parser\Lexer\T_BLOB, TYPO3\CMS\Core\Database\Schema\Parser\Lexer\T_CHAR, TYPO3\CMS\Core\Database\Schema\Parser\Lexer\T_DATE, TYPO3\CMS\Core\Database\Schema\Parser\Lexer\T_DATETIME, TYPO3\CMS\Core\Database\Schema\Parser\Lexer\T_DECIMAL, TYPO3\CMS\Core\Database\Schema\Parser\Lexer\T_DOUBLE, TYPO3\CMS\Core\Database\Schema\Parser\Lexer\T_ENUM, TYPO3\CMS\Core\Database\Schema\Parser\Lexer\T_FLOAT, TYPO3\CMS\Core\Database\Schema\Parser\Lexer\T_INT, TYPO3\CMS\Core\Database\Schema\Parser\Lexer\T_INTEGER, TYPO3\CMS\Core\Database\Schema\Parser\Lexer\T_JSON, TYPO3\CMS\Core\Database\Schema\Parser\Lexer\T_LONGBLOB, TYPO3\CMS\Core\Database\Schema\Parser\Lexer\T_LONGTEXT, TYPO3\CMS\Core\Database\Schema\Parser\Lexer\T_MEDIUMBLOB, TYPO3\CMS\Core\Database\Schema\Parser\Lexer\T_MEDIUMINT, TYPO3\CMS\Core\Database\Schema\Parser\Lexer\T_MEDIUMTEXT, TYPO3\CMS\Core\Database\Schema\Parser\Lexer\T_NUMERIC, TYPO3\CMS\Core\Database\Schema\Parser\Lexer\T_PRECISION, TYPO3\CMS\Core\Database\Schema\Parser\Lexer\T_REAL, TYPO3\CMS\Core\Database\Schema\Parser\Lexer\T_SET, TYPO3\CMS\Core\Database\Schema\Parser\Lexer\T_SMALLINT, TYPO3\CMS\Core\Database\Schema\Parser\Lexer\T_TEXT, TYPO3\CMS\Core\Database\Schema\Parser\Lexer\T_TIME, TYPO3\CMS\Core\Database\Schema\Parser\Lexer\T_TIMESTAMP, TYPO3\CMS\Core\Database\Schema\Parser\Lexer\T_TINYBLOB, TYPO3\CMS\Core\Database\Schema\Parser\Lexer\T_TINYINT, TYPO3\CMS\Core\Database\Schema\Parser\Lexer\T_TINYTEXT, TYPO3\CMS\Core\Database\Schema\Parser\Lexer\T_VARBINARY, TYPO3\CMS\Core\Database\Schema\Parser\Lexer\T_VARCHAR, TYPO3\CMS\Core\Database\Schema\Parser\Lexer\T_YEAR, and TYPO3\CMS\Core\Database\Schema\Parser\Parser\valueList().

Referenced by TYPO3\CMS\Core\Database\Schema\Parser\Parser\createColumnDefinitionItem().

◆ columnDefaultValue()

◆ createColumnDefinitionItem()

TYPO3\CMS\Core\Database\Schema\Parser\Parser::createColumnDefinitionItem ( )
private

CreateColumnDefinitionItem ::= col_name column_definition

column_definition: data_type [NOT NULL | NULL] [DEFAULT default_value] [AUTO_INCREMENT] [UNIQUE [KEY] | [PRIMARY] KEY] [COMMENT 'string'] [COLUMN_FORMAT {FIXED|DYNAMIC|DEFAULT}] [STORAGE {DISK|MEMORY|DEFAULT}] [reference_definition]

Exceptions
StatementException

Definition at line 585 of file Parser.php.

References TYPO3\CMS\Core\Database\Schema\Parser\Parser\columnDataType(), TYPO3\CMS\Core\Database\Schema\Parser\Parser\columnDefaultValue(), TYPO3\CMS\Core\Database\Schema\Parser\Parser\match(), TYPO3\CMS\Core\Database\Schema\Parser\Parser\referenceDefinition(), TYPO3\CMS\Core\Database\Schema\Parser\Parser\schemaObjectName(), TYPO3\CMS\Core\Database\Schema\Parser\Parser\syntaxError(), TYPO3\CMS\Core\Database\Schema\Parser\Lexer\T_AUTO_INCREMENT, TYPO3\CMS\Core\Database\Schema\Parser\Lexer\T_CLOSE_PARENTHESIS, TYPO3\CMS\Core\Database\Schema\Parser\Lexer\T_COLUMN_FORMAT, TYPO3\CMS\Core\Database\Schema\Parser\Lexer\T_COMMA, TYPO3\CMS\Core\Database\Schema\Parser\Lexer\T_COMMENT, TYPO3\CMS\Core\Database\Schema\Parser\Lexer\T_DEFAULT, TYPO3\CMS\Core\Database\Schema\Parser\Lexer\T_DISK, TYPO3\CMS\Core\Database\Schema\Parser\Lexer\T_DYNAMIC, TYPO3\CMS\Core\Database\Schema\Parser\Lexer\T_FIXED, TYPO3\CMS\Core\Database\Schema\Parser\Lexer\T_KEY, TYPO3\CMS\Core\Database\Schema\Parser\Lexer\T_MEMORY, TYPO3\CMS\Core\Database\Schema\Parser\Lexer\T_NOT, TYPO3\CMS\Core\Database\Schema\Parser\Lexer\T_NULL, TYPO3\CMS\Core\Database\Schema\Parser\Lexer\T_PRIMARY, TYPO3\CMS\Core\Database\Schema\Parser\Lexer\T_REFERENCES, TYPO3\CMS\Core\Database\Schema\Parser\Lexer\T_STORAGE, TYPO3\CMS\Core\Database\Schema\Parser\Lexer\T_STRING, and TYPO3\CMS\Core\Database\Schema\Parser\Lexer\T_UNIQUE.

Referenced by TYPO3\CMS\Core\Database\Schema\Parser\Parser\createDefinitionItem().

◆ createDefinition()

TYPO3\CMS\Core\Database\Schema\Parser\Parser::createDefinition ( )
private

Parses the table field/index definition

createDefinition ::= ( col_name column_definition | [CONSTRAINT [symbol]] PRIMARY KEY index_type [index_option] ... | {INDEX|KEY} [index_name] index_type [index_option] ... | [CONSTRAINT [symbol]] UNIQUE [INDEX|KEY] [index_name] index_type [index_option] ... | {FULLTEXT|SPATIAL} [INDEX|KEY] index_name [index_option] ... | [CONSTRAINT [symbol]] FOREIGN KEY index_name reference_definition | CHECK (expr) )

Exceptions
StatementException

Definition at line 288 of file Parser.php.

References TYPO3\CMS\Core\Database\Schema\Parser\Parser\createDefinitionItem(), TYPO3\CMS\Core\Database\Schema\Parser\Parser\match(), TYPO3\CMS\Core\Database\Schema\Parser\Lexer\T_CLOSE_PARENTHESIS, TYPO3\CMS\Core\Database\Schema\Parser\Lexer\T_COMMA, and TYPO3\CMS\Core\Database\Schema\Parser\Lexer\T_OPEN_PARENTHESIS.

Referenced by TYPO3\CMS\Core\Database\Schema\Parser\Parser\createTableStatement().

◆ createDefinitionItem()

◆ createForeignKeyDefinitionItem()

◆ createIndexDefinitionItem()

◆ createStatement()

◆ createTableClause()

◆ createTableStatement()

TYPO3\CMS\Core\Database\Schema\Parser\Parser::createTableStatement ( )
private

CreateTableStatement ::= CREATE [TEMPORARY] TABLE [IF NOT EXISTS] tbl_name (create_definition,...) [tbl_options]

Exceptions
StatementException

Definition at line 235 of file Parser.php.

References TYPO3\CMS\Core\Database\Schema\Parser\Parser\createDefinition(), TYPO3\CMS\Core\Database\Schema\Parser\Parser\createTableClause(), TYPO3\CMS\Core\Database\Schema\Parser\Lexer\T_SEMICOLON, and TYPO3\CMS\Core\Database\Schema\Parser\Parser\tableOptions().

Referenced by TYPO3\CMS\Core\Database\Schema\Parser\Parser\createStatement().

◆ dataTypeDecimals()

TYPO3\CMS\Core\Database\Schema\Parser\Parser::dataTypeDecimals ( )
private

◆ dataTypeLength()

◆ enumerationDataTypeOptions()

◆ fractionalSecondsPart()

TYPO3\CMS\Core\Database\Schema\Parser\Parser::fractionalSecondsPart ( )
private

Determine the fractional seconds part support for TIME, DATETIME and TIMESTAMP columns

Exceptions
StatementException

Definition at line 1005 of file Parser.php.

References TYPO3\CMS\Core\Database\Schema\Parser\Parser\dataTypeLength(), and TYPO3\CMS\Core\Database\Schema\Parser\Parser\semanticError().

Referenced by TYPO3\CMS\Core\Database\Schema\Parser\Parser\columnDataType().

◆ getAST()

TYPO3\CMS\Core\Database\Schema\Parser\Parser::getAST ( string  $statement)

◆ indexColumnName()

◆ indexName()

TYPO3\CMS\Core\Database\Schema\Parser\Parser::indexName ( )
private

◆ indexOptions()

◆ indexType()

◆ match()

TYPO3\CMS\Core\Database\Schema\Parser\Parser::match ( int  $token)
private

Attempts to match the given token with the current lookahead token.

If they match, updates the lookahead token; otherwise raises a syntax error.

Parameters
int$token‪The token type.
Exceptions
StatementException‪If the tokens don't match.

Definition at line 135 of file Parser.php.

References TYPO3\CMS\Core\Database\Schema\Parser\Parser\syntaxError(), TYPO3\CMS\Core\Database\Schema\Parser\Lexer\T_DELETE, TYPO3\CMS\Core\Database\Schema\Parser\Lexer\T_FULL, TYPO3\CMS\Core\Database\Schema\Parser\Lexer\T_IDENTIFIER, TYPO3\CMS\Core\Database\Schema\Parser\Lexer\T_MATCH, TYPO3\CMS\Core\Database\Schema\Parser\Lexer\T_ON, TYPO3\CMS\Core\Database\Schema\Parser\Lexer\T_PARTIAL, TYPO3\CMS\Core\Database\Schema\Parser\Lexer\T_SIMPLE, and TYPO3\CMS\Core\Database\Schema\Parser\Lexer\T_UPDATE.

Referenced by TYPO3\CMS\Core\Database\Schema\Parser\Parser\characterDataTypeOptions(), TYPO3\CMS\Core\Database\Schema\Parser\Parser\columnDataType(), TYPO3\CMS\Core\Database\Schema\Parser\Parser\columnDefaultValue(), TYPO3\CMS\Core\Database\Schema\Parser\Parser\createColumnDefinitionItem(), TYPO3\CMS\Core\Database\Schema\Parser\Parser\createDefinition(), TYPO3\CMS\Core\Database\Schema\Parser\Parser\createForeignKeyDefinitionItem(), TYPO3\CMS\Core\Database\Schema\Parser\Parser\createIndexDefinitionItem(), TYPO3\CMS\Core\Database\Schema\Parser\Parser\createStatement(), TYPO3\CMS\Core\Database\Schema\Parser\Parser\createTableClause(), TYPO3\CMS\Core\Database\Schema\Parser\Parser\dataTypeDecimals(), TYPO3\CMS\Core\Database\Schema\Parser\Parser\dataTypeLength(), TYPO3\CMS\Core\Database\Schema\Parser\Parser\enumerationDataTypeOptions(), TYPO3\CMS\Core\Database\Schema\Parser\Parser\indexColumnName(), TYPO3\CMS\Core\Database\Schema\Parser\Parser\indexOptions(), TYPO3\CMS\Core\Database\Schema\Parser\Parser\indexType(), TYPO3\CMS\Core\Database\Schema\Parser\Parser\numericDataTypeOptions(), TYPO3\CMS\Core\Database\Schema\Parser\Parser\referenceDefinition(), TYPO3\CMS\Core\Database\Schema\Parser\Parser\referenceOption(), TYPO3\CMS\Core\Database\Schema\Parser\Parser\tableOptions(), TYPO3\CMS\Core\Database\Schema\Parser\Parser\tableOptionValue(), TYPO3\CMS\Core\Database\Schema\Parser\Parser\valueList(), and TYPO3\CMS\Core\Database\Schema\Parser\Parser\valueListItem().

◆ numericDataTypeOptions()

TYPO3\CMS\Core\Database\Schema\Parser\Parser::numericDataTypeOptions ( )
private

◆ parse()

list<Table> TYPO3\CMS\Core\Database\Schema\Parser\Parser::parse ( string  $statement)

Parses a statement string.

Returns
‪list<Table>
Exceptions
SchemaException

Definition at line 92 of file Parser.php.

References TYPO3\CMS\Core\Database\Schema\Parser\Parser\getAST().

◆ referenceDefinition()

◆ referenceOption()

◆ schemaObjectName()

TYPO3\CMS\Core\Database\Schema\Parser\Parser::schemaObjectName ( )
private

◆ semanticError()

TYPO3\CMS\Core\Database\Schema\Parser\Parser::semanticError ( string  $message = '')
private

◆ syntaxError()

◆ tableOptions()

TYPO3\CMS\Core\Database\Schema\Parser\Parser::tableOptions ( )
private

Parse MySQL table options

ENGINE [=] engine_name | AUTO_INCREMENT [=] value | AVG_ROW_LENGTH [=] value | [DEFAULT] CHARACTER SET [=] charset_name | CHECKSUM [=] {0 | 1} | [DEFAULT] COLLATE [=] collation_name | COMMENT [=] 'string' | COMPRESSION [=] {'ZLIB'|'LZ4'|'NONE'} | CONNECTION [=] 'connect_string' | DATA DIRECTORY [=] 'absolute path to directory' | DELAY_KEY_WRITE [=] {0 | 1} | ENCRYPTION [=] {'Y' | 'N'} | INDEX DIRECTORY [=] 'absolute path to directory' | INSERT_METHOD [=] { NO | FIRST | LAST } | KEY_BLOCK_SIZE [=] value | MAX_ROWS [=] value | MIN_ROWS [=] value | PACK_KEYS [=] {0 | 1 | DEFAULT} | PASSWORD [=] 'string' | ROW_FORMAT [=] {DEFAULT|DYNAMIC|FIXED|COMPRESSED|REDUNDANT|COMPACT} | STATS_AUTO_RECALC [=] {DEFAULT|0|1} | STATS_PERSISTENT [=] {DEFAULT|0|1} | STATS_SAMPLE_PAGES [=] value | TABLESPACE tablespace_name | UNION =

Exceptions
StatementException

Definition at line 1262 of file Parser.php.

References TYPO3\CMS\Core\Database\Schema\Parser\Parser\match(), TYPO3\CMS\Core\Database\Schema\Parser\Parser\syntaxError(), TYPO3\CMS\Core\Database\Schema\Parser\Lexer\T_AUTO_INCREMENT, TYPO3\CMS\Core\Database\Schema\Parser\Lexer\T_AVG_ROW_LENGTH, TYPO3\CMS\Core\Database\Schema\Parser\Lexer\T_CHARACTER, TYPO3\CMS\Core\Database\Schema\Parser\Lexer\T_CHECKSUM, TYPO3\CMS\Core\Database\Schema\Parser\Lexer\T_COLLATE, TYPO3\CMS\Core\Database\Schema\Parser\Lexer\T_COMMENT, TYPO3\CMS\Core\Database\Schema\Parser\Lexer\T_COMPRESSION, TYPO3\CMS\Core\Database\Schema\Parser\Lexer\T_CONNECTION, TYPO3\CMS\Core\Database\Schema\Parser\Lexer\T_DATA, TYPO3\CMS\Core\Database\Schema\Parser\Lexer\T_DEFAULT, TYPO3\CMS\Core\Database\Schema\Parser\Lexer\T_DELAY_KEY_WRITE, TYPO3\CMS\Core\Database\Schema\Parser\Lexer\T_DIRECTORY, TYPO3\CMS\Core\Database\Schema\Parser\Lexer\T_ENCRYPTION, TYPO3\CMS\Core\Database\Schema\Parser\Lexer\T_ENGINE, TYPO3\CMS\Core\Database\Schema\Parser\Lexer\T_INDEX, TYPO3\CMS\Core\Database\Schema\Parser\Lexer\T_INSERT_METHOD, TYPO3\CMS\Core\Database\Schema\Parser\Lexer\T_KEY_BLOCK_SIZE, TYPO3\CMS\Core\Database\Schema\Parser\Lexer\T_MAX_ROWS, TYPO3\CMS\Core\Database\Schema\Parser\Lexer\T_MIN_ROWS, TYPO3\CMS\Core\Database\Schema\Parser\Lexer\T_PACK_KEYS, TYPO3\CMS\Core\Database\Schema\Parser\Lexer\T_PASSWORD, TYPO3\CMS\Core\Database\Schema\Parser\Lexer\T_ROW_FORMAT, TYPO3\CMS\Core\Database\Schema\Parser\Lexer\T_SEMICOLON, TYPO3\CMS\Core\Database\Schema\Parser\Lexer\T_SET, TYPO3\CMS\Core\Database\Schema\Parser\Lexer\T_STATS_AUTO_RECALC, TYPO3\CMS\Core\Database\Schema\Parser\Lexer\T_STATS_PERSISTENT, TYPO3\CMS\Core\Database\Schema\Parser\Lexer\T_STATS_SAMPLE_PAGES, TYPO3\CMS\Core\Database\Schema\Parser\Lexer\T_TABLESPACE, and TYPO3\CMS\Core\Database\Schema\Parser\Parser\tableOptionValue().

Referenced by TYPO3\CMS\Core\Database\Schema\Parser\Parser\createTableStatement().

◆ tableOptionValue()

TYPO3\CMS\Core\Database\Schema\Parser\Parser::tableOptionValue ( )
private

Return the value of an option, skipping the optional equal sign.

Exceptions
StatementException

Definition at line 1418 of file Parser.php.

References TYPO3\CMS\Core\Database\Schema\Parser\Parser\match(), and TYPO3\CMS\Core\Database\Schema\Parser\Lexer\T_EQUALS.

Referenced by TYPO3\CMS\Core\Database\Schema\Parser\Parser\tableOptions().

◆ valueList()

◆ valueListItem()

TYPO3\CMS\Core\Database\Schema\Parser\Parser::valueListItem ( )
private

Return a value list item for an enumeration set

Exceptions
StatementException

Definition at line 1116 of file Parser.php.

References TYPO3\CMS\Core\Database\Schema\Parser\Parser\match(), and TYPO3\CMS\Core\Database\Schema\Parser\Lexer\T_STRING.

Referenced by TYPO3\CMS\Core\Database\Schema\Parser\Parser\valueList().

Member Data Documentation

◆ $statement

string TYPO3\CMS\Core\Database\Schema\Parser\Parser::$statement
private