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

Unable to compile MySQL #16

Open
lavoiesl opened this issue Apr 17, 2024 · 0 comments
Open

Unable to compile MySQL #16

lavoiesl opened this issue Apr 17, 2024 · 0 comments

Comments

@lavoiesl
Copy link

lavoiesl commented Apr 17, 2024

Trying to use the MySQL grammar: https://github.com/antlr/grammars-v4/tree/master/sql/mysql/Positive-Technologies

Using rake task and the extconf.rb from https://gist.github.com/lavoiesl/efed2ed8886b32d778c5fd30bdb16390

$ bin/rake antlr:runtime:clone # ok
$ bin/rake antlr:mysql:generate # ok


$ bin/rake antlr:mysql:compile
Running via Spring preloader in process 97444
checking for rice/rice.hpp in /Users/seb/.gem/ruby/3.2.2/gems/rice-4.3.1/include... yes
checking for -lc++... yes
checking for -lstdc++... yes
creating Makefile
compiling my_sql_parser.cpp
compiling ../lib/antlr4-cpp-runtime/Vocabulary.cpp
compiling ../lib/antlr4-cpp-runtime/WritableToken.cpp
...
compiling ../lib/antlr4-cpp-runtime/atn/LexerCustomAction.cpp
compiling ../lib/antlr4-cpp-runtime/atn/LexerIndexedCustomAction.cpp
compiling ../lib/antlr4-cpp-runtime/atn/LexerModeAction.cpp
my_sql_parser.cpp:41070:12: error: expected ')'
    return Qnil;
           ^
/opt/rubies/3.2.2/include/ruby-3.2.0/ruby/internal/special_consts.h:60:25: note: expanded from macro 'Qnil'
#define Qnil            RUBY_Qnil              /**< @old{RUBY_Qnil} */
                        ^
/opt/rubies/3.2.2/include/ruby-3.2.0/ruby/internal/special_consts.h:358:40: note: expanded from macro 'RUBY_Qnil'
#define RUBY_Qnil   RBIMPL_CAST((VALUE)RUBY_Qnil)
                                       ^
my_sql_parser.cpp:41070:12: note: to match this '('
/opt/rubies/3.2.2/include/ruby-3.2.0/ruby/internal/special_consts.h:60:25: note: expanded from macro 'Qnil'
#define Qnil            RUBY_Qnil              /**< @old{RUBY_Qnil} */
                        ^
/opt/rubies/3.2.2/include/ruby-3.2.0/ruby/internal/special_consts.h:358:21: note: expanded from macro 'RUBY_Qnil'
#define RUBY_Qnil   RBIMPL_CAST((VALUE)RUBY_Qnil)
                    ^
/opt/rubies/3.2.2/include/ruby-3.2.0/ruby/internal/cast.h:43:5: note: expanded from macro 'RBIMPL_CAST'
    (expr)                                  \
    ^
my_sql_parser.cpp:41070:12: error: reference to non-static member function must be called; did you mean to call it with no arguments?
    return Qnil;
           ^~~~
/opt/rubies/3.2.2/include/ruby-3.2.0/ruby/internal/special_consts.h:60:25: note: expanded from macro 'Qnil'
#define Qnil            RUBY_Qnil              /**< @old{RUBY_Qnil} */
                        ^~~~~~~~~
/opt/rubies/3.2.2/include/ruby-3.2.0/ruby/internal/special_consts.h:358:33: note: expanded from macro 'RUBY_Qnil'
#define RUBY_Qnil   RBIMPL_CAST((VALUE)RUBY_Qnil)
                                ^~~~~~~
/opt/rubies/3.2.2/include/ruby-3.2.0/ruby/internal/cast.h:43:6: note: expanded from macro 'RBIMPL_CAST'
    (expr)                                  \
     ^~~~
my_sql_parser.cpp:41076:12: error: expected ')'
    return Qnil;
           ^

(Many errors like that)

fatal error: too many errors emitted, stopping now [-ferror-limit=]
compiling ../lib/antlr4-cpp-runtime/atn/LexerMoreAction.cpp
compiling ../lib/antlr4-cpp-runtime/atn/LexerPopModeAction.cpp
compiling ../lib/antlr4-cpp-runtime/atn/LexerPushModeAction.cpp
compiling ../lib/antlr4-cpp-runtime/atn/LexerSkipAction.cpp
compiling ../lib/antlr4-cpp-runtime/atn/LexerTypeAction.cpp
compiling ../lib/antlr4-cpp-runtime/atn/LookaheadEventInfo.cpp
compiling ../lib/antlr4-cpp-runtime/atn/NotSetTransition.cpp
compiling ../lib/antlr4-cpp-runtime/atn/OrderedATNConfigSet.cpp
compiling ../lib/antlr4-cpp-runtime/atn/ParseInfo.cpp
compiling ../lib/antlr4-cpp-runtime/atn/ParserATNSimulator.cpp
20 errors generated.
make: *** [my_sql_parser.o] Error 1
make: *** Waiting for unfinished jobs....

You can find the full output in the Gist above.


I tested similar steps with the lua parser used in the spec of this repo and it compiles just fine.

I suspect that the MySQL grammar is generating invalid C++, but the file is enormous and I don't really speak C++.


I found #15 and antlr/grammars-v4#1905, which seem related, but the MySQL grammar already uses NULL_LITERAL and I tried renaming (TRUE|FALSE) to *_LITERAL in the lexer and parser, but it didn't change anything.

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

No branches or pull requests

1 participant