diff options
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 |