lib/kaiser_ruby/rockstar_transform.rb in kaiser-ruby-0.4.1 vs lib/kaiser_ruby/rockstar_transform.rb in kaiser-ruby-0.4.2
- old
+ new
@@ -49,10 +49,10 @@
rule(division: { left: simple(:left), right: simple(:right) }) { "#{left} / #{right}" }
rule(print: { output: simple(:output) }) { "puts #{output}" }
rule(continue: simple(:_)) { "next" }
rule(break: simple(:_)) { "break" }
- rule(input_variable: simple(:var)) { "print '> '\n#{var} = STDIN.gets.chomp" }
+ rule(input_variable: simple(:var)) { "print '> '\n__input = STDIN.gets.chomp\n#{var} = Integer(__input) rescue input" }
rule(equals: { left: simple(:left), right: simple(:right) }) { "#{left} == #{right}" }
rule(not_equals: { left: simple(:left), right: simple(:right) }) { "#{left} != #{right}" }
rule(gt: { left: simple(:left), right: simple(:right) }) { "#{left} > #{right}" }
rule(gte: { left: simple(:left), right: simple(:right) }) { "#{left} >= #{right}" }