ruby-changes:73926
From: yui-knk <ko1@a...>
Date: Sat, 8 Oct 2022 17:59:32 +0900 (JST)
Subject: [ruby-changes:73926] 52eaffde86 (master): Support "+error-tolerant" as ruby option
https://git.ruby-lang.org/ruby.git/commit/?id=52eaffde86 From 52eaffde8604b64279208242444894dd69780c24 Mon Sep 17 00:00:00 2001 From: yui-knk <spiketeika@g...> Date: Sun, 25 Sep 2022 21:23:17 +0900 Subject: Support "+error-tolerant" as ruby option [Feature #19013] --- ruby.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/ruby.c b/ruby.c index cefa774639..cddd9c0e3d 100644 --- a/ruby.c +++ b/ruby.c @@ -154,6 +154,7 @@ enum feature_flag_bits { https://github.com/ruby/ruby/blob/trunk/ruby.c#L154 /* END OF DUMPS */ enum dump_flag_bits { dump_version_v, + dump_error_tolerant, EACH_DUMPS(DEFINE_DUMP, COMMA), dump_exit_bits = (DUMP_BIT(yydebug) | DUMP_BIT(syntax) | DUMP_BIT(parsetree) | DUMP_BIT(parsetree_with_comment) | @@ -301,9 +302,9 @@ usage(const char *name, int help, int highlight, int columns) https://github.com/ruby/ruby/blob/trunk/ruby.c#L302 static const struct ruby_opt_message dumps[] = { M("insns", "", "instruction sequences"), M("insns_without_opt", "", "instruction sequences compiled with no optimization"), - M("yydebug", "", "yydebug of yacc parser generator"), - M("parsetree", "", "AST"), - M("parsetree_with_comment", "", "AST with comments"), + M("yydebug(+error-tolerant)", "", "yydebug of yacc parser generator"), + M("parsetree(+error-tolerant)","", "AST"), + M("parsetree_with_comment(+error-tolerant)", "", "AST with comments"), }; static const struct ruby_opt_message features[] = { M("gems", "", "rubygems (only for debugging, default: "DEFAULT_RUBYGEMS_ENABLED")"), @@ -1016,6 +1017,11 @@ static void https://github.com/ruby/ruby/blob/trunk/ruby.c#L1017 dump_option(const char *str, int len, void *arg) { static const char list[] = EACH_DUMPS(LITERAL_NAME_ELEMENT, ", "); +#define NAME_MATCH_TOLERANT_P(name) (len >= 15 && NAME_MATCH_P(#name "+error-tolerant", str, len)) + if (NAME_MATCH_TOLERANT_P(yydebug) || NAME_MATCH_TOLERANT_P(parsetree) || NAME_MATCH_TOLERANT_P(parsetree_with_comment)) { + *(unsigned int *)arg |= DUMP_BIT(error_tolerant); + len -= 15; + } #define SET_WHEN_DUMP(bit) SET_WHEN(#bit, DUMP_BIT(bit), str, len) EACH_DUMPS(SET_WHEN_DUMP, ;); rb_warn("don't know how to dump `%.*s',", len, str); @@ -1935,6 +1941,9 @@ process_options(int argc, char **argv, ruby_cmdline_options_t *opt) https://github.com/ruby/ruby/blob/trunk/ruby.c#L1941 if (opt->dump & DUMP_BIT(yydebug)) { rb_parser_set_yydebug(parser, Qtrue); } + if (opt->dump & DUMP_BIT(error_tolerant)) { + rb_parser_error_tolerant(parser); + } if (opt->ext.enc.name != 0) { opt->ext.enc.index = opt_enc_index(opt->ext.enc.name); } -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/