From 69d7871b02fedf24de381c2bc514394eed9afd32 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sun, 17 Sep 2023 15:22:11 +0900 Subject: [PATCH] ripper: Preprocess ripper-dispatchable types only Keep the other types, which not having setter macros for ripper. --- ext/ripper/tools/preproc.rb | 7 +++---- parse.y | 2 +- 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} / - out << line.sub(/<\w+>/, '') - when /\A%type/ - out << line.sub(/<\w+>/, '') + when /\A%token/, /\A%type/, /\A} / + # types in %union which have corresponding set_yylval_* macro. + out << line.sub(/<(?:node|num|id)>/, '') 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 f_kwrest f_label f_arg_asgn call_op call_op2 reswords relop dot_or_colon %type p_kwrest p_kwnorest p_any_kwrest p_kw_label %type f_no_kwarg f_any_kwrest args_forward excessed_comma nonlocal_var - %type lex_ctxt begin_defined k_class k_module /* keep in ripper */ +%type lex_ctxt begin_defined k_class k_module %token END_OF_INPUT 0 "end-of-input" %token '.' /* escaped chars, should be ignored otherwise */