From 9e470ebdcd59bc2655d78a61e2a8e8bf6a4e0521 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sun, 17 Mar 2024 18:28:28 +0900 Subject: Revert "Remove flip-flop usages from build scripts" This reverts commit 301fa452f7a9cdea922103e9c50d85a2d5652d0d. --- ext/ripper/tools/preproc.rb | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) (limited to 'ext/ripper/tools') diff --git a/ext/ripper/tools/preproc.rb b/ext/ripper/tools/preproc.rb index 981237a585..a36c98689b 100644 --- a/ext/ripper/tools/preproc.rb +++ b/ext/ripper/tools/preproc.rb @@ -53,7 +53,6 @@ end def prelude(f, out) @exprs = {} - lex_state_def = false while line = f.gets case line when /\A%%/ @@ -62,24 +61,18 @@ def prelude(f, out) when /\A%token/, /\A%type/, /\A} _\w+)?>/ # types in %union which have corresponding set_yylval_* macro. out << line - when /^enum lex_state_(?:bits|e) \{/ - lex_state_def = true - out << line - when /^\}/ - lex_state_def = false - out << line else - out << line - end - if lex_state_def - case line - when /^\s*(EXPR_\w+),\s+\/\*(.+)\*\// - @exprs[$1.chomp("_bit")] = $2.strip - when /^\s*(EXPR_\w+)\s+=\s+(.+)$/ - name = $1 - val = $2.chomp(",") - @exprs[name] = "equals to " + (val.start_with?("(") ? "#{val}" : "+#{val}+") + if (/^enum lex_state_(?:bits|e) \{/ =~ line)..(/^\}/ =~ line) + case line + when /^\s*(EXPR_\w+),\s+\/\*(.+)\*\// + @exprs[$1.chomp("_bit")] = $2.strip + when /^\s*(EXPR_\w+)\s+=\s+(.+)$/ + name = $1 + val = $2.chomp(",") + @exprs[name] = "equals to " + (val.start_with?("(") ? "#{val}" : "+#{val}+") + end end + out << line end end end -- cgit v1.2.3