From 301fa452f7a9cdea922103e9c50d85a2d5652d0d Mon Sep 17 00:00:00 2001 From: mame Date: Fri, 15 Jun 2018 08:53:17 +0000 Subject: Remove flip-flop usages from build scripts git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63669 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/ripper/tools/preproc.rb | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) (limited to 'ext/ripper') diff --git a/ext/ripper/tools/preproc.rb b/ext/ripper/tools/preproc.rb index f5d0115184..7639a901df 100755 --- a/ext/ripper/tools/preproc.rb +++ b/ext/ripper/tools/preproc.rb @@ -41,6 +41,7 @@ end def prelude(f, out) @exprs = {} + lex_state_def = false while line = f.gets case line when /\A%%/ @@ -50,19 +51,25 @@ def prelude(f, out) out << line.sub(/<\w+>/, '') when /\A%type/ out << line.sub(/<\w+>/, '') + when /^enum lex_state_(?:bits|e) \{/ + lex_state_def = true + out << line + when /^\}/ + lex_state_def = false + out << line else - 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 + 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}+") + end + end end end -- cgit v1.2.3