diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2024-03-17 18:28:28 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2024-03-17 18:28:28 +0900 |
commit | 9e470ebdcd59bc2655d78a61e2a8e8bf6a4e0521 (patch) | |
tree | 5f05353d07e7429ea638a93cf5c94cfbcb4d08db /ext/ripper/tools | |
parent | 28a2105a554d875cc5c6fc2b5ac20e0e6c04966e (diff) |
Revert "Remove flip-flop usages from build scripts"
This reverts commit 301fa452f7a9cdea922103e9c50d85a2d5652d0d.
Diffstat (limited to 'ext/ripper/tools')
-rw-r--r-- | ext/ripper/tools/preproc.rb | 27 |
1 files changed, 10 insertions, 17 deletions
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} <node(?>_\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?("(") ? "<tt>#{val}</tt>" : "+#{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?("(") ? "<tt>#{val}</tt>" : "+#{val}+") + end end + out << line end end end |