aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2023-09-17 15:22:11 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2023-09-17 16:22:01 +0900
commit69d7871b02fedf24de381c2bc514394eed9afd32 (patch)
tree1bcf52b915fd2db11307e1ba19de1526fd3499e5
parentdf316be4016b0cce7aac4ccec52445d48606bf92 (diff)
downloadruby-69d7871b02fedf24de381c2bc514394eed9afd32.tar.gz
ripper: Preprocess ripper-dispatchable types only
Keep the other types, which not having setter macros for ripper.
-rw-r--r--ext/ripper/tools/preproc.rb7
-rw-r--r--parse.y2
2 files changed, 4 insertions, 5 deletions
diff --git a/ext/ripper/tools/preproc.rb b/ext/ripper/tools/preproc.rb
index 07ef627cf3..a98a60e319 100644
--- a/ext/ripper/tools/preproc.rb
+++ b/ext/ripper/tools/preproc.rb
@@ -59,10 +59,9 @@ def prelude(f, out)
when /\A%%/
out << "%%\n"
return
- when /\A%token/, /\A} <node>/
- out << line.sub(/<\w+>/, '<val>')
- when /\A%type/
- out << line.sub(/<\w+>/, '<val>')
+ when /\A%token/, /\A%type/, /\A} <node>/
+ # types in %union which have corresponding set_yylval_* macro.
+ out << line.sub(/<(?:node|num|id)>/, '<val>')
when /^enum lex_state_(?:bits|e) \{/
lex_state_def = true
out << line
diff --git a/parse.y b/parse.y
index 462ec22f61..ed9bfe6b7e 100644
--- a/parse.y
+++ b/parse.y
@@ -1627,7 +1627,7 @@ static int looking_at_eol_p(struct parser_params *p);
%type <id> f_kwrest f_label f_arg_asgn call_op call_op2 reswords relop dot_or_colon
%type <id> p_kwrest p_kwnorest p_any_kwrest p_kw_label
%type <id> f_no_kwarg f_any_kwrest args_forward excessed_comma nonlocal_var
- %type <ctxt> lex_ctxt begin_defined k_class k_module /* keep <ctxt> in ripper */
+%type <ctxt> lex_ctxt begin_defined k_class k_module
%token END_OF_INPUT 0 "end-of-input"
%token <id> '.'
/* escaped chars, should be ignored otherwise */