Skip to content

Commit

Permalink
Use parentheses for assignment in conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
ydah committed Dec 23, 2023
1 parent af9d865 commit 0fc68a9
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/lrama/grammar.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def add_term(id:, alias_name: nil, tag: nil, token_id: nil, replace: false)
return sym
end

if sym = @symbols.find {|s| s.id == id }
if (sym = @symbols.find {|s| s.id == id })
return sym
end

Expand Down
4 changes: 2 additions & 2 deletions lib/lrama/grammar/rule_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def numberize_references
raise location.generate_error_message("Referring symbol `#{ref_name}` is duplicated.")
end

unless referring_symbol = candidates.first
unless (referring_symbol = candidates.first)
location = token.location.partial_location(ref.first_column, ref.last_column)
raise location.generate_error_message("Referring symbol `#{ref_name}` is not found.")
end
Expand All @@ -179,7 +179,7 @@ def numberize_references
end

def flush_user_code
if c = @user_code
if (c = @user_code)
@rhs << c
@user_code = nil
end
Expand Down
2 changes: 1 addition & 1 deletion lib/lrama/states_reporter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def report_states(io, itemsets, lookaheads, solved, counterexamples, verbose)
nl = true
end

if r = state.default_reduction_rule
if (r = state.default_reduction_rule)
nl = true
s = "$default".ljust(max_len)

Expand Down

0 comments on commit 0fc68a9

Please sign in to comment.