Skip to content

Commit

Permalink
Fix bracket matching so make^perf works
Browse files Browse the repository at this point in the history
  • Loading branch information
wgmyers committed May 16, 2021
1 parent a3fb9fd commit ca801cc
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions impls/ruby-wgm/reader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -218,14 +218,16 @@ def expand_macros(tok_arr)
if in_macro.positive?
case item
# When we're in a macro, we need to start counting brackets
when '(', '['
when '(', '[', '{'
in_brackets += 1
else
if in_brackets.positive?
if (item == ')') || (item == ']')
ret_arr.push(')')
if [')', ']', '}'].include?(item)
in_brackets -= 1
in_macro -= 1
if in_brackets.zero?
ret_arr.push(')')
in_macro -= 1
end
elsif (in_brackets < in_macro) || last_was_macro
# Handle nested macros+brackets here.
# * If macro depth is greater than bracket depth, we have an
Expand Down

0 comments on commit ca801cc

Please sign in to comment.