lib/writeexcel/excelformulaparser.rb in writeexcel-1.0.5 vs lib/writeexcel/excelformulaparser.rb in writeexcel-1.0.6

- old
+ new

@@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- +# frozen_string_literal: true # # DO NOT MODIFY!!!! # This file is automatically generated by Racc 1.4.11 # from Racc grammer file "". # @@ -291,215 +292,215 @@ # reduce 1 omitted module_eval(<<'.,.,', 'excelformula.y', 20) def _reduce_2(val, _values, result) - result = [] + result = [] result end .,., module_eval(<<'.,.,', 'excelformula.y', 21) def _reduce_3(val, _values, result) - result.push val[1], '_arg', '1' + 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 = [ 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 = [ 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 = [ 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 = [ 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 = [ 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 = [ 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 = [ 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 = [ 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 = [ 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 = [ 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 = [ 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 = [ 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 = [ 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 = [ '_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 = [ '_num', val[0] ] result end .,., module_eval(<<'.,.,', 'excelformula.y', 42) def _reduce_22(val, _values, result) - result = [ '_str', val[0] ] + result = [ '_str', val[0] ] result end .,., module_eval(<<'.,.,', 'excelformula.y', 43) def _reduce_23(val, _values, result) - result = [ '_ref2d', val[0] ] + result = [ '_ref2d', val[0] ] result end .,., module_eval(<<'.,.,', 'excelformula.y', 44) def _reduce_24(val, _values, result) - result = [ '_ref3d', val[0] ] + result = [ '_ref3d', val[0] ] result end .,., module_eval(<<'.,.,', 'excelformula.y', 45) def _reduce_25(val, _values, result) - result = [ '_range2d', val[0] ] + result = [ '_range2d', val[0] ] result end .,., module_eval(<<'.,.,', 'excelformula.y', 46) def _reduce_26(val, _values, result) - result = [ '_range3d', val[0] ] + result = [ '_range3d', val[0] ] result end .,., module_eval(<<'.,.,', 'excelformula.y', 47) def _reduce_27(val, _values, result) - result = [ '_name', val[0] ] + result = [ '_name', val[0] ] result end .,., module_eval(<<'.,.,', 'excelformula.y', 48) def _reduce_28(val, _values, result) - result = [ 'ptgBool', '1' ] + result = [ 'ptgBool', '1' ] result end .,., module_eval(<<'.,.,', 'excelformula.y', 49) def _reduce_29(val, _values, result) - result = [ 'ptgBool', '0' ] + 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 = [ '_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 = [ '_func', val[0] ] result end .,., module_eval(<<'.,.,', 'excelformula.y', 55) def _reduce_33(val, _values, result) - result = val + result = val result end .,., module_eval(<<'.,.,', 'excelformula.y', 56) def _reduce_34(val, _values, result) - result.push val[2] + result.push val[2] result end .,., def _reduce_none(val, _values, result) @@ -513,73 +514,72 @@ 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 } - out = [] 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