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

Rename NULL, TRUE, and FALSE literals in SQLite grammar to successfully compile targeting c++ #1905

Merged
merged 1 commit into from
Oct 27, 2020

Conversation

KinanBab
Copy link
Contributor

@KinanBab KinanBab commented Oct 26, 2020

ANTLR runtime includes header files that define NULL via preprocessing directive, using NULL as an identifier in grammars (specifically the lexer) causes it to be used
as an identifier in the corresponding auto-generated c++ code which then fails to compile.

[edited:] We change NULL to NULL_ in SQLiteLexer.g4 and update its use in SQLiteParser.g4. We also do the same to TRUE and FALSE to avoid similar issues that may occur when compiling on windows.

This fixes #1904

@KvanTTT KvanTTT added sqlite target:cpp Grammars for C++ target, https://github.com/antlr/antlr4/blob/master/doc/cpp-target.md labels Oct 27, 2020
Copy link
Member

@KvanTTT KvanTTT left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you think that using NULL_LITERAL and others instead of NULL_, TRUE_, FALSE_ is better? We have such agreements about conflicting identifiers.

@KvanTTT KvanTTT added the symbol-conflict Rule names that conflict with keywords in certain runtimes label Oct 27, 2020
…ly compile targeting c++

ANTLR runtime includes header files that define NULL via preprocessing directive, using NULL as an identifier in grammars (specifiecally the lexer) causes it to be used
as an identifier in the corresponding autogenerated c++ code which then fails to compile.

We change NULL to NULL_ in SQLiteLexer.g4 and update its use in SQLiteParser.g4. We also do the same to TRUE and FALSE to avoid similar issues that may occur when compiling on windows.

This fixes antlr#1904
@KinanBab
Copy link
Contributor Author

KinanBab commented Oct 27, 2020

Sorry, I had originally planned to do it with just _, but the MySQL grammar you currently have uses NULL_LITERAL instead and I thought I would be consistent.

All good now, changed my PR to use NULL_, TRUE_, and FALSE_

@KinanBab KinanBab requested a review from KvanTTT October 27, 2020 15:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sqlite symbol-conflict Rule names that conflict with keywords in certain runtimes target:cpp Grammars for C++ target, https://github.com/antlr/antlr4/blob/master/doc/cpp-target.md
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SQLite grammar uses "NULL" which causes auto generated c++ code to fail to compile
2 participants