writeexcel 0.3.5 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitattributes +1 -0
- data/README.rdoc +12 -6
- data/VERSION +1 -1
- data/charts/chartex.rb +316 -315
- data/charts/demo1.rb +1 -0
- data/charts/demo2.rb +1 -0
- data/charts/demo3.rb +117 -116
- data/charts/demo4.rb +119 -118
- data/charts/demo5.rb +48 -47
- data/examples/a_simple.rb +1 -0
- data/examples/autofilter.rb +1 -0
- data/examples/bigfile.rb +30 -29
- data/examples/chart_area.rb +121 -120
- data/examples/chart_bar.rb +120 -119
- data/examples/chart_column.rb +120 -119
- data/examples/chart_line.rb +120 -119
- data/examples/chart_pie.rb +108 -107
- data/examples/chart_scatter.rb +121 -120
- data/examples/chart_stock.rb +148 -147
- data/examples/chess.rb +1 -0
- data/examples/colors.rb +1 -0
- data/examples/comments1.rb +1 -0
- data/examples/comments2.rb +3 -2
- data/examples/copyformat.rb +1 -0
- data/examples/data_validate.rb +1 -0
- data/examples/date_time.rb +1 -0
- data/examples/defined_name.rb +1 -0
- data/examples/demo.rb +1 -0
- data/examples/diag_border.rb +1 -0
- data/examples/formats.rb +1 -0
- data/examples/formula_result.rb +1 -0
- data/examples/header.rb +1 -0
- data/examples/hide_sheet.rb +1 -0
- data/examples/hyperlink.rb +1 -0
- data/examples/images.rb +1 -0
- data/examples/indent.rb +1 -0
- data/examples/merge1.rb +1 -0
- data/examples/merge2.rb +1 -0
- data/examples/merge3.rb +1 -0
- data/examples/merge4.rb +1 -0
- data/examples/merge5.rb +1 -0
- data/examples/merge6.rb +67 -66
- data/examples/outline.rb +1 -0
- data/examples/outline_collapsed.rb +1 -0
- data/examples/panes.rb +1 -0
- data/examples/properties.rb +1 -0
- data/examples/properties_jp.rb +1 -0
- data/examples/protection.rb +1 -0
- data/examples/regions.rb +1 -0
- data/examples/repeat.rb +1 -0
- data/examples/right_to_left.rb +1 -0
- data/examples/row_wrap.rb +1 -0
- data/examples/stats.rb +1 -0
- data/examples/stocks.rb +1 -0
- data/examples/tab_colors.rb +1 -0
- data/examples/write_arrays.rb +1 -0
- data/lib/writeexcel.rb +6 -1
- data/lib/writeexcel/biffwriter.rb +21 -20
- data/lib/writeexcel/chart.rb +25 -12
- data/lib/writeexcel/charts/area.rb +153 -152
- data/lib/writeexcel/charts/bar.rb +178 -177
- data/lib/writeexcel/charts/column.rb +157 -156
- data/lib/writeexcel/charts/external.rb +62 -61
- data/lib/writeexcel/charts/line.rb +153 -152
- data/lib/writeexcel/charts/pie.rb +170 -169
- data/lib/writeexcel/charts/scatter.rb +4 -3
- data/lib/writeexcel/charts/stock.rb +212 -211
- data/lib/writeexcel/compatibility.rb +320 -0
- data/lib/writeexcel/excelformulaparser.rb +587 -586
- data/lib/writeexcel/format.rb +12 -13
- data/lib/writeexcel/formula.rb +30 -28
- data/lib/writeexcel/helper.rb +23 -0
- data/lib/writeexcel/olewriter.rb +5 -16
- data/lib/writeexcel/properties.rb +43 -54
- data/lib/writeexcel/storage_lite.rb +981 -968
- data/lib/writeexcel/workbook.rb +94 -73
- data/lib/writeexcel/worksheet.rb +230 -210
- data/test/helper.rb +19 -0
- data/test/test_00_IEEE_double.rb +1 -0
- data/test/test_01_add_worksheet.rb +1 -0
- data/test/test_02_merge_formats.rb +3 -5
- data/test/test_04_dimensions.rb +3 -5
- data/test/test_05_rows.rb +6 -6
- data/test/test_06_extsst.rb +8 -8
- data/test/test_11_date_time.rb +3 -5
- data/test/test_12_date_only.rb +3 -5
- data/test/test_13_date_seconds.rb +4 -6
- data/test/test_21_escher.rb +3 -5
- data/test/test_22_mso_drawing_group.rb +20 -22
- data/test/test_23_note.rb +5 -7
- data/test/test_24_txo.rb +3 -5
- data/test/test_25_position_object.rb +84 -79
- data/test/test_26_autofilter.rb +3 -13
- data/test/test_27_autofilter.rb +3 -13
- data/test/test_28_autofilter.rb +3 -13
- data/test/test_29_process_jpg.rb +5 -0
- data/test/test_30_validation_dval.rb +3 -5
- data/test/test_31_validation_dv_strings.rb +3 -5
- data/test/test_32_validation_dv_formula.rb +3 -5
- data/test/test_40_property_types.rb +10 -9
- data/test/test_41_properties.rb +1 -0
- data/test/test_42_set_properties.rb +14 -15
- data/test/test_50_name_stored.rb +299 -302
- data/test/test_51_name_print_area.rb +357 -360
- data/test/test_52_name_print_titles.rb +454 -457
- data/test/test_53_autofilter.rb +203 -206
- data/test/test_60_chart_generic.rb +5 -0
- data/test/test_61_chart_subclasses.rb +95 -94
- data/test/test_62_chart_formats.rb +272 -267
- data/test/test_63_chart_area_formats.rb +649 -644
- data/test/test_biff.rb +12 -38
- data/test/test_compatibility.rb +627 -0
- data/test/test_example_match.rb +3 -18
- data/test/test_format.rb +46 -105
- data/test/test_formula.rb +1 -0
- data/test/test_ole.rb +3 -4
- data/test/test_storage_lite.rb +125 -146
- data/test/test_workbook.rb +2 -23
- data/test/test_worksheet.rb +4 -5
- data/utils/add_magic_comment.rb +80 -0
- data/writeexcel.gemspec +8 -2
- metadata +10 -4
@@ -0,0 +1,320 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
#
|
3
|
+
# Why would we ever use Ruby 1.8.7 when we can backport with something
|
4
|
+
# as simple as this?
|
5
|
+
#
|
6
|
+
# copied from prawn.
|
7
|
+
# modified by Hideo NAKAMURA
|
8
|
+
#
|
9
|
+
unless defined?(Encoding)
|
10
|
+
class Encoding # :nodoc:
|
11
|
+
class ConverterNotFoundError < StandardError; end
|
12
|
+
class UndefinedConversionError < StandardError; end
|
13
|
+
|
14
|
+
ASCII = 0
|
15
|
+
BINARY = 1
|
16
|
+
UTF_8 = 2
|
17
|
+
EUCJP = 3
|
18
|
+
SJIS = 4
|
19
|
+
UTF_16LE = 5
|
20
|
+
UTF_16BE = 6
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
class String #:nodoc:
|
25
|
+
def first_line
|
26
|
+
self.each_line { |line| return line }
|
27
|
+
end
|
28
|
+
unless "".respond_to?(:lines)
|
29
|
+
alias_method :lines, :to_a
|
30
|
+
end
|
31
|
+
unless "".respond_to?(:each_char)
|
32
|
+
def each_char #:nodoc:
|
33
|
+
# copied from jcode
|
34
|
+
if block_given?
|
35
|
+
scan(/./m) { |x| yield x }
|
36
|
+
else
|
37
|
+
scan(/./m)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
unless "".respond_to?(:encode)
|
43
|
+
@encoding = Encoding::UTF_8
|
44
|
+
|
45
|
+
def encode(encoding) # :nodoc:
|
46
|
+
require 'nkf'
|
47
|
+
@encoding ||= Encoding::UTF_8
|
48
|
+
if @encoding == Encoding::UTF_8
|
49
|
+
# supported only $KCODE = 'u'. so @encoding.nil? means UTF_8.
|
50
|
+
case encoding
|
51
|
+
when /ASCII/i
|
52
|
+
if self.mbchar?('UTF8')
|
53
|
+
raise Encoding::UndefinedConversionError
|
54
|
+
else
|
55
|
+
str = String.new(self)
|
56
|
+
str.force_encoding(encoding)
|
57
|
+
str
|
58
|
+
end
|
59
|
+
when /BINARY/i
|
60
|
+
if self.mbchar?('UTF8')
|
61
|
+
raise Encoding::UndefinedConversionError
|
62
|
+
else
|
63
|
+
str = String.new(self)
|
64
|
+
str.force_encoding(encoding)
|
65
|
+
str
|
66
|
+
end
|
67
|
+
when /UTF_8/i
|
68
|
+
raise Encoding::ConverterNotFoundError
|
69
|
+
when /EUCJP/i, /SJIS/i
|
70
|
+
enc = encoding =~ /EUCJP/i ? 'e' : 's'
|
71
|
+
str = NKF.nkf("-#{enc} -m0 -W", self)
|
72
|
+
str.force_encoding(encoding)
|
73
|
+
str
|
74
|
+
when /UTF_16LE/i, /UTF_16BE/i
|
75
|
+
raise Encoding::ConverterNotFoundError
|
76
|
+
else
|
77
|
+
raise "Sorry, encoding #{encoding} is not supported by WriteExcel."
|
78
|
+
end
|
79
|
+
elsif @encoding == Encoding::ASCII
|
80
|
+
case encoding
|
81
|
+
when /ASCII/i, /BINARY/i, /EUCJP/i, /SJIS/i
|
82
|
+
str = String.new(self)
|
83
|
+
str.force_encoding(encoding)
|
84
|
+
str
|
85
|
+
when /UTF_8/i, /UTF_16LE/i, /UTF_16BE/i
|
86
|
+
raise Encoding::ConverterNotFoundError
|
87
|
+
else
|
88
|
+
raise "Sorry, encoding #{encoding} is not supported by WriteExcel."
|
89
|
+
end
|
90
|
+
elsif @encoding == Encoding::BINARY
|
91
|
+
case encoding
|
92
|
+
when /ASCII/i
|
93
|
+
if self.ascii_only? || self.mbchar?('UTF8') || self.mbchar?('EUCJP') || self.mbchar?('SJIS')
|
94
|
+
raise Encoding::UndefinedConversionError
|
95
|
+
else
|
96
|
+
str = String.new(self)
|
97
|
+
str.force_encoding(encoding)
|
98
|
+
str
|
99
|
+
end
|
100
|
+
when /BINARY/i
|
101
|
+
self
|
102
|
+
when /EUCJP/i, /SJIS/i
|
103
|
+
if self.ascii_only? || self.mbchar?('UTF8') || self.mbchar?('EUCJP') || self.mbchar?('SJIS')
|
104
|
+
raise Encoding::UndefinedConversionError
|
105
|
+
else
|
106
|
+
str = String.new(self)
|
107
|
+
str.force_encoding(encoding)
|
108
|
+
str
|
109
|
+
end
|
110
|
+
when /UTF_8/i, /UTF_16LE/i, /UTF_16BE/i
|
111
|
+
raise Encoding::ConverterNotFoundError
|
112
|
+
else
|
113
|
+
raise "Sorry, encoding #{encoding} is not supported by WriteExcel."
|
114
|
+
end
|
115
|
+
elsif @encoding == Encoding::EUCJP || @encoding == Encoding::SJIS
|
116
|
+
type = @encoding == Encoding::EUCJP ? 'EUCJP' : 'SJIS'
|
117
|
+
inenc = @encoding == Encoding::EUCJP ? 'e' : 's'
|
118
|
+
case encoding
|
119
|
+
when /ASCII/i
|
120
|
+
if self.mbchar?(type)
|
121
|
+
raise Encoding::UndefinedConversionError
|
122
|
+
else
|
123
|
+
str = String.new(self)
|
124
|
+
str.force_encoding(encoding)
|
125
|
+
str
|
126
|
+
end
|
127
|
+
when /BINARY/i
|
128
|
+
if self.mbchar?(type)
|
129
|
+
raise Encoding::UndefinedConversionError
|
130
|
+
else
|
131
|
+
str = String.new(self)
|
132
|
+
str.force_encoding(encoding)
|
133
|
+
str
|
134
|
+
end
|
135
|
+
when /UTF_8/i
|
136
|
+
raise Encoding::ConverterNotFoundError
|
137
|
+
when /EUCJP/i, /SJIS/i
|
138
|
+
outenc = encoding =~ /EUCJP/i ? 'E' : 'S'
|
139
|
+
str = NKF.nkf("-#{inenc} -#{outenc}", self)
|
140
|
+
str.force_encoding(encoding)
|
141
|
+
str
|
142
|
+
when /UTF_16LE/i, /UTF_16BE/i
|
143
|
+
raise Encoding::ConverterNotFoundError
|
144
|
+
else
|
145
|
+
raise "Sorry, encoding #{encoding} is not supported by WriteExcel."
|
146
|
+
end
|
147
|
+
elsif @encoding == Encoding::UTF_16LE || @encoding == Encoding::UTF_16BE
|
148
|
+
enc = @encoding == Encoding::UTF_16LE ? 'L' : 'B'
|
149
|
+
utf8 = NKF.nkf("-w -m0 -W16#{enc}", self)
|
150
|
+
case encoding
|
151
|
+
when /ASCII/i
|
152
|
+
if utf8.mbchar?
|
153
|
+
raise Encoding::UndefinedConversionError
|
154
|
+
else
|
155
|
+
str = String.new(self)
|
156
|
+
str.force_encoding(encoding)
|
157
|
+
str
|
158
|
+
end
|
159
|
+
when /BINARY/i
|
160
|
+
if utf8.mbchar?
|
161
|
+
raise Encoding::UndefinedConversionError
|
162
|
+
else
|
163
|
+
str = String.new(self)
|
164
|
+
str.force_encoding(encoding)
|
165
|
+
str
|
166
|
+
end
|
167
|
+
when /UTF_8/i
|
168
|
+
raise Encoding::ConverterNotFoundError
|
169
|
+
when /EUCJP/i, /SJIS/i
|
170
|
+
str = String.new(self)
|
171
|
+
str.force_encoding(encoding)
|
172
|
+
str
|
173
|
+
when /UTF_16LE/i, /UTF_16BE/i
|
174
|
+
raise Encoding::ConverterNotFoundError
|
175
|
+
else
|
176
|
+
raise "Sorry, encoding #{encoding} is not supported by WriteExcel."
|
177
|
+
end
|
178
|
+
else
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
def self_with_encoding(encoding)
|
183
|
+
if encoding =~ /ASCII/i
|
184
|
+
@encoding = Encoding::ASCII
|
185
|
+
elsif encoding =~ /BINARY/i
|
186
|
+
@encoding = Encoding::BINARY
|
187
|
+
elsif encoding =~ /UTF_8/i
|
188
|
+
@encoding = Encoding::UTF_8
|
189
|
+
elsif encoding =~ /EUCJP/i
|
190
|
+
@encoding = Encoding::EUCJP
|
191
|
+
elsif encoding =~ /SJIS/i
|
192
|
+
@encoding = Encoding::SJIS
|
193
|
+
elsif encoding =~ /UTF_16LE/i
|
194
|
+
@encoding = Encoding::UTF_16LE
|
195
|
+
elsif encoding =~ /UTF_16BE/i
|
196
|
+
@encoding = Encoding::UTF_16BE
|
197
|
+
else
|
198
|
+
raise "Sorry, encoding #{encoding} is not supported by WriteExcel."
|
199
|
+
end
|
200
|
+
self
|
201
|
+
end
|
202
|
+
private :self_with_encoding
|
203
|
+
end
|
204
|
+
|
205
|
+
unless "".respond_to?(:encoding)
|
206
|
+
def encoding
|
207
|
+
@encoding ||= Encoding::UTF_8
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
211
|
+
unless "".respond_to?(:bytesize)
|
212
|
+
def bytesize # :nodoc:
|
213
|
+
self.length
|
214
|
+
end
|
215
|
+
end
|
216
|
+
|
217
|
+
unless "".respond_to?(:ord)
|
218
|
+
def ord
|
219
|
+
self[0]
|
220
|
+
end
|
221
|
+
end
|
222
|
+
|
223
|
+
unless "".respond_to?(:force_encoding)
|
224
|
+
def force_encoding(encoding)
|
225
|
+
if encoding.kind_of?(String)
|
226
|
+
@encoding = case encoding
|
227
|
+
when /ASCII/i
|
228
|
+
Encoding::ASCII
|
229
|
+
when /BINARY/i
|
230
|
+
Encoding::BINARY
|
231
|
+
when /UTF[-_]8/i
|
232
|
+
Encoding::UTF_8
|
233
|
+
when /EUCJP/i
|
234
|
+
Encoding::EUCJP
|
235
|
+
when /SJIS/i
|
236
|
+
Encoding::SJIS
|
237
|
+
when /UTF[-_]16LE/i
|
238
|
+
Encoding::UTF_16LE
|
239
|
+
when /UTF[-_]16BE/i
|
240
|
+
Encoding::UTF_16BE
|
241
|
+
end
|
242
|
+
else
|
243
|
+
@encoding = case encoding
|
244
|
+
when Encoding::ASCII
|
245
|
+
Encoding::ASCII
|
246
|
+
when Encoding::BINARY
|
247
|
+
Encoding::BINARY
|
248
|
+
when Encoding::UTF_8
|
249
|
+
Encoding::UTF_8
|
250
|
+
when Encoding::EUCJP
|
251
|
+
Encoding::EUCJP
|
252
|
+
when Encoding::SJIS
|
253
|
+
Encoding::SJIS
|
254
|
+
when Encoding::UTF_16LE
|
255
|
+
Encoding::UTF_16LE
|
256
|
+
when Encoding::UTF_16BE
|
257
|
+
Encoding::UTF_16BE
|
258
|
+
end
|
259
|
+
end
|
260
|
+
self
|
261
|
+
end
|
262
|
+
end
|
263
|
+
|
264
|
+
unless "".respond_to?(:ascii_only?)
|
265
|
+
def ascii_only?
|
266
|
+
!!(self =~ /[^!"#\$%&'\(\)\*\+,\-\.\/\:\;<=>\?@0-9A-Za-z_\[\\\]\{\}^` ~\0\n]/)
|
267
|
+
end
|
268
|
+
end
|
269
|
+
|
270
|
+
if RUBY_VERSION < "1.9"
|
271
|
+
unless "".respond_to?(:mbchar?)
|
272
|
+
PATTERN_SJIS = '[\x81-\x9f\xe0-\xef][\x40-\x7e\x80-\xfc]' # :nodoc:
|
273
|
+
PATTERN_EUC = '[\xa1-\xfe][\xa1-\xfe]' # :nodoc:
|
274
|
+
PATTERN_UTF8 = '[\xc0-\xdf][\x80-\xbf]|[\xe0-\xef][\x80-\xbf][\x80-\xbf]' # :nodoc:
|
275
|
+
|
276
|
+
RE_SJIS = Regexp.new(PATTERN_SJIS, 0, 'n') # :nodoc:
|
277
|
+
RE_EUC = Regexp.new(PATTERN_EUC, 0, 'n') # :nodoc:
|
278
|
+
RE_UTF8 = Regexp.new(PATTERN_UTF8, 0, 'n') # :nodoc:
|
279
|
+
|
280
|
+
def mbchar?(type = nil)# :nodoc: idea copied from jcode.rb
|
281
|
+
if (!type.nil? && type =~ /SJIS/i) || $KCODE == 'SJIS'
|
282
|
+
self =~ RE_SJIS
|
283
|
+
elsif (!type.nil? && type =~ /EUCJP/i) || $KCODE == 'EUC'
|
284
|
+
self =~ RE_EUC
|
285
|
+
elsif (!type.nil? && type =~ /UTF_8/i) || $KCODE == 'UTF8'
|
286
|
+
self =~ RE_UTF8
|
287
|
+
else
|
288
|
+
nil
|
289
|
+
end
|
290
|
+
end
|
291
|
+
end
|
292
|
+
end
|
293
|
+
end
|
294
|
+
|
295
|
+
unless File.respond_to?(:binread)
|
296
|
+
def File.binread(file) #:nodoc:
|
297
|
+
File.open(file,"rb") { |f| f.read }
|
298
|
+
end
|
299
|
+
end
|
300
|
+
|
301
|
+
if RUBY_VERSION < "1.9"
|
302
|
+
|
303
|
+
def ruby_18 #:nodoc:
|
304
|
+
yield
|
305
|
+
end
|
306
|
+
|
307
|
+
def ruby_19 #:nodoc:
|
308
|
+
false
|
309
|
+
end
|
310
|
+
|
311
|
+
else
|
312
|
+
|
313
|
+
def ruby_18 #:nodoc:
|
314
|
+
false
|
315
|
+
end
|
316
|
+
|
317
|
+
def ruby_19 #:nodoc:
|
318
|
+
yield
|
319
|
+
end
|
320
|
+
end
|
@@ -1,586 +1,587 @@
|
|
1
|
-
#
|
2
|
-
#
|
3
|
-
#
|
4
|
-
#
|
5
|
-
#
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
23, 24, 27, 29,
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
53, 53,
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
16, 16,
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
27, 27,
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
30, 30,
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
9,
|
92
|
-
|
93
|
-
38,
|
94
|
-
|
95
|
-
|
96
|
-
51,
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
45, 45, 45,
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
55,
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
nil,
|
110
|
-
nil,
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
-
|
121
|
-
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
nil,
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
3, 3, 3, nil,
|
136
|
-
|
137
|
-
nil,
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
3, 37, :
|
153
|
-
3, 37, :
|
154
|
-
3, 37, :
|
155
|
-
3, 37, :
|
156
|
-
3, 37, :
|
157
|
-
3, 37, :
|
158
|
-
3, 37, :
|
159
|
-
3, 37, :
|
160
|
-
3, 37, :
|
161
|
-
3, 37, :
|
162
|
-
3, 37, :
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
1, 38, :
|
168
|
-
1, 38, :
|
169
|
-
1, 38, :
|
170
|
-
1, 38, :
|
171
|
-
1, 38, :
|
172
|
-
1, 38, :
|
173
|
-
1, 38, :
|
174
|
-
1, 38, :
|
175
|
-
1, 38, :
|
176
|
-
1, 38, :
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
:
|
190
|
-
|
191
|
-
"
|
192
|
-
"
|
193
|
-
"
|
194
|
-
"
|
195
|
-
"
|
196
|
-
"
|
197
|
-
"
|
198
|
-
"
|
199
|
-
"
|
200
|
-
"
|
201
|
-
"
|
202
|
-
|
203
|
-
:
|
204
|
-
:
|
205
|
-
:
|
206
|
-
:
|
207
|
-
:
|
208
|
-
|
209
|
-
"
|
210
|
-
|
211
|
-
:
|
212
|
-
:
|
213
|
-
:
|
214
|
-
:
|
215
|
-
:
|
216
|
-
:
|
217
|
-
:
|
218
|
-
:
|
219
|
-
:
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
"
|
245
|
-
"
|
246
|
-
"
|
247
|
-
"\"
|
248
|
-
"\"
|
249
|
-
"\"
|
250
|
-
"\"
|
251
|
-
"\"
|
252
|
-
"\"
|
253
|
-
"\"
|
254
|
-
"\"
|
255
|
-
"\"
|
256
|
-
"\"
|
257
|
-
"\"
|
258
|
-
"
|
259
|
-
"
|
260
|
-
"
|
261
|
-
"
|
262
|
-
"
|
263
|
-
"
|
264
|
-
"
|
265
|
-
"\"
|
266
|
-
"
|
267
|
-
"
|
268
|
-
"
|
269
|
-
"
|
270
|
-
"
|
271
|
-
"
|
272
|
-
"
|
273
|
-
"
|
274
|
-
"
|
275
|
-
"
|
276
|
-
"
|
277
|
-
"
|
278
|
-
"
|
279
|
-
"
|
280
|
-
"
|
281
|
-
"
|
282
|
-
"
|
283
|
-
"
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
v
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
@
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
o.push
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
@
|
576
|
-
@
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
o
|
582
|
-
o.push @
|
583
|
-
o.push @
|
584
|
-
|
585
|
-
|
586
|
-
end
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
#
|
3
|
+
# DO NOT MODIFY!!!!
|
4
|
+
# This file is automatically generated by Racc 1.4.6
|
5
|
+
# from Racc grammer file "".
|
6
|
+
#
|
7
|
+
|
8
|
+
require 'racc/parser.rb'
|
9
|
+
class ExcelFormulaParser < Racc::Parser # :nodoc:
|
10
|
+
##### State transition tables begin ###
|
11
|
+
|
12
|
+
racc_action_table = [
|
13
|
+
16, 54, 26, 28, 30, 32, 34, 21, 20, 3,
|
14
|
+
nil, nil, 53, 19, 23, 4, 5, 6, 7, 10,
|
15
|
+
13, 14, 15, 17, 18, 16, nil, 26, 28, 30,
|
16
|
+
32, 34, 8, nil, nil, nil, nil, 16, 19, nil,
|
17
|
+
4, 5, 6, 7, 10, 13, 14, 15, 17, 18,
|
18
|
+
19, 16, 4, 5, 6, 7, 10, 13, 14, 15,
|
19
|
+
17, 18, nil, 16, 19, nil, 4, 5, 6, 7,
|
20
|
+
10, 13, 14, 15, 17, 18, 19, 16, 4, 5,
|
21
|
+
6, 7, 10, 13, 14, 15, 17, 18, nil, 16,
|
22
|
+
19, nil, 4, 5, 6, 7, 10, 13, 14, 15,
|
23
|
+
17, 18, 19, 16, 4, 5, 6, 7, 10, 13,
|
24
|
+
14, 15, 17, 18, nil, 16, 19, 37, 4, 5,
|
25
|
+
6, 7, 10, 13, 14, 15, 17, 18, 19, 16,
|
26
|
+
4, 5, 6, 7, 10, 13, 14, 15, 17, 18,
|
27
|
+
nil, 16, 19, nil, 4, 5, 6, 7, 10, 13,
|
28
|
+
14, 15, 17, 18, 19, 16, 4, 5, 6, 7,
|
29
|
+
10, 13, 14, 15, 17, 18, nil, 16, 19, nil,
|
30
|
+
4, 5, 6, 7, 10, 13, 14, 15, 17, 18,
|
31
|
+
19, 16, 4, 5, 6, 7, 10, 13, 14, 15,
|
32
|
+
17, 18, nil, 16, 19, nil, 4, 5, 6, 7,
|
33
|
+
10, 13, 14, 15, 17, 18, 19, 16, 4, 5,
|
34
|
+
6, 7, 10, 13, 14, 15, 17, 18, nil, 16,
|
35
|
+
19, nil, 4, 5, 6, 7, 10, 13, 14, 15,
|
36
|
+
17, 18, 19, nil, 4, 5, 6, 7, 10, 13,
|
37
|
+
14, 15, 17, 18, 23, 24, 27, 29, 31, 33,
|
38
|
+
nil, nil, nil, nil, nil, 22, nil, 26, 28, 30,
|
39
|
+
32, 34, nil, 52, 23, 24, 27, 29, 31, 33,
|
40
|
+
23, 24, 27, 29, nil, nil, nil, 26, 28, 30,
|
41
|
+
32, 34, nil, 26, 28, 30, 32, 34, 23, 24,
|
42
|
+
27, 29, nil, nil, nil, 23, 24, 27, 29, 31,
|
43
|
+
33, 26, 28, 30, 32, 34, 22, 25, 26, 28,
|
44
|
+
30, 32, 34, 23, 24, 27, 29, 31, 33, nil,
|
45
|
+
nil, nil, nil, nil, 22, nil, 26, 28, 30, 32,
|
46
|
+
34, 23, 24, 27, 29, 31, 33, nil, nil, nil,
|
47
|
+
nil, nil, 22, nil, 26, 28, 30, 32, 34, 23,
|
48
|
+
24, 27, 29, 31, 33, 23, nil, nil, nil, nil,
|
49
|
+
22, nil, 26, 28, 30, 32, 34, nil, 26, 28,
|
50
|
+
30, 32, 34, 23, 24, 27, 29, 31, 33, 23,
|
51
|
+
24, nil, nil, nil, 22, nil, 26, 28, 30, 32,
|
52
|
+
34, nil, 26, 28, 30, 32, 34, 23, 24, 27,
|
53
|
+
29, 31, 33, 23, 24, nil, nil, nil, 22, nil,
|
54
|
+
26, 28, 30, 32, 34, nil, 26, 28, 30, 32,
|
55
|
+
34, 23, 24, 27, 29, 31, 33, nil, nil, nil,
|
56
|
+
nil, nil, 22, nil, 26, 28, 30, 32, 34, 23,
|
57
|
+
24, 27, 29, 31, 33, nil, nil, nil, nil, nil,
|
58
|
+
22, nil, 26, 28, 30, 32, 34 ]
|
59
|
+
|
60
|
+
racc_action_check = [
|
61
|
+
34, 39, 35, 35, 35, 35, 35, 4, 3, 1,
|
62
|
+
nil, nil, 39, 34, 41, 34, 34, 34, 34, 34,
|
63
|
+
34, 34, 34, 34, 34, 2, nil, 41, 41, 41,
|
64
|
+
41, 41, 2, nil, nil, nil, nil, 53, 2, nil,
|
65
|
+
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
66
|
+
53, 33, 53, 53, 53, 53, 53, 53, 53, 53,
|
67
|
+
53, 53, nil, 32, 33, nil, 33, 33, 33, 33,
|
68
|
+
33, 33, 33, 33, 33, 33, 32, 16, 32, 32,
|
69
|
+
32, 32, 32, 32, 32, 32, 32, 32, nil, 19,
|
70
|
+
16, nil, 16, 16, 16, 16, 16, 16, 16, 16,
|
71
|
+
16, 16, 19, 21, 19, 19, 19, 19, 19, 19,
|
72
|
+
19, 19, 19, 19, nil, 22, 21, 21, 21, 21,
|
73
|
+
21, 21, 21, 21, 21, 21, 21, 21, 22, 23,
|
74
|
+
22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
|
75
|
+
nil, 24, 23, nil, 23, 23, 23, 23, 23, 23,
|
76
|
+
23, 23, 23, 23, 24, 26, 24, 24, 24, 24,
|
77
|
+
24, 24, 24, 24, 24, 24, nil, 27, 26, nil,
|
78
|
+
26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
|
79
|
+
27, 28, 27, 27, 27, 27, 27, 27, 27, 27,
|
80
|
+
27, 27, nil, 29, 28, nil, 28, 28, 28, 28,
|
81
|
+
28, 28, 28, 28, 28, 28, 29, 30, 29, 29,
|
82
|
+
29, 29, 29, 29, 29, 29, 29, 29, nil, 31,
|
83
|
+
30, nil, 30, 30, 30, 30, 30, 30, 30, 30,
|
84
|
+
30, 30, 31, nil, 31, 31, 31, 31, 31, 31,
|
85
|
+
31, 31, 31, 31, 36, 36, 36, 36, 36, 36,
|
86
|
+
nil, nil, nil, nil, nil, 36, nil, 36, 36, 36,
|
87
|
+
36, 36, nil, 36, 40, 40, 40, 40, 40, 40,
|
88
|
+
48, 48, 48, 48, nil, nil, nil, 40, 40, 40,
|
89
|
+
40, 40, nil, 48, 48, 48, 48, 48, 50, 50,
|
90
|
+
50, 50, nil, nil, nil, 9, 9, 9, 9, 9,
|
91
|
+
9, 50, 50, 50, 50, 50, 9, 9, 9, 9,
|
92
|
+
9, 9, 9, 38, 38, 38, 38, 38, 38, nil,
|
93
|
+
nil, nil, nil, nil, 38, nil, 38, 38, 38, 38,
|
94
|
+
38, 49, 49, 49, 49, 49, 49, nil, nil, nil,
|
95
|
+
nil, nil, 49, nil, 49, 49, 49, 49, 49, 51,
|
96
|
+
51, 51, 51, 51, 51, 42, nil, nil, nil, nil,
|
97
|
+
51, nil, 51, 51, 51, 51, 51, nil, 42, 42,
|
98
|
+
42, 42, 42, 43, 43, 43, 43, 43, 43, 44,
|
99
|
+
44, nil, nil, nil, 43, nil, 43, 43, 43, 43,
|
100
|
+
43, nil, 44, 44, 44, 44, 44, 45, 45, 45,
|
101
|
+
45, 45, 45, 46, 46, nil, nil, nil, 45, nil,
|
102
|
+
45, 45, 45, 45, 45, nil, 46, 46, 46, 46,
|
103
|
+
46, 47, 47, 47, 47, 47, 47, nil, nil, nil,
|
104
|
+
nil, nil, 47, nil, 47, 47, 47, 47, 47, 55,
|
105
|
+
55, 55, 55, 55, 55, nil, nil, nil, nil, nil,
|
106
|
+
55, nil, 55, 55, 55, 55, 55 ]
|
107
|
+
|
108
|
+
racc_action_pointer = [
|
109
|
+
nil, 9, 17, 8, -14, nil, nil, nil, nil, 292,
|
110
|
+
nil, nil, nil, nil, nil, nil, 69, nil, nil, 81,
|
111
|
+
nil, 95, 107, 121, 133, nil, 147, 159, 173, 185,
|
112
|
+
199, 211, 55, 43, -8, -14, 241, nil, 310, -21,
|
113
|
+
261, 11, 352, 370, 376, 394, 400, 418, 267, 328,
|
114
|
+
285, 346, nil, 29, nil, 436 ]
|
115
|
+
|
116
|
+
racc_action_default = [
|
117
|
+
-2, -35, -1, -35, -20, -21, -22, -23, -4, -35,
|
118
|
+
-24, -17, -30, -25, -26, -27, -35, -28, -29, -35,
|
119
|
+
56, -35, -35, -35, -35, -3, -35, -35, -35, -35,
|
120
|
+
-35, -35, -35, -35, -35, -19, -35, -32, -33, -35,
|
121
|
+
-16, -9, -10, -11, -7, -12, -8, -13, -5, -14,
|
122
|
+
-6, -15, -18, -35, -31, -34 ]
|
123
|
+
|
124
|
+
racc_goto_table = [
|
125
|
+
9, 1, 2, 39, nil, nil, nil, nil, nil, nil,
|
126
|
+
nil, nil, nil, nil, 35, nil, nil, 36, nil, 38,
|
127
|
+
40, 41, 42, nil, 43, 44, 45, 46, 47, 48,
|
128
|
+
49, 50, 51, nil, nil, nil, nil, nil, nil, nil,
|
129
|
+
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
|
130
|
+
nil, 55 ]
|
131
|
+
|
132
|
+
racc_goto_check = [
|
133
|
+
3, 1, 2, 6, nil, nil, nil, nil, nil, nil,
|
134
|
+
nil, nil, nil, nil, 3, nil, nil, 3, nil, 3,
|
135
|
+
3, 3, 3, nil, 3, 3, 3, 3, 3, 3,
|
136
|
+
3, 3, 3, nil, nil, nil, nil, nil, nil, nil,
|
137
|
+
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
|
138
|
+
nil, 3 ]
|
139
|
+
|
140
|
+
racc_goto_pointer = [
|
141
|
+
nil, 1, 2, -2, nil, nil, -18 ]
|
142
|
+
|
143
|
+
racc_goto_default = [
|
144
|
+
nil, nil, nil, nil, 11, 12, nil ]
|
145
|
+
|
146
|
+
racc_reduce_table = [
|
147
|
+
0, 0, :racc_error,
|
148
|
+
1, 35, :_reduce_none,
|
149
|
+
0, 36, :_reduce_2,
|
150
|
+
3, 36, :_reduce_3,
|
151
|
+
2, 36, :_reduce_none,
|
152
|
+
3, 37, :_reduce_5,
|
153
|
+
3, 37, :_reduce_6,
|
154
|
+
3, 37, :_reduce_7,
|
155
|
+
3, 37, :_reduce_8,
|
156
|
+
3, 37, :_reduce_9,
|
157
|
+
3, 37, :_reduce_10,
|
158
|
+
3, 37, :_reduce_11,
|
159
|
+
3, 37, :_reduce_12,
|
160
|
+
3, 37, :_reduce_13,
|
161
|
+
3, 37, :_reduce_14,
|
162
|
+
3, 37, :_reduce_15,
|
163
|
+
3, 37, :_reduce_16,
|
164
|
+
1, 37, :_reduce_none,
|
165
|
+
3, 38, :_reduce_18,
|
166
|
+
2, 38, :_reduce_19,
|
167
|
+
1, 38, :_reduce_none,
|
168
|
+
1, 38, :_reduce_21,
|
169
|
+
1, 38, :_reduce_22,
|
170
|
+
1, 38, :_reduce_23,
|
171
|
+
1, 38, :_reduce_24,
|
172
|
+
1, 38, :_reduce_25,
|
173
|
+
1, 38, :_reduce_26,
|
174
|
+
1, 38, :_reduce_27,
|
175
|
+
1, 38, :_reduce_28,
|
176
|
+
1, 38, :_reduce_29,
|
177
|
+
1, 38, :_reduce_none,
|
178
|
+
4, 39, :_reduce_31,
|
179
|
+
3, 39, :_reduce_32,
|
180
|
+
1, 40, :_reduce_33,
|
181
|
+
3, 40, :_reduce_34 ]
|
182
|
+
|
183
|
+
racc_reduce_n = 35
|
184
|
+
|
185
|
+
racc_shift_n = 56
|
186
|
+
|
187
|
+
racc_token_table = {
|
188
|
+
false => 0,
|
189
|
+
:error => 1,
|
190
|
+
:UMINUS => 2,
|
191
|
+
"^" => 3,
|
192
|
+
"&" => 4,
|
193
|
+
"*" => 5,
|
194
|
+
"/" => 6,
|
195
|
+
"+" => 7,
|
196
|
+
"-" => 8,
|
197
|
+
"<" => 9,
|
198
|
+
">" => 10,
|
199
|
+
"<=" => 11,
|
200
|
+
">=" => 12,
|
201
|
+
"<>" => 13,
|
202
|
+
"=" => 14,
|
203
|
+
:EOL => 15,
|
204
|
+
:LT => 16,
|
205
|
+
:GT => 17,
|
206
|
+
:LE => 18,
|
207
|
+
:GE => 19,
|
208
|
+
:NE => 20,
|
209
|
+
"(" => 21,
|
210
|
+
")" => 22,
|
211
|
+
:FUNC => 23,
|
212
|
+
:NUMBER => 24,
|
213
|
+
:STRING => 25,
|
214
|
+
:REF2D => 26,
|
215
|
+
:REF3D => 27,
|
216
|
+
:RANGE2D => 28,
|
217
|
+
:RANGE3D => 29,
|
218
|
+
:NAME => 30,
|
219
|
+
:TRUE => 31,
|
220
|
+
:FALSE => 32,
|
221
|
+
"," => 33 }
|
222
|
+
|
223
|
+
racc_nt_base = 34
|
224
|
+
|
225
|
+
racc_use_result_var = true
|
226
|
+
|
227
|
+
Racc_arg = [
|
228
|
+
racc_action_table,
|
229
|
+
racc_action_check,
|
230
|
+
racc_action_default,
|
231
|
+
racc_action_pointer,
|
232
|
+
racc_goto_table,
|
233
|
+
racc_goto_check,
|
234
|
+
racc_goto_default,
|
235
|
+
racc_goto_pointer,
|
236
|
+
racc_nt_base,
|
237
|
+
racc_reduce_table,
|
238
|
+
racc_token_table,
|
239
|
+
racc_shift_n,
|
240
|
+
racc_reduce_n,
|
241
|
+
racc_use_result_var ]
|
242
|
+
|
243
|
+
Racc_token_to_s_table = [
|
244
|
+
"$end",
|
245
|
+
"error",
|
246
|
+
"UMINUS",
|
247
|
+
"\"^\"",
|
248
|
+
"\"&\"",
|
249
|
+
"\"*\"",
|
250
|
+
"\"/\"",
|
251
|
+
"\"+\"",
|
252
|
+
"\"-\"",
|
253
|
+
"\"<\"",
|
254
|
+
"\">\"",
|
255
|
+
"\"<=\"",
|
256
|
+
"\">=\"",
|
257
|
+
"\"<>\"",
|
258
|
+
"\"=\"",
|
259
|
+
"EOL",
|
260
|
+
"LT",
|
261
|
+
"GT",
|
262
|
+
"LE",
|
263
|
+
"GE",
|
264
|
+
"NE",
|
265
|
+
"\"(\"",
|
266
|
+
"\")\"",
|
267
|
+
"FUNC",
|
268
|
+
"NUMBER",
|
269
|
+
"STRING",
|
270
|
+
"REF2D",
|
271
|
+
"REF3D",
|
272
|
+
"RANGE2D",
|
273
|
+
"RANGE3D",
|
274
|
+
"NAME",
|
275
|
+
"TRUE",
|
276
|
+
"FALSE",
|
277
|
+
"\",\"",
|
278
|
+
"$start",
|
279
|
+
"formula",
|
280
|
+
"expr_list",
|
281
|
+
"expr",
|
282
|
+
"primary",
|
283
|
+
"funcall",
|
284
|
+
"args" ]
|
285
|
+
|
286
|
+
Racc_debug_parser = false
|
287
|
+
|
288
|
+
##### State transition tables end #####
|
289
|
+
|
290
|
+
# reduce 0 omitted
|
291
|
+
|
292
|
+
# reduce 1 omitted
|
293
|
+
|
294
|
+
module_eval(<<'.,.,', 'excelformula.y', 20)
|
295
|
+
def _reduce_2(val, _values, result)
|
296
|
+
result = []
|
297
|
+
result
|
298
|
+
end
|
299
|
+
.,.,
|
300
|
+
|
301
|
+
module_eval(<<'.,.,', 'excelformula.y', 21)
|
302
|
+
def _reduce_3(val, _values, result)
|
303
|
+
result.push val[1], '_arg', '1'
|
304
|
+
result
|
305
|
+
end
|
306
|
+
.,.,
|
307
|
+
|
308
|
+
# reduce 4 omitted
|
309
|
+
|
310
|
+
module_eval(<<'.,.,', 'excelformula.y', 24)
|
311
|
+
def _reduce_5(val, _values, result)
|
312
|
+
result = [ val[0], val[2], 'ptgAdd' ]
|
313
|
+
result
|
314
|
+
end
|
315
|
+
.,.,
|
316
|
+
|
317
|
+
module_eval(<<'.,.,', 'excelformula.y', 25)
|
318
|
+
def _reduce_6(val, _values, result)
|
319
|
+
result = [ val[0], val[2], 'ptgSub' ]
|
320
|
+
result
|
321
|
+
end
|
322
|
+
.,.,
|
323
|
+
|
324
|
+
module_eval(<<'.,.,', 'excelformula.y', 26)
|
325
|
+
def _reduce_7(val, _values, result)
|
326
|
+
result = [ val[0], val[2], 'ptgMul' ]
|
327
|
+
result
|
328
|
+
end
|
329
|
+
.,.,
|
330
|
+
|
331
|
+
module_eval(<<'.,.,', 'excelformula.y', 27)
|
332
|
+
def _reduce_8(val, _values, result)
|
333
|
+
result = [ val[0], val[2], 'ptgDiv' ]
|
334
|
+
result
|
335
|
+
end
|
336
|
+
.,.,
|
337
|
+
|
338
|
+
module_eval(<<'.,.,', 'excelformula.y', 28)
|
339
|
+
def _reduce_9(val, _values, result)
|
340
|
+
result = [ val[0], val[2], 'ptgPower' ]
|
341
|
+
result
|
342
|
+
end
|
343
|
+
.,.,
|
344
|
+
|
345
|
+
module_eval(<<'.,.,', 'excelformula.y', 29)
|
346
|
+
def _reduce_10(val, _values, result)
|
347
|
+
result = [ val[0], val[2], 'ptgConcat' ]
|
348
|
+
result
|
349
|
+
end
|
350
|
+
.,.,
|
351
|
+
|
352
|
+
module_eval(<<'.,.,', 'excelformula.y', 30)
|
353
|
+
def _reduce_11(val, _values, result)
|
354
|
+
result = [ val[0], val[2], 'ptgLT' ]
|
355
|
+
result
|
356
|
+
end
|
357
|
+
.,.,
|
358
|
+
|
359
|
+
module_eval(<<'.,.,', 'excelformula.y', 31)
|
360
|
+
def _reduce_12(val, _values, result)
|
361
|
+
result = [ val[0], val[2], 'ptgGT' ]
|
362
|
+
result
|
363
|
+
end
|
364
|
+
.,.,
|
365
|
+
|
366
|
+
module_eval(<<'.,.,', 'excelformula.y', 32)
|
367
|
+
def _reduce_13(val, _values, result)
|
368
|
+
result = [ val[0], val[2], 'ptgLE' ]
|
369
|
+
result
|
370
|
+
end
|
371
|
+
.,.,
|
372
|
+
|
373
|
+
module_eval(<<'.,.,', 'excelformula.y', 33)
|
374
|
+
def _reduce_14(val, _values, result)
|
375
|
+
result = [ val[0], val[2], 'ptgGE' ]
|
376
|
+
result
|
377
|
+
end
|
378
|
+
.,.,
|
379
|
+
|
380
|
+
module_eval(<<'.,.,', 'excelformula.y', 34)
|
381
|
+
def _reduce_15(val, _values, result)
|
382
|
+
result = [ val[0], val[2], 'ptgNE' ]
|
383
|
+
result
|
384
|
+
end
|
385
|
+
.,.,
|
386
|
+
|
387
|
+
module_eval(<<'.,.,', 'excelformula.y', 35)
|
388
|
+
def _reduce_16(val, _values, result)
|
389
|
+
result = [ val[0], val[2], 'ptgEQ' ]
|
390
|
+
result
|
391
|
+
end
|
392
|
+
.,.,
|
393
|
+
|
394
|
+
# reduce 17 omitted
|
395
|
+
|
396
|
+
module_eval(<<'.,.,', 'excelformula.y', 38)
|
397
|
+
def _reduce_18(val, _values, result)
|
398
|
+
result = [ val[1], '_arg', '1', 'ptgParen']
|
399
|
+
result
|
400
|
+
end
|
401
|
+
.,.,
|
402
|
+
|
403
|
+
module_eval(<<'.,.,', 'excelformula.y', 39)
|
404
|
+
def _reduce_19(val, _values, result)
|
405
|
+
result = [ '_num', '-1', val[1], 'ptgMul' ]
|
406
|
+
result
|
407
|
+
end
|
408
|
+
.,.,
|
409
|
+
|
410
|
+
# reduce 20 omitted
|
411
|
+
|
412
|
+
module_eval(<<'.,.,', 'excelformula.y', 41)
|
413
|
+
def _reduce_21(val, _values, result)
|
414
|
+
result = [ '_num', val[0] ]
|
415
|
+
result
|
416
|
+
end
|
417
|
+
.,.,
|
418
|
+
|
419
|
+
module_eval(<<'.,.,', 'excelformula.y', 42)
|
420
|
+
def _reduce_22(val, _values, result)
|
421
|
+
result = [ '_str', val[0] ]
|
422
|
+
result
|
423
|
+
end
|
424
|
+
.,.,
|
425
|
+
|
426
|
+
module_eval(<<'.,.,', 'excelformula.y', 43)
|
427
|
+
def _reduce_23(val, _values, result)
|
428
|
+
result = [ '_ref2d', val[0] ]
|
429
|
+
result
|
430
|
+
end
|
431
|
+
.,.,
|
432
|
+
|
433
|
+
module_eval(<<'.,.,', 'excelformula.y', 44)
|
434
|
+
def _reduce_24(val, _values, result)
|
435
|
+
result = [ '_ref3d', val[0] ]
|
436
|
+
result
|
437
|
+
end
|
438
|
+
.,.,
|
439
|
+
|
440
|
+
module_eval(<<'.,.,', 'excelformula.y', 45)
|
441
|
+
def _reduce_25(val, _values, result)
|
442
|
+
result = [ '_range2d', val[0] ]
|
443
|
+
result
|
444
|
+
end
|
445
|
+
.,.,
|
446
|
+
|
447
|
+
module_eval(<<'.,.,', 'excelformula.y', 46)
|
448
|
+
def _reduce_26(val, _values, result)
|
449
|
+
result = [ '_range3d', val[0] ]
|
450
|
+
result
|
451
|
+
end
|
452
|
+
.,.,
|
453
|
+
|
454
|
+
module_eval(<<'.,.,', 'excelformula.y', 47)
|
455
|
+
def _reduce_27(val, _values, result)
|
456
|
+
result = [ '_name', val[0] ]
|
457
|
+
result
|
458
|
+
end
|
459
|
+
.,.,
|
460
|
+
|
461
|
+
module_eval(<<'.,.,', 'excelformula.y', 48)
|
462
|
+
def _reduce_28(val, _values, result)
|
463
|
+
result = [ 'ptgBool', '1' ]
|
464
|
+
result
|
465
|
+
end
|
466
|
+
.,.,
|
467
|
+
|
468
|
+
module_eval(<<'.,.,', 'excelformula.y', 49)
|
469
|
+
def _reduce_29(val, _values, result)
|
470
|
+
result = [ 'ptgBool', '0' ]
|
471
|
+
result
|
472
|
+
end
|
473
|
+
.,.,
|
474
|
+
|
475
|
+
# reduce 30 omitted
|
476
|
+
|
477
|
+
module_eval(<<'.,.,', 'excelformula.y', 52)
|
478
|
+
def _reduce_31(val, _values, result)
|
479
|
+
result = [ '_class', val[0], val[2], '_arg', val[2].size.to_s, '_func', val[0] ]
|
480
|
+
result
|
481
|
+
end
|
482
|
+
.,.,
|
483
|
+
|
484
|
+
module_eval(<<'.,.,', 'excelformula.y', 53)
|
485
|
+
def _reduce_32(val, _values, result)
|
486
|
+
result = [ '_func', val[0] ]
|
487
|
+
result
|
488
|
+
end
|
489
|
+
.,.,
|
490
|
+
|
491
|
+
module_eval(<<'.,.,', 'excelformula.y', 55)
|
492
|
+
def _reduce_33(val, _values, result)
|
493
|
+
result = val
|
494
|
+
result
|
495
|
+
end
|
496
|
+
.,.,
|
497
|
+
|
498
|
+
module_eval(<<'.,.,', 'excelformula.y', 56)
|
499
|
+
def _reduce_34(val, _values, result)
|
500
|
+
result.push val[2]
|
501
|
+
result
|
502
|
+
end
|
503
|
+
.,.,
|
504
|
+
|
505
|
+
def _reduce_none(val, _values, result)
|
506
|
+
val[0]
|
507
|
+
end
|
508
|
+
|
509
|
+
end # class ExcelFormulaParser
|
510
|
+
|
511
|
+
|
512
|
+
class ExcelFormulaParserError < StandardError #:nodoc:
|
513
|
+
end
|
514
|
+
|
515
|
+
class Node # :nodoc:
|
516
|
+
|
517
|
+
def exec_list(nodes)
|
518
|
+
v = nil
|
519
|
+
nodes.each { |i| v = i.evaluate }
|
520
|
+
v
|
521
|
+
end
|
522
|
+
|
523
|
+
def excelformulaparser_error(msg)
|
524
|
+
raise ExcelFormulaParserError,
|
525
|
+
"in #{fname}:#{lineno}: #{msg}"
|
526
|
+
end
|
527
|
+
|
528
|
+
end
|
529
|
+
|
530
|
+
class RootNode < Node # :nodoc:
|
531
|
+
|
532
|
+
def initialize(tree)
|
533
|
+
@tree = tree
|
534
|
+
end
|
535
|
+
|
536
|
+
def evaluate
|
537
|
+
exec_list @tree
|
538
|
+
end
|
539
|
+
|
540
|
+
end
|
541
|
+
|
542
|
+
|
543
|
+
class FuncallNode < Node # :nodoc:
|
544
|
+
|
545
|
+
def initialize(func, args)
|
546
|
+
@func = func
|
547
|
+
@args = args
|
548
|
+
end
|
549
|
+
|
550
|
+
def evaluate
|
551
|
+
arg = @args.collect {|i| i.evaluate }
|
552
|
+
out = []
|
553
|
+
arg.each { |i| o.push i }
|
554
|
+
o.push @func
|
555
|
+
p o
|
556
|
+
end
|
557
|
+
|
558
|
+
end
|
559
|
+
|
560
|
+
class NumberNode < Node # :nodoc:
|
561
|
+
|
562
|
+
def initialize(val)
|
563
|
+
@val = val
|
564
|
+
end
|
565
|
+
|
566
|
+
def evaluate
|
567
|
+
p @val
|
568
|
+
end
|
569
|
+
|
570
|
+
end
|
571
|
+
|
572
|
+
class OperateNode < Node # :nodoc:
|
573
|
+
|
574
|
+
def initialize(op, left, right)
|
575
|
+
@op = op
|
576
|
+
@left = left
|
577
|
+
@right = right
|
578
|
+
end
|
579
|
+
|
580
|
+
def evaluate
|
581
|
+
o = []
|
582
|
+
o.push @left
|
583
|
+
o.push @right
|
584
|
+
o.push @op
|
585
|
+
p o
|
586
|
+
end
|
587
|
+
end
|