final class Spellings
Restricted visibility: declared "@visibility SqlSemantics". Code outside that scope must not name this declaration.

Checks that the layouts of a rendering only re-spelled the rendered tokens.

Rule: CORE-SPELLING-001 (validation part). The SQL as the structure renders it and the SQL as the layouts spell it are read by the parser of the profile. Both must have the same number of tokens, and the comparison keys of the token correspondence check, which depend on the production and position of each token, must be equal position by position. A layout therefore cannot add, drop or change a significant token, its gaps can only hold whitespace and comments, and a spelling counts as the same token only where the database reads it as the same request. Status: Implemented.

Methods§

public function __construct(
    private SqlParser $parser,
    private Productions $productions,
    private LeafKeys $keys,
)

Parameters

$parserSqlParserThe parser of the profile
$productionsProductionsThe productions of the grammar release
$keysLeafKeysThe token rules of the profile
public function check(string $rendered, string $spelled): void

Refuses a spelled SQL text whose tokens are not those of the rendered SQL text.

Parameters

$renderedstring
$spelledstring

Throws

InvariantViolation When a layout changed a token or wrote a token into a gap
Test cases 3
Called from 1
Calls 7
public function tree(string $text): Node

Parses a rendered or spelled text.

Parameters

$textstring

Returns

Node

Throws

InvariantViolation When the text is outside the grammar
Test cases 1
Called from 1
Calls 2
public function tokens(string $text): list<Token>

Private surface 3§

Implementation details, listed for orientation only.

private SqlParser $parser
private Productions $productions
private LeafKeys $keys

Test cases 5§

Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.

Dedicated tests 5

Relations§

Instantiated in 1
Method calls 1