# -*- coding: utf-8 -*-
# frozen_string_literal: true
#
# DO NOT MODIFY!!!!
# This file is automatically generated by Racc 1.4.11
# from Racc grammer file "".
#

require 'racc/parser'
class ExcelFormulaParser < Racc::Parser  # :nodoc:
##### State transition tables begin ###

racc_action_table = [
    16,    54,    26,    28,    30,    32,    34,    21,    20,     3,
   nil,   nil,    53,    19,    23,     4,     5,     6,     7,    10,
    13,    14,    15,    17,    18,    16,   nil,    26,    28,    30,
    32,    34,     8,   nil,   nil,   nil,   nil,    16,    19,   nil,
     4,     5,     6,     7,    10,    13,    14,    15,    17,    18,
    19,    16,     4,     5,     6,     7,    10,    13,    14,    15,
    17,    18,   nil,    16,    19,   nil,     4,     5,     6,     7,
    10,    13,    14,    15,    17,    18,    19,    16,     4,     5,
     6,     7,    10,    13,    14,    15,    17,    18,   nil,    16,
    19,   nil,     4,     5,     6,     7,    10,    13,    14,    15,
    17,    18,    19,    16,     4,     5,     6,     7,    10,    13,
    14,    15,    17,    18,   nil,    16,    19,    37,     4,     5,
     6,     7,    10,    13,    14,    15,    17,    18,    19,    16,
     4,     5,     6,     7,    10,    13,    14,    15,    17,    18,
   nil,    16,    19,   nil,     4,     5,     6,     7,    10,    13,
    14,    15,    17,    18,    19,    16,     4,     5,     6,     7,
    10,    13,    14,    15,    17,    18,   nil,    16,    19,   nil,
     4,     5,     6,     7,    10,    13,    14,    15,    17,    18,
    19,    16,     4,     5,     6,     7,    10,    13,    14,    15,
    17,    18,   nil,    16,    19,   nil,     4,     5,     6,     7,
    10,    13,    14,    15,    17,    18,    19,    16,     4,     5,
     6,     7,    10,    13,    14,    15,    17,    18,   nil,    16,
    19,   nil,     4,     5,     6,     7,    10,    13,    14,    15,
    17,    18,    19,   nil,     4,     5,     6,     7,    10,    13,
    14,    15,    17,    18,    23,    24,    27,    29,    31,    33,
   nil,   nil,   nil,   nil,   nil,    22,   nil,    26,    28,    30,
    32,    34,   nil,    52,    23,    24,    27,    29,    31,    33,
    23,    24,    27,    29,   nil,   nil,   nil,    26,    28,    30,
    32,    34,   nil,    26,    28,    30,    32,    34,    23,    24,
    27,    29,   nil,   nil,   nil,    23,    24,    27,    29,    31,
    33,    26,    28,    30,    32,    34,    22,    25,    26,    28,
    30,    32,    34,    23,    24,    27,    29,    31,    33,   nil,
   nil,   nil,   nil,   nil,    22,   nil,    26,    28,    30,    32,
    34,    23,    24,    27,    29,    31,    33,   nil,   nil,   nil,
   nil,   nil,    22,   nil,    26,    28,    30,    32,    34,    23,
    24,    27,    29,    31,    33,    23,   nil,   nil,   nil,   nil,
    22,   nil,    26,    28,    30,    32,    34,   nil,    26,    28,
    30,    32,    34,    23,    24,    27,    29,    31,    33,    23,
    24,   nil,   nil,   nil,    22,   nil,    26,    28,    30,    32,
    34,   nil,    26,    28,    30,    32,    34,    23,    24,    27,
    29,    31,    33,    23,    24,   nil,   nil,   nil,    22,   nil,
    26,    28,    30,    32,    34,   nil,    26,    28,    30,    32,
    34,    23,    24,    27,    29,    31,    33,   nil,   nil,   nil,
   nil,   nil,    22,   nil,    26,    28,    30,    32,    34,    23,
    24,    27,    29,    31,    33,   nil,   nil,   nil,   nil,   nil,
    22,   nil,    26,    28,    30,    32,    34 ]

racc_action_check = [
    34,    39,    35,    35,    35,    35,    35,     4,     3,     1,
   nil,   nil,    39,    34,    41,    34,    34,    34,    34,    34,
    34,    34,    34,    34,    34,     2,   nil,    41,    41,    41,
    41,    41,     2,   nil,   nil,   nil,   nil,    53,     2,   nil,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
    53,    33,    53,    53,    53,    53,    53,    53,    53,    53,
    53,    53,   nil,    32,    33,   nil,    33,    33,    33,    33,
    33,    33,    33,    33,    33,    33,    32,    16,    32,    32,
    32,    32,    32,    32,    32,    32,    32,    32,   nil,    19,
    16,   nil,    16,    16,    16,    16,    16,    16,    16,    16,
    16,    16,    19,    21,    19,    19,    19,    19,    19,    19,
    19,    19,    19,    19,   nil,    22,    21,    21,    21,    21,
    21,    21,    21,    21,    21,    21,    21,    21,    22,    23,
    22,    22,    22,    22,    22,    22,    22,    22,    22,    22,
   nil,    24,    23,   nil,    23,    23,    23,    23,    23,    23,
    23,    23,    23,    23,    24,    26,    24,    24,    24,    24,
    24,    24,    24,    24,    24,    24,   nil,    27,    26,   nil,
    26,    26,    26,    26,    26,    26,    26,    26,    26,    26,
    27,    28,    27,    27,    27,    27,    27,    27,    27,    27,
    27,    27,   nil,    29,    28,   nil,    28,    28,    28,    28,
    28,    28,    28,    28,    28,    28,    29,    30,    29,    29,
    29,    29,    29,    29,    29,    29,    29,    29,   nil,    31,
    30,   nil,    30,    30,    30,    30,    30,    30,    30,    30,
    30,    30,    31,   nil,    31,    31,    31,    31,    31,    31,
    31,    31,    31,    31,    36,    36,    36,    36,    36,    36,
   nil,   nil,   nil,   nil,   nil,    36,   nil,    36,    36,    36,
    36,    36,   nil,    36,    40,    40,    40,    40,    40,    40,
    48,    48,    48,    48,   nil,   nil,   nil,    40,    40,    40,
    40,    40,   nil,    48,    48,    48,    48,    48,    50,    50,
    50,    50,   nil,   nil,   nil,     9,     9,     9,     9,     9,
     9,    50,    50,    50,    50,    50,     9,     9,     9,     9,
     9,     9,     9,    38,    38,    38,    38,    38,    38,   nil,
   nil,   nil,   nil,   nil,    38,   nil,    38,    38,    38,    38,
    38,    49,    49,    49,    49,    49,    49,   nil,   nil,   nil,
   nil,   nil,    49,   nil,    49,    49,    49,    49,    49,    51,
    51,    51,    51,    51,    51,    42,   nil,   nil,   nil,   nil,
    51,   nil,    51,    51,    51,    51,    51,   nil,    42,    42,
    42,    42,    42,    43,    43,    43,    43,    43,    43,    44,
    44,   nil,   nil,   nil,    43,   nil,    43,    43,    43,    43,
    43,   nil,    44,    44,    44,    44,    44,    45,    45,    45,
    45,    45,    45,    46,    46,   nil,   nil,   nil,    45,   nil,
    45,    45,    45,    45,    45,   nil,    46,    46,    46,    46,
    46,    47,    47,    47,    47,    47,    47,   nil,   nil,   nil,
   nil,   nil,    47,   nil,    47,    47,    47,    47,    47,    55,
    55,    55,    55,    55,    55,   nil,   nil,   nil,   nil,   nil,
    55,   nil,    55,    55,    55,    55,    55 ]

racc_action_pointer = [
   nil,     9,    17,     8,   -14,   nil,   nil,   nil,   nil,   292,
   nil,   nil,   nil,   nil,   nil,   nil,    69,   nil,   nil,    81,
   nil,    95,   107,   121,   133,   nil,   147,   159,   173,   185,
   199,   211,    55,    43,    -8,   -14,   241,   nil,   310,   -21,
   261,    11,   352,   370,   376,   394,   400,   418,   267,   328,
   285,   346,   nil,    29,   nil,   436 ]

racc_action_default = [
    -2,   -35,    -1,   -35,   -20,   -21,   -22,   -23,    -4,   -35,
   -24,   -17,   -30,   -25,   -26,   -27,   -35,   -28,   -29,   -35,
    56,   -35,   -35,   -35,   -35,    -3,   -35,   -35,   -35,   -35,
   -35,   -35,   -35,   -35,   -35,   -19,   -35,   -32,   -33,   -35,
   -16,    -9,   -10,   -11,    -7,   -12,    -8,   -13,    -5,   -14,
    -6,   -15,   -18,   -35,   -31,   -34 ]

racc_goto_table = [
     9,     1,     2,    39,   nil,   nil,   nil,   nil,   nil,   nil,
   nil,   nil,   nil,   nil,    35,   nil,   nil,    36,   nil,    38,
    40,    41,    42,   nil,    43,    44,    45,    46,    47,    48,
    49,    50,    51,   nil,   nil,   nil,   nil,   nil,   nil,   nil,
   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,
   nil,    55 ]

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

racc_goto_pointer = [
   nil,     1,     2,    -2,   nil,   nil,   -18 ]

racc_goto_default = [
   nil,   nil,   nil,   nil,    11,    12,   nil ]

racc_reduce_table = [
  0, 0, :racc_error,
  1, 35, :_reduce_none,
  0, 36, :_reduce_2,
  3, 36, :_reduce_3,
  2, 36, :_reduce_none,
  3, 37, :_reduce_5,
  3, 37, :_reduce_6,
  3, 37, :_reduce_7,
  3, 37, :_reduce_8,
  3, 37, :_reduce_9,
  3, 37, :_reduce_10,
  3, 37, :_reduce_11,
  3, 37, :_reduce_12,
  3, 37, :_reduce_13,
  3, 37, :_reduce_14,
  3, 37, :_reduce_15,
  3, 37, :_reduce_16,
  1, 37, :_reduce_none,
  3, 38, :_reduce_18,
  2, 38, :_reduce_19,
  1, 38, :_reduce_none,
  1, 38, :_reduce_21,
  1, 38, :_reduce_22,
  1, 38, :_reduce_23,
  1, 38, :_reduce_24,
  1, 38, :_reduce_25,
  1, 38, :_reduce_26,
  1, 38, :_reduce_27,
  1, 38, :_reduce_28,
  1, 38, :_reduce_29,
  1, 38, :_reduce_none,
  4, 39, :_reduce_31,
  3, 39, :_reduce_32,
  1, 40, :_reduce_33,
  3, 40, :_reduce_34 ]

racc_reduce_n = 35

racc_shift_n = 56

racc_token_table = {
  false => 0,
  :error => 1,
  :UMINUS => 2,
  "^" => 3,
  "&" => 4,
  "*" => 5,
  "/" => 6,
  "+" => 7,
  "-" => 8,
  "<" => 9,
  ">" => 10,
  "<=" => 11,
  ">=" => 12,
  "<>" => 13,
  "=" => 14,
  :EOL => 15,
  :LT => 16,
  :GT => 17,
  :LE => 18,
  :GE => 19,
  :NE => 20,
  "(" => 21,
  ")" => 22,
  :FUNC => 23,
  :NUMBER => 24,
  :STRING => 25,
  :REF2D => 26,
  :REF3D => 27,
  :RANGE2D => 28,
  :RANGE3D => 29,
  :NAME => 30,
  :TRUE => 31,
  :FALSE => 32,
  "," => 33 }

racc_nt_base = 34

racc_use_result_var = true

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",
  "\"^\"",
  "\"&\"",
  "\"*\"",
  "\"/\"",
  "\"+\"",
  "\"-\"",
  "\"<\"",
  "\">\"",
  "\"<=\"",
  "\">=\"",
  "\"<>\"",
  "\"=\"",
  "EOL",
  "LT",
  "GT",
  "LE",
  "GE",
  "NE",
  "\"(\"",
  "\")\"",
  "FUNC",
  "NUMBER",
  "STRING",
  "REF2D",
  "REF3D",
  "RANGE2D",
  "RANGE3D",
  "NAME",
  "TRUE",
  "FALSE",
  "\",\"",
  "$start",
  "formula",
  "expr_list",
  "expr",
  "primary",
  "funcall",
  "args" ]

Racc_debug_parser = false

##### State transition tables end #####

# reduce 0 omitted

# reduce 1 omitted

module_eval(<<'.,.,', 'excelformula.y', 20)
  def _reduce_2(val, _values, result)
     result = []
    result
  end
.,.,

module_eval(<<'.,.,', 'excelformula.y', 21)
  def _reduce_3(val, _values, result)
     result.push val[1], '_arg', '1'
    result
  end
.,.,

# reduce 4 omitted

module_eval(<<'.,.,', 'excelformula.y', 24)
  def _reduce_5(val, _values, result)
     result = [ val[0], val[2], 'ptgAdd' ]
    result
  end
.,.,

module_eval(<<'.,.,', 'excelformula.y', 25)
  def _reduce_6(val, _values, result)
     result = [ val[0], val[2], 'ptgSub' ]
    result
  end
.,.,

module_eval(<<'.,.,', 'excelformula.y', 26)
  def _reduce_7(val, _values, result)
     result = [ val[0], val[2], 'ptgMul' ]
    result
  end
.,.,

module_eval(<<'.,.,', 'excelformula.y', 27)
  def _reduce_8(val, _values, result)
     result = [ val[0], val[2], 'ptgDiv' ]
    result
  end
.,.,

module_eval(<<'.,.,', 'excelformula.y', 28)
  def _reduce_9(val, _values, result)
     result = [ val[0], val[2], 'ptgPower' ]
    result
  end
.,.,

module_eval(<<'.,.,', 'excelformula.y', 29)
  def _reduce_10(val, _values, result)
     result = [ val[0], val[2], 'ptgConcat' ]
    result
  end
.,.,

module_eval(<<'.,.,', 'excelformula.y', 30)
  def _reduce_11(val, _values, result)
     result = [ val[0], val[2], 'ptgLT' ]
    result
  end
.,.,

module_eval(<<'.,.,', 'excelformula.y', 31)
  def _reduce_12(val, _values, result)
     result = [ val[0], val[2], 'ptgGT' ]
    result
  end
.,.,

module_eval(<<'.,.,', 'excelformula.y', 32)
  def _reduce_13(val, _values, result)
     result = [ val[0], val[2], 'ptgLE' ]
    result
  end
.,.,

module_eval(<<'.,.,', 'excelformula.y', 33)
  def _reduce_14(val, _values, result)
     result = [ val[0], val[2], 'ptgGE' ]
    result
  end
.,.,

module_eval(<<'.,.,', 'excelformula.y', 34)
  def _reduce_15(val, _values, result)
     result = [ val[0], val[2], 'ptgNE' ]
    result
  end
.,.,

module_eval(<<'.,.,', 'excelformula.y', 35)
  def _reduce_16(val, _values, result)
     result = [ val[0], val[2], 'ptgEQ' ]
    result
  end
.,.,

# reduce 17 omitted

module_eval(<<'.,.,', 'excelformula.y', 38)
  def _reduce_18(val, _values, result)
     result = [ val[1], '_arg', '1', 'ptgParen']
    result
  end
.,.,

module_eval(<<'.,.,', 'excelformula.y', 39)
  def _reduce_19(val, _values, result)
     result = [ '_num', '-1', val[1], 'ptgMul' ]
    result
  end
.,.,

# reduce 20 omitted

module_eval(<<'.,.,', 'excelformula.y', 41)
  def _reduce_21(val, _values, result)
     result = [ '_num',     val[0] ]
    result
  end
.,.,

module_eval(<<'.,.,', 'excelformula.y', 42)
  def _reduce_22(val, _values, result)
     result = [ '_str',     val[0] ]
    result
  end
.,.,

module_eval(<<'.,.,', 'excelformula.y', 43)
  def _reduce_23(val, _values, result)
     result = [ '_ref2d',   val[0] ]
    result
  end
.,.,

module_eval(<<'.,.,', 'excelformula.y', 44)
  def _reduce_24(val, _values, result)
     result = [ '_ref3d',   val[0] ]
    result
  end
.,.,

module_eval(<<'.,.,', 'excelformula.y', 45)
  def _reduce_25(val, _values, result)
     result = [ '_range2d', val[0] ]
    result
  end
.,.,

module_eval(<<'.,.,', 'excelformula.y', 46)
  def _reduce_26(val, _values, result)
     result = [ '_range3d', val[0] ]
    result
  end
.,.,

module_eval(<<'.,.,', 'excelformula.y', 47)
  def _reduce_27(val, _values, result)
     result = [ '_name',    val[0] ]
    result
  end
.,.,

module_eval(<<'.,.,', 'excelformula.y', 48)
  def _reduce_28(val, _values, result)
     result = [ 'ptgBool',  '1'    ]
    result
  end
.,.,

module_eval(<<'.,.,', 'excelformula.y', 49)
  def _reduce_29(val, _values, result)
     result = [ 'ptgBool',  '0'    ]
    result
  end
.,.,

# reduce 30 omitted

module_eval(<<'.,.,', 'excelformula.y', 52)
  def _reduce_31(val, _values, result)
     result = [ '_class', val[0], val[2], '_arg', val[2].size.to_s, '_func', val[0] ]
    result
  end
.,.,

module_eval(<<'.,.,', 'excelformula.y', 53)
  def _reduce_32(val, _values, result)
     result = [ '_func', val[0] ]
    result
  end
.,.,

module_eval(<<'.,.,', 'excelformula.y', 55)
  def _reduce_33(val, _values, result)
     result = val
    result
  end
.,.,

module_eval(<<'.,.,', 'excelformula.y', 56)
  def _reduce_34(val, _values, result)
     result.push val[2]
    result
  end
.,.,

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

end   # class ExcelFormulaParser


class ExcelFormulaParserError < StandardError  #:nodoc:
end

module Writeexcel

   class Node  # :nodoc:

      def exec_list(nodes)
         v = nil
         nodes.each { |i| v = i.evaluate }
         v
      end

      def excelformulaparser_error(msg)
         raise ExcelFormulaParserError,
                  "in #{fname}:#{lineno}: #{msg}"
      end

   end

   class RootNode < Node  # :nodoc:

      def initialize(tree)
         @tree = tree
      end

      def evaluate
         exec_list @tree
      end

   end


   class FuncallNode < Node  # :nodoc:

      def initialize(func, args)
         @func = func
         @args = args
      end

      def evaluate
         arg = @args.collect {|i| i.evaluate }
         arg.each { |i| o.push i }
         o.push @func
         p o
      end

   end

   class NumberNode < Node  # :nodoc:

      def initialize(val)
         @val = val
      end

      def evaluate
         p @val
      end

   end

   class OperateNode < Node  # :nodoc:

      def initialize(op, left, right)
         @op = op
         @left = left
         @right = right
      end

      def evaluate
         o = []
         o.push @left
         o.push @right
         o.push @op
         p o
      end
   end
end
