Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Define context keywords relying on Token constants #568

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