classParseTable
final class ParseTable
Restricted visibility: declared "@visibility root". Code outside that scope must not name this declaration.
The LALR(1) parse table of one grammar.
Each state has explicit actions for some symbols and a default for the rest. Looking an action up follows Lemon's order so that both generators' tables read the same way: the token itself, then the token it falls back to, then the wildcard, then the state's default.
Properties§
public SymbolTable $symbolspublic list<TableRule> $rulespublic list<int> $defaultspublic ActionRows $rowspublic array<int, int> $fallbacks = []public int|null $wildcard = nullMethods§
public function __construct(
public SymbolTable $symbols,
public list<TableRule> $rules,
public list<int> $defaults,
public ActionRows $rows,
public array<int, int> $fallbacks = [],
public int|null $wildcard = null,
)Parameters
$symbols | SymbolTable | Every symbol, numbered as the rows refer to them |
$rules | list<TableRule> | Every rule, the augmented start rule first |
$defaults | list<int> | Default action code of each state, or the error code |
$rows | ActionRows | Explicit actions of each state |
$fallbacks | array<int, int> | Terminal to retry with by the terminal that failed |
$wildcard | int|null | Terminal whose action applies to any other terminal without one |
public function action(int $state, int $symbol): intAnswers the action a state takes on a symbol.
Parameters
$state | int | State number |
$symbol | int | Terminal or nonterminal number |
Returns
int The action code, the error code when the state rejects the symbolTest cases 2
Called from 2
Calls 3
- method-call ActionRows::row() line 49
- method-call SymbolTable::terminalCount() line 57
- class-const ActionCode::ERROR() line 61
public function expectedTerminals(int $state): list<int>Answers the terminals a state has an action for, so an error can say what it expected.
Parameters
$state | int | State number |
Returns
list<int> Terminal numbers with a shift or reduce, in number orderTest cases 1
Called from 1
Calls 4
- method-call ActionRows::row() line 74
- class-const ActionCode::ERROR() line 75
- method-call SymbolTable::isTerminal() line 75
- function-call
sortline 79
public function stateCount(): intAnswers how many states the table has.
Returns
int State countTest cases 1
Called from 2
Calls 1
- function-call
countline 91
Test cases 15§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 4
Other tests reaching this symbol 11
BuildResultTest::testPropertiesAreKeptcallsParseTableBuilderTestcallsMySqlParserTestcallsLrParserTestcallsPostgreSqlParserTestcallsResourceWriterTest::testWriteTablecallsSqliteParserTestcallsTableCodecTest::testDecodeKeepsAMissingWildcardcallsTableCodecTest::testEncodeAndDecodeRoundTripcallsTableFileTest::testForgetcallsTableFileTest::testSaveAndLoadRoundTripcalls
Relations§
Instantiated in 2
Method calls 5
- method-call SqlParser\Parser\LrParser::parse() packages/sql-parser/src/Parser/LrParser.php:51
- method-call SqlParser\Parser\LrParser::parse() packages/sql-parser/src/Parser/LrParser.php:76
- method-call SqlParser\Parser\LrParser::expected() packages/sql-parser/src/Parser/LrParser.php:90
- method-call SqlParser\Table\TableCodec::encode() packages/sql-parser/src/Table/TableCodec.php:53
- method-call SqlParser\Table\TableCodec::encode() packages/sql-parser/src/Table/TableCodec.php:59
Type declarations 10
- type SqlParser\Automaton\BuildResult packages/sql-parser/src/Automaton/BuildResult.php:22
- type SqlParser\MySql\MySqlParser packages/sql-parser/src/MySql/MySqlParser.php:49
- type SqlParser\Parser\LrParser packages/sql-parser/src/Parser/LrParser.php:28
- type SqlParser\PostgreSql\PostgreSqlParser packages/sql-parser/src/PostgreSql/PostgreSqlParser.php:46
- type SqlParser\Resource\ResourceWriter packages/sql-parser/src/Resource/ResourceWriter.php:33
- type SqlParser\Sqlite\SqliteParser packages/sql-parser/src/Sqlite/SqliteParser.php:47
- type SqlParser\Table\TableCodec packages/sql-parser/src/Table/TableCodec.php:35
- type SqlParser\Table\TableCodec packages/sql-parser/src/Table/TableCodec.php:120
- type SqlParser\Table\TableFile packages/sql-parser/src/Table/TableFile.php:36
- type SqlParser\Table\TableFile packages/sql-parser/src/Table/TableFile.php:53