Skip to content

Commit

Permalink
Raise Trxl::InvalidArgumentError if division LHS is NULL
Browse files Browse the repository at this point in the history
  • Loading branch information
snusnu committed May 8, 2012
1 parent 1b9b89b commit 49d9ad6
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 46 deletions.
2 changes: 1 addition & 1 deletion lib/trxl/trxl_grammar.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3382,7 +3382,7 @@ module Multitive2
def eval(env = Environment.new)
# left associative evaluation
multitives(env).inject(exponential.eval(env)) do |operand, next_op|
op = (next_op[0].text_value == '/' ? operand.to_f : operand)
op = (next_op[0].text_value == '/' ? (operand ? operand.to_f : nil) : operand)
next_op[0].apply(op, next_op[1])
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/trxl/trxl_grammar.treetop
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ grammar Trxl
def eval(env = Environment.new)
# left associative evaluation
multitives(env).inject(exponential.eval(env)) do |operand, next_op|
op = (next_op[0].text_value == '/' ? operand.to_f : operand)
op = (next_op[0].text_value == '/' ? (operand ? operand.to_f : nil) : operand)
next_op[0].apply(op, next_op[1])
end
end
Expand Down
Loading

0 comments on commit 49d9ad6

Please sign in to comment.