#
# DO NOT MODIFY!!!!
# This file is automatically generated by racc 1.4.4
# from racc grammer file "calc3.racc".
#

require 'racc/parser'


#
# generated by racc
#
require 'calc3.rex'


class Calculator3 < Racc::Parser

##### racc 1.4.4 generates ###

racc_reduce_table = [
 0, 0, :racc_error,
 1, 11, :_reduce_none,
 0, 11, :_reduce_2,
 3, 12, :_reduce_3,
 3, 12, :_reduce_4,
 3, 12, :_reduce_5,
 3, 12, :_reduce_6,
 3, 12, :_reduce_7,
 2, 12, :_reduce_8,
 1, 12, :_reduce_none ]

racc_reduce_n = 10

racc_shift_n = 19

racc_action_table = [
     7,     8,     9,    10,     6,    18,     3,     4,    11,     5,
     7,     8,     9,    10,     3,     4,    13,     5,     3,     4,
   nil,     5,     3,     4,   nil,     5,     3,     4,   nil,     5,
     3,     4,   nil,     5,     7,     8,     7,     8 ]

racc_action_check = [
    12,    12,    12,    12,     1,    12,    10,    10,     3,    10,
     2,     2,     2,     2,     0,     0,     6,     0,     4,     4,
   nil,     4,     9,     9,   nil,     9,     8,     8,   nil,     8,
     7,     7,   nil,     7,    17,    17,    16,    16 ]

racc_action_pointer = [
     8,     4,     7,    -1,    12,   nil,    16,    24,    20,    16,
     0,   nil,    -3,   nil,   nil,   nil,    33,    31,   nil ]

racc_action_default = [
    -2,   -10,    -1,   -10,   -10,    -9,   -10,   -10,   -10,   -10,
   -10,    -8,   -10,    19,    -5,    -6,    -3,    -4,    -7 ]

racc_goto_table = [
     2,     1,   nil,   nil,    12,   nil,   nil,    14,    15,    16,
    17 ]

racc_goto_check = [
     2,     1,   nil,   nil,     2,   nil,   nil,     2,     2,     2,
     2 ]

racc_goto_pointer = [
   nil,     1,     0 ]

racc_goto_default = [
   nil,   nil,   nil ]

racc_token_table = {
 false => 0,
 Object.new => 1,
 :UMINUS => 2,
 "*" => 3,
 "/" => 4,
 "+" => 5,
 "-" => 6,
 "(" => 7,
 ")" => 8,
 :NUMBER => 9 }

racc_use_result_var = false

racc_nt_base = 10

Racc_arg = [
 racc_action_table,
 racc_action_check,
 racc_action_default,
 racc_action_pointer,
 racc_goto_table,
 racc_goto_check,
 racc_goto_default,
 racc_goto_pointer,
 racc_nt_base,
 racc_reduce_table,
 racc_token_table,
 racc_shift_n,
 racc_reduce_n,
 racc_use_result_var ]

Racc_token_to_s_table = [
'$end',
'error',
'UMINUS',
'"*"',
'"/"',
'"+"',
'"-"',
'"("',
'")"',
'NUMBER',
'$start',
'target',
'exp']

Racc_debug_parser = false

##### racc system variables end #####

 # reduce 0 omitted

 # reduce 1 omitted

module_eval <<'.,.,', 'calc3.racc', 13
  def _reduce_2( val, _values)
 0
  end
.,.,

module_eval <<'.,.,', 'calc3.racc', 15
  def _reduce_3( val, _values)
 val[0] + val[2]
  end
.,.,

module_eval <<'.,.,', 'calc3.racc', 16
  def _reduce_4( val, _values)
 val[0] - val[2]
  end
.,.,

module_eval <<'.,.,', 'calc3.racc', 17
  def _reduce_5( val, _values)
 val[0] * val[2]
  end
.,.,

module_eval <<'.,.,', 'calc3.racc', 18
  def _reduce_6( val, _values)
 val[0] / val[2]
  end
.,.,

module_eval <<'.,.,', 'calc3.racc', 19
  def _reduce_7( val, _values)
 val[1]
  end
.,.,

module_eval <<'.,.,', 'calc3.racc', 20
  def _reduce_8( val, _values)
 -(val[1])
  end
.,.,

 # reduce 9 omitted

 def _reduce_none( val, _values)
  val[0]
 end

end   # class Calculator3


puts 'sample calc'
puts '"q" to quit.'
calc = Calculator3.new
while true
  print '>>> '; $stdout.flush
  str = $stdin.gets.strip
  break if /q/i === str
  begin
    p calc.scan_str(str)
  rescue ParseError
    puts 'parse error'
  end
end
