summaryrefslogtreecommitdiff
path: root/ext/ripper
diff options
context:
space:
mode:
Diffstat (limited to 'ext/ripper')
-rwxr-xr-xext/ripper/tools/preproc.rb27
1 files changed, 17 insertions, 10 deletions
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+>/, '<val>')
when /\A%type/
out << line.sub(/<\w+>/, '<val>')
+ 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?("(") ? "<tt>#{val}</tt>" : "+#{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?("(") ? "<tt>#{val}</tt>" : "+#{val}+")
+ end
+ end
end
end