Skip to content

Comments

Define context keywords relying on Token constants#568

Closed
Tithugues wants to merge 1 commit intophpmyadmin:masterfrom
Tithugues:feature/define-context-keywords-relying-on-token-constants
Closed

Define context keywords relying on Token constants#568
Tithugues wants to merge 1 commit intophpmyadmin:masterfrom
Tithugues:feature/define-context-keywords-relying-on-token-constants

Conversation

@Tithugues
Copy link
Contributor

I always had issues to understand the "magic" keyword integers of the Context* files. Would it make sense to rely on Token constants to define them?

Additionally, I added a variable for the default bit needed for all keywords.

@M393
Copy link

M393 commented Aug 2, 2024

These files are autogenerated with https://github.com/phpmyadmin/sql-parser/blob/master/tools/run_generators.sh

This is the code that prints the keywords:

foreach ($words as $type => $wordsByType) {
foreach ($wordsByType as $len => $wordsByLen) {
$count = round(($line - $spaces) / ($len + 9)); // strlen("'' => 1, ") = 9
$i = 0;
foreach ($wordsByLen as $word) {
if ($i === 0) {
$ret .= str_repeat(' ', $spaces);
}
$ret .= sprintf('\'%s\' => %s, ', $word, $type);
if (++$i !== $count && ++$i <= $count) {
continue;
}

@Tithugues
Copy link
Contributor Author

OK, thanks. Then I’ll take a look at the generator. 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants