Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Define context keywords relying on Token constants#568

Closed
Tithugues wants to merge 1 commit intophpmyadmin:masterphpmyadmin/sql-parser:masterfrom
Tithugues:feature/define-context-keywords-relying-on-token-constantsTithugues/sql-parser:feature/define-context-keywords-relying-on-token-constantsCopy head branch name to clipboard
Closed

Define context keywords relying on Token constants#568
Tithugues wants to merge 1 commit intophpmyadmin:masterphpmyadmin/sql-parser:masterfrom
Tithugues:feature/define-context-keywords-relying-on-token-constantsTithugues/sql-parser:feature/define-context-keywords-relying-on-token-constantsCopy head branch name to clipboard

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

Morty Proxy This is a proxified and sanitized view of the page, visit original site.