remove prints in parser
This commit is contained in:
@@ -116,7 +116,6 @@ module RubyAlgebra
|
|||||||
elsif c == " "
|
elsif c == " "
|
||||||
i += 1
|
i += 1
|
||||||
else
|
else
|
||||||
puts "Unrecognized character at pos #{i}"
|
|
||||||
i += 1
|
i += 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -127,7 +126,6 @@ module RubyAlgebra
|
|||||||
operators = []
|
operators = []
|
||||||
out_stack = []
|
out_stack = []
|
||||||
tokenize(expr) do |token|
|
tokenize(expr) do |token|
|
||||||
pp token
|
|
||||||
if token.type == :num
|
if token.type == :num
|
||||||
out_stack.push(Constant.new(token.value))
|
out_stack.push(Constant.new(token.value))
|
||||||
elsif token.type == :end
|
elsif token.type == :end
|
||||||
@@ -166,9 +164,6 @@ module RubyAlgebra
|
|||||||
b = out_stack.pop if oper.type == :op
|
b = out_stack.pop if oper.type == :op
|
||||||
a = out_stack.pop
|
a = out_stack.pop
|
||||||
|
|
||||||
puts "make unary op #{oper.op} from (#{a})" if oper.type == :unary_op
|
|
||||||
puts "make binary op #{oper.op} from (#{a}), (#{b})" if oper.type == :op
|
|
||||||
|
|
||||||
case oper.op
|
case oper.op
|
||||||
when :add
|
when :add
|
||||||
out_stack.push Addition.new(a, b)
|
out_stack.push Addition.new(a, b)
|
||||||
|
|||||||
Reference in New Issue
Block a user