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
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
Called from 1
Calls 2
public function tokens(string $text): list<Token>

Reads the tokens of a text, without the end marker.

Parameters

$textstring

Returns

list<Token>

Throws

InvariantViolation When the text is not lexically valid
Called from 2
Calls 4

Private surface 3§

Implementation details, listed for orientation only.

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

Relations§

Instantiated in 1
Method calls 1