Add RB_DEFAULT_PARSER preprocessor macro
This way there is one place to change for switching the default. This also allows for building the same commit with different cppflags.
This commit is contained in:
parent
1729f47e72
commit
f2ac013009
Notes:
git
2024-08-27 23:15:57 +00:00
Merged: https://github.com/ruby/ruby/pull/11473 Merged-By: XrXr
@ -12,6 +12,13 @@
|
||||
#include "rubyparser.h"
|
||||
#include "internal/static_assert.h"
|
||||
|
||||
// The default parser to use for Ruby code.
|
||||
// 0: parse.y
|
||||
// 1: Prism
|
||||
#ifndef RB_DEFAULT_PARSER
|
||||
#define RB_DEFAULT_PARSER 0
|
||||
#endif
|
||||
|
||||
#ifdef UNIVERSAL_PARSER
|
||||
#define rb_encoding const void
|
||||
#endif
|
||||
|
6
ruby.c
6
ruby.c
@ -1428,10 +1428,10 @@ proc_long_options(ruby_cmdline_options_t *opt, const char *s, long argc, char **
|
||||
}
|
||||
else if (is_option_with_arg("parser", Qfalse, Qtrue)) {
|
||||
if (strcmp("prism", s) == 0) {
|
||||
(*rb_ruby_prism_ptr()) = true;
|
||||
*rb_ruby_prism_ptr() = true;
|
||||
}
|
||||
else if (strcmp("parse.y", s) == 0) {
|
||||
// default behavior
|
||||
*rb_ruby_prism_ptr() = false;
|
||||
}
|
||||
else {
|
||||
rb_raise(rb_eRuntimeError, "unknown parser %s", s);
|
||||
@ -3114,8 +3114,6 @@ ruby_process_options(int argc, char **argv)
|
||||
VALUE iseq;
|
||||
const char *script_name = (argc > 0 && argv[0]) ? argv[0] : ruby_engine;
|
||||
|
||||
(*rb_ruby_prism_ptr()) = false;
|
||||
|
||||
if (!origarg.argv || origarg.argc <= 0) {
|
||||
origarg.argc = argc;
|
||||
origarg.argv = argv;
|
||||
|
Loading…
x
Reference in New Issue
Block a user