surpass 0.0.4 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (259) hide show
  1. data/History.txt +4 -0
  2. data/README.txt +3 -20
  3. data/Rakefile +2 -13
  4. data/bin/surpass +8 -0
  5. data/examples/big-16mb.rb +25 -0
  6. data/examples/big-random-strings.rb +28 -0
  7. data/examples/blanks.rb +34 -0
  8. data/examples/blanks.xls +0 -0
  9. data/examples/col_width.rb +16 -0
  10. data/examples/col_width.xls +0 -0
  11. data/examples/dates.rb +31 -0
  12. data/examples/dates.xls +0 -0
  13. data/examples/format.rb +23 -0
  14. data/examples/format.xls +0 -0
  15. data/examples/hello-world.rb +9 -0
  16. data/examples/hello-world.xls +0 -0
  17. data/examples/image.rb +10 -0
  18. data/examples/image.xls +0 -0
  19. data/examples/merged.rb +36 -0
  20. data/examples/merged.xls +0 -0
  21. data/examples/merged0.rb +27 -0
  22. data/examples/merged0.xls +0 -0
  23. data/examples/merged1.rb +99 -0
  24. data/examples/merged1.xls +0 -0
  25. data/examples/num_formats.rb +55 -0
  26. data/examples/num_formats.xls +0 -0
  27. data/examples/numbers.rb +24 -0
  28. data/examples/numbers.xls +0 -0
  29. data/examples/outline.rb +110 -0
  30. data/examples/outline.xls +0 -0
  31. data/examples/panes.rb +48 -0
  32. data/examples/panes.xls +0 -0
  33. data/examples/protection.rb +132 -0
  34. data/examples/protection.xls +0 -0
  35. data/examples/python.bmp +0 -0
  36. data/examples/row_styles.rb +16 -0
  37. data/examples/row_styles.xls +0 -0
  38. data/examples/row_styles_empty.rb +15 -0
  39. data/examples/row_styles_empty.xls +0 -0
  40. data/examples/set_cell_and_range_style.rb +12 -0
  41. data/examples/set_cell_and_range_style.xls +0 -0
  42. data/examples/wrapped-text.rb +13 -0
  43. data/examples/wrapped-text.xls +0 -0
  44. data/examples/write_arrays.rb +22 -0
  45. data/examples/write_arrays.xls +0 -0
  46. data/examples/ws_props.rb +80 -0
  47. data/lib/surpass/ExcelFormula.g +366 -0
  48. data/lib/surpass/ExcelFormula.tokens +30 -0
  49. data/lib/surpass/ExcelFormulaLexer.rb +922 -0
  50. data/lib/surpass/ExcelFormulaParser.rb +602 -0
  51. data/lib/{biff_record.rb → surpass/biff_record.rb} +0 -0
  52. data/lib/{bitmap.rb → surpass/bitmap.rb} +0 -0
  53. data/lib/{cell.rb → surpass/cell.rb} +2 -34
  54. data/lib/{chart.rb → surpass/chart.rb} +0 -0
  55. data/lib/{column.rb → surpass/column.rb} +0 -0
  56. data/lib/{document.rb → surpass/document.rb} +0 -0
  57. data/lib/surpass/excel_formula.rb +23 -0
  58. data/lib/{excel_magic.rb → surpass/excel_magic.rb} +0 -0
  59. data/lib/{formatting.rb → surpass/formatting.rb} +93 -53
  60. data/lib/{row.rb → surpass/row.rb} +0 -0
  61. data/lib/{style.rb → surpass/style.rb} +2 -1
  62. data/lib/surpass/tokens.txt +2 -0
  63. data/lib/{utilities.rb → surpass/utilities.rb} +0 -0
  64. data/lib/{workbook.rb → surpass/workbook.rb} +0 -0
  65. data/lib/{worksheet.rb → surpass/worksheet.rb} +15 -6
  66. data/lib/surpass.rb +1 -1
  67. data/spec/biff_record_spec.rb +268 -0
  68. data/spec/cell_spec.rb +56 -0
  69. data/spec/data/random-strings.txt +10000 -0
  70. data/spec/document_spec.rb +168 -0
  71. data/spec/excel_formula_spec.rb +27 -0
  72. data/spec/formatting_spec.rb +53 -0
  73. data/spec/output/cells-rk.xls +0 -0
  74. data/spec/output/cells.xls +0 -0
  75. data/spec/output/mini.xls +0 -0
  76. data/spec/reference/P-0508-0000507647-3280-5298.xls +0 -0
  77. data/spec/reference/all-cell-styles.bin +0 -0
  78. data/spec/reference/all-number-formats.bin +0 -0
  79. data/spec/reference/all-styles.bin +0 -0
  80. data/spec/reference/mini.xls +0 -0
  81. data/spec/row_spec.rb +19 -0
  82. data/spec/spec_helper.rb +10 -0
  83. data/spec/style_spec.rb +89 -0
  84. data/spec/surpass_spec.rb +7 -0
  85. data/spec/utilities_spec.rb +57 -0
  86. data/spec/workbook_spec.rb +48 -0
  87. data/spec/worksheet_spec.rb +0 -0
  88. data/stats/cloc.txt +8 -0
  89. data/stats/rcov.txt +0 -0
  90. data/stats/specdoc.txt +158 -0
  91. data/surpass.gemspec +40 -0
  92. data/tasks/setup.rb +1 -1
  93. data/tasks/zentest.rake +36 -0
  94. data/webby/README.txt +6 -0
  95. data/webby/Sitefile +43 -0
  96. data/webby/content/css/pygments.txt +6 -0
  97. data/webby/content/css/style.css +279 -0
  98. data/webby/content/examples/autoformat.png +0 -0
  99. data/webby/content/examples/autoformat.rb +32 -0
  100. data/webby/content/examples/autoformat.xls +0 -0
  101. data/webby/content/examples/borders.png +0 -0
  102. data/webby/content/examples/borders.rb +15 -0
  103. data/webby/content/examples/borders.xls +0 -0
  104. data/webby/content/examples/colours.png +0 -0
  105. data/webby/content/examples/colours.rb +23 -0
  106. data/webby/content/examples/colours.xls +0 -0
  107. data/webby/content/examples/data.png +0 -0
  108. data/webby/content/examples/data.rb +11 -0
  109. data/webby/content/examples/data.xls +0 -0
  110. data/webby/content/examples/formatting.png +0 -0
  111. data/webby/content/examples/formatting.rb +78 -0
  112. data/webby/content/examples/formatting.xls +0 -0
  113. data/webby/content/examples/hello-world.png +0 -0
  114. data/webby/content/examples/hello-world.py +8 -0
  115. data/webby/content/examples/hello-world.rb +9 -0
  116. data/webby/content/examples/hello-world.xls +0 -0
  117. data/webby/content/examples/number-format-string.png +0 -0
  118. data/webby/content/examples/number-format-string.rb +14 -0
  119. data/webby/content/examples/number-format-string.xls +0 -0
  120. data/webby/content/examples/patterns.png +0 -0
  121. data/webby/content/examples/patterns.rb +26 -0
  122. data/webby/content/examples/patterns.xls +0 -0
  123. data/webby/content/examples/show-greens.sh +1 -0
  124. data/webby/content/examples/surpass-info.sh +1 -0
  125. data/webby/content/img/Thumbs.db +0 -0
  126. data/webby/content/img/bg_menu.gif +0 -0
  127. data/webby/content/img/bg_t.gif +0 -0
  128. data/webby/content/img/bullet.gif +0 -0
  129. data/webby/content/img/logo.png +0 -0
  130. data/webby/content/img/logo_.jpg +0 -0
  131. data/webby/content/img/top_bg.gif +0 -0
  132. data/webby/content/img/top_bg_.gif +0 -0
  133. data/webby/content/index.txt +16 -0
  134. data/webby/content/installation/index.txt +24 -0
  135. data/webby/content/source/ExcelFormulaLexer.txt +7 -0
  136. data/webby/content/source/ExcelFormulaParser.txt +7 -0
  137. data/webby/content/source/biff_record.txt +7 -0
  138. data/webby/content/source/bitmap.txt +7 -0
  139. data/webby/content/source/cell.txt +7 -0
  140. data/webby/content/source/chart.txt +7 -0
  141. data/webby/content/source/column.txt +7 -0
  142. data/webby/content/source/document.txt +7 -0
  143. data/webby/content/source/excel_formula.txt +7 -0
  144. data/webby/content/source/excel_magic.txt +7 -0
  145. data/webby/content/source/formatting.txt +7 -0
  146. data/webby/content/source/row.txt +7 -0
  147. data/webby/content/source/style.txt +7 -0
  148. data/webby/content/source/utilities.txt +7 -0
  149. data/webby/content/source/workbook.txt +7 -0
  150. data/webby/content/source/worksheet.txt +7 -0
  151. data/webby/content/surpass-manual.erb +198 -0
  152. data/webby/layouts/book.txt +29 -0
  153. data/webby/layouts/default.txt +27 -0
  154. data/webby/layouts/two_column.txt +25 -0
  155. data/webby/layouts/web.txt +66 -0
  156. data/webby/output/.cairn +0 -0
  157. data/webby/output/css/blueprint/ie.css +26 -0
  158. data/webby/output/css/blueprint/plugins/buttons/icons/cross.png +0 -0
  159. data/webby/output/css/blueprint/plugins/buttons/icons/key.png +0 -0
  160. data/webby/output/css/blueprint/plugins/buttons/icons/tick.png +0 -0
  161. data/webby/output/css/blueprint/plugins/buttons/readme.txt +32 -0
  162. data/webby/output/css/blueprint/plugins/buttons/screen.css +97 -0
  163. data/webby/output/css/blueprint/plugins/fancy-type/readme.txt +14 -0
  164. data/webby/output/css/blueprint/plugins/fancy-type/screen.css +71 -0
  165. data/webby/output/css/blueprint/plugins/link-icons/icons/doc.png +0 -0
  166. data/webby/output/css/blueprint/plugins/link-icons/icons/email.png +0 -0
  167. data/webby/output/css/blueprint/plugins/link-icons/icons/external.png +0 -0
  168. data/webby/output/css/blueprint/plugins/link-icons/icons/feed.png +0 -0
  169. data/webby/output/css/blueprint/plugins/link-icons/icons/im.png +0 -0
  170. data/webby/output/css/blueprint/plugins/link-icons/icons/pdf.png +0 -0
  171. data/webby/output/css/blueprint/plugins/link-icons/icons/visited.png +0 -0
  172. data/webby/output/css/blueprint/plugins/link-icons/icons/xls.png +0 -0
  173. data/webby/output/css/blueprint/plugins/link-icons/readme.txt +18 -0
  174. data/webby/output/css/blueprint/plugins/link-icons/screen.css +40 -0
  175. data/webby/output/css/blueprint/plugins/rtl/readme.txt +10 -0
  176. data/webby/output/css/blueprint/plugins/rtl/screen.css +109 -0
  177. data/webby/output/css/blueprint/print.css +30 -0
  178. data/webby/output/css/blueprint/screen.css +251 -0
  179. data/webby/output/css/blueprint/src/forms.css +49 -0
  180. data/webby/output/css/blueprint/src/grid.css +212 -0
  181. data/webby/output/css/blueprint/src/grid.png +0 -0
  182. data/webby/output/css/blueprint/src/ie.css +59 -0
  183. data/webby/output/css/blueprint/src/print.css +85 -0
  184. data/webby/output/css/blueprint/src/reset.css +38 -0
  185. data/webby/output/css/blueprint/src/typography.css +105 -0
  186. data/webby/output/css/pygments.css +59 -0
  187. data/webby/output/css/site.css +62 -0
  188. data/webby/output/css/style.css +279 -0
  189. data/webby/output/examples/autoformat.png +0 -0
  190. data/webby/output/examples/autoformat.rb +32 -0
  191. data/webby/output/examples/autoformat.xls +0 -0
  192. data/webby/output/examples/borders.png +0 -0
  193. data/webby/output/examples/borders.rb +15 -0
  194. data/webby/output/examples/borders.xls +0 -0
  195. data/webby/output/examples/colours.png +0 -0
  196. data/webby/output/examples/colours.rb +23 -0
  197. data/webby/output/examples/colours.xls +0 -0
  198. data/webby/output/examples/data.png +0 -0
  199. data/webby/output/examples/data.rb +11 -0
  200. data/webby/output/examples/data.xls +0 -0
  201. data/webby/output/examples/formatting.png +0 -0
  202. data/webby/output/examples/formatting.rb +78 -0
  203. data/webby/output/examples/formatting.xls +0 -0
  204. data/webby/output/examples/hello-world.png +0 -0
  205. data/webby/output/examples/hello-world.py +8 -0
  206. data/webby/output/examples/hello-world.rb +9 -0
  207. data/webby/output/examples/hello-world.xls +0 -0
  208. data/webby/output/examples/number-format-string.png +0 -0
  209. data/webby/output/examples/number-format-string.rb +14 -0
  210. data/webby/output/examples/number-format-string.xls +0 -0
  211. data/webby/output/examples/patterns.png +0 -0
  212. data/webby/output/examples/patterns.rb +26 -0
  213. data/webby/output/examples/patterns.xls +0 -0
  214. data/webby/output/examples/show-greens.sh +1 -0
  215. data/webby/output/examples/surpass-info.sh +1 -0
  216. data/webby/output/img/Thumbs.db +0 -0
  217. data/webby/output/img/bg_menu.gif +0 -0
  218. data/webby/output/img/bg_t.gif +0 -0
  219. data/webby/output/img/bullet.gif +0 -0
  220. data/webby/output/img/logo.png +0 -0
  221. data/webby/output/img/logo_.jpg +0 -0
  222. data/webby/output/img/top_bg.gif +0 -0
  223. data/webby/output/img/top_bg_.gif +0 -0
  224. data/webby/output/index.html +138 -0
  225. data/webby/output/installation/index.html +64 -0
  226. data/webby/output/installation/installation.html +1 -0
  227. data/webby/output/installation.html +1 -0
  228. data/webby/output/source/ExcelFormulaLexer.html +981 -0
  229. data/webby/output/source/ExcelFormulaParser.html +661 -0
  230. data/webby/output/source/biff_record.html +462 -0
  231. data/webby/output/source/bitmap.html +277 -0
  232. data/webby/output/source/cell.html +241 -0
  233. data/webby/output/source/chart.html +64 -0
  234. data/webby/output/source/column.html +99 -0
  235. data/webby/output/source/document.html +465 -0
  236. data/webby/output/source/excel_formula.html +82 -0
  237. data/webby/output/source/excel_magic.html +1072 -0
  238. data/webby/output/source/formatting.html +664 -0
  239. data/webby/output/source/row.html +169 -0
  240. data/webby/output/source/style.html +158 -0
  241. data/webby/output/source/surpass.html +110 -0
  242. data/webby/output/source/utilities.html +145 -0
  243. data/webby/output/source/workbook.html +265 -0
  244. data/webby/output/source/worksheet.html +331 -0
  245. data/webby/output/surpass-manual-0-0-5.pdf +0 -0
  246. data/webby/output/surpass-manual.aux +50 -0
  247. data/webby/output/surpass-manual.log +366 -0
  248. data/webby/output/surpass-manual.out +20 -0
  249. data/webby/output/surpass-manual.tex +582 -0
  250. data/webby/output/surpass-manual.toc +20 -0
  251. data/webby/rsync-exclude +7 -0
  252. data/webby/tasks/latex.rake +14 -0
  253. data/webby/tasks/screenshots.rb +58 -0
  254. data/webby/templates/article.erb +15 -0
  255. data/webby/templates/book.erb +16 -0
  256. data/webby/templates/page.erb +9 -0
  257. metadata +302 -24
  258. data/bin/surpass-info +0 -20
  259. data/lib/excel_formula.rb +0 -6
@@ -0,0 +1,922 @@
1
+ # ExcelFormulaLexer (ExcelFormula.g)
2
+ # Generated by ANTLR 3.1.2-2008-10-21 on 2009-06-15 23:03:59
3
+
4
+ class ExcelFormulaLexer
5
+ require 'stringio'
6
+
7
+ COMMA=25
8
+ TRUE_CONST=12
9
+ PERCENT=11
10
+ POWER=10
11
+ FUNC_CHOOSE=33
12
+ BANG=28
13
+ EQ=4
14
+ QUOTENAME=31
15
+ LT=19
16
+ NE=21
17
+ GT=20
18
+ FUNC_IF=32
19
+ RP=27
20
+ FALSE_CONST=13
21
+ LP=26
22
+ GE=23
23
+ MUL=8
24
+ NUM_CONST=16
25
+ REF2D=17
26
+ SEMICOLON=24
27
+ CONCAT=5
28
+ EOF=-1
29
+ LE=22
30
+ INT_CONST=15
31
+ STR_CONST=14
32
+ COLON=18
33
+ DIV=9
34
+ DIGIT=29
35
+ SUB=7
36
+ NAME=30
37
+ ADD=6
38
+
39
+ def initialize(input)
40
+ input = StringIO.new(input) if input.respond_to?(:to_str)
41
+ @input = CharStream.new(input)
42
+ @backtracking = 0
43
+ @failed = false
44
+
45
+ end
46
+
47
+ def next_token
48
+ # TODO: catch exceptions
49
+ @token = nil
50
+ @channel = nil
51
+ @text = nil
52
+
53
+ @start = @input.index
54
+ @line = @input.line
55
+ @pos = @input.column
56
+
57
+ @type = nil
58
+ @type_int = nil
59
+
60
+ return :EOF if @input.look_ahead(1) == :EOF
61
+
62
+ match_Tokens()
63
+
64
+ if @token == nil
65
+ @text ||= @input.substring(@start, @input.index - 1)
66
+ @token = Token.new(@type, @type_int, @line, @pos, @text, @channel)
67
+ end
68
+
69
+ return @token
70
+ end
71
+
72
+ class Token
73
+ attr_reader :token_type
74
+ attr_reader :int_type
75
+ attr_reader :line
76
+ attr_reader :pos
77
+ attr_reader :text
78
+ attr_reader :channel
79
+
80
+ def initialize(token_type, int_type, line, pos, text, channel = nil)
81
+ @token_type = token_type
82
+ @int_type = int_type
83
+ @line = line
84
+ @pos = pos
85
+ @text = text
86
+ @channel = channel
87
+ end
88
+
89
+ alias :to_i :int_type
90
+ end
91
+
92
+
93
+ private
94
+
95
+ class CharStream
96
+ attr_reader :line
97
+ attr_reader :column
98
+ attr_reader :index
99
+
100
+ def initialize(input)
101
+ @buffer = ""
102
+ @input = input
103
+ @line = 1
104
+ @column = 0
105
+
106
+ @index = 0;
107
+ end
108
+
109
+ # returns a Fixnum between 0 and 0xFFFF or :EOF
110
+ def look_ahead(pos)
111
+ offset = @index + pos - 1
112
+ if @buffer.length < offset + 1
113
+ char = @input.read(offset + 1 - @buffer.length)
114
+ @buffer << char if not char.nil?
115
+ end
116
+
117
+ if offset < @buffer.length
118
+ @buffer[offset]
119
+ else
120
+ :EOF
121
+ end
122
+ end
123
+
124
+ def mark
125
+ @state = { :index => @index, :line => @line, :column => @column }
126
+ return 0
127
+ end
128
+
129
+ def rewind(marker)
130
+ @index = @state[:index]
131
+ @line = @state[:line]
132
+ @column = @state[:column]
133
+ end
134
+
135
+ def consume
136
+ look_ahead(1) # force a read from the input if necessary
137
+ @column = @column + 1
138
+ if @buffer[@index] == ?\n
139
+ @line = @line + 1
140
+ @column = 0
141
+ end
142
+ @index = @index + 1
143
+ end
144
+
145
+ def substring(start, stop)
146
+ @buffer.slice(start, stop - start + 1)
147
+ end
148
+ end
149
+
150
+
151
+ def match(value = nil)
152
+ @failed = false
153
+ case
154
+ when value.nil?
155
+ @input.consume()
156
+ when value.respond_to?(:to_str)
157
+ catch(:done) do
158
+ value.each_byte do |c|
159
+ @failed ||= !(@input.look_ahead(1) == c)
160
+ @input.consume() if !@failed
161
+ throw :done if @failed
162
+ end
163
+ end
164
+ else
165
+ @failed = !(@input.look_ahead(1) == value)
166
+ @input.consume() if !@failed
167
+ end
168
+
169
+ if @failed && @backtracking <= 0
170
+ raise "Expected #{value.respond_to?(:chr) ? value.chr : value}"
171
+ end
172
+ end
173
+
174
+ def match_range(from, to)
175
+ char = @input.look_ahead(1)
176
+
177
+ if char != :EOF && (char >= from || char <= to)
178
+ @failed = false
179
+ match()
180
+ elsif @backtracking > 0
181
+ @failed = true
182
+ else
183
+ raise "Expected [#{from.chr}..#{to.chr}]"
184
+ end
185
+ end
186
+
187
+ def match_EQ()
188
+
189
+ # 332:5: '='
190
+ match(?=)
191
+
192
+ end
193
+
194
+ def match_LT()
195
+
196
+ @type = :LT
197
+ @type_int = LT
198
+ # 333:5: '<'
199
+ match(?<)
200
+ end
201
+
202
+ def match_GT()
203
+
204
+ @type = :GT
205
+ @type_int = GT
206
+ # 334:5: '>'
207
+ match(?>)
208
+ end
209
+
210
+ def match_NE()
211
+
212
+ @type = :NE
213
+ @type_int = NE
214
+ # 335:5: '<>'
215
+ match("<>")
216
+
217
+ end
218
+
219
+ def match_LE()
220
+
221
+ @type = :LE
222
+ @type_int = LE
223
+ # 336:5: '<='
224
+ match("<=")
225
+
226
+ end
227
+
228
+ def match_GE()
229
+
230
+ @type = :GE
231
+ @type_int = GE
232
+ # 337:5: '>='
233
+ match(">=")
234
+
235
+ end
236
+
237
+ def match_ADD()
238
+
239
+ @type = :ADD
240
+ @type_int = ADD
241
+ # 339:6: '+'
242
+ match(?+)
243
+ end
244
+
245
+ def match_SUB()
246
+
247
+ @type = :SUB
248
+ @type_int = SUB
249
+ # 340:6: '-'
250
+ match(?-)
251
+ end
252
+
253
+ def match_MUL()
254
+
255
+ @type = :MUL
256
+ @type_int = MUL
257
+ # 341:6: '*'
258
+ match(?*)
259
+ end
260
+
261
+ def match_DIV()
262
+
263
+ @type = :DIV
264
+ @type_int = DIV
265
+ # 342:6: '/'
266
+ match(?/)
267
+ end
268
+
269
+ def match_COLON()
270
+
271
+ @type = :COLON
272
+ @type_int = COLON
273
+ # 344:8: ':'
274
+ match(?:)
275
+ end
276
+
277
+ def match_SEMICOLON()
278
+
279
+ @type = :SEMICOLON
280
+ @type_int = SEMICOLON
281
+ # 345:12: ';'
282
+ match(?;)
283
+ end
284
+
285
+ def match_COMMA()
286
+
287
+ @type = :COMMA
288
+ @type_int = COMMA
289
+ # 346:8: ','
290
+ match(?,)
291
+ end
292
+
293
+ def match_LP()
294
+
295
+ @type = :LP
296
+ @type_int = LP
297
+ # 348:5: '('
298
+ match(?()
299
+ end
300
+
301
+ def match_RP()
302
+
303
+ @type = :RP
304
+ @type_int = RP
305
+ # 349:5: ')'
306
+ match(?))
307
+ end
308
+
309
+ def match_CONCAT()
310
+
311
+ @type = :CONCAT
312
+ @type_int = CONCAT
313
+ # 350:9: '&'
314
+ match(?&)
315
+ end
316
+
317
+ def match_PERCENT()
318
+
319
+ @type = :PERCENT
320
+ @type_int = PERCENT
321
+ # 351:10: '%'
322
+ match(?%)
323
+ end
324
+
325
+ def match_POWER()
326
+
327
+ @type = :POWER
328
+ @type_int = POWER
329
+ # 352:8: '^'
330
+ match(?^)
331
+ end
332
+
333
+ def match_BANG()
334
+
335
+ @type = :BANG
336
+ @type_int = BANG
337
+ # 353:7: '!'
338
+ match(?!)
339
+ end
340
+
341
+ def match_DIGIT()
342
+
343
+ @type = :DIGIT
344
+ @type_int = DIGIT
345
+ # 355:8: '0' .. '9'
346
+ match_range(?0, ?9)
347
+ end
348
+
349
+ def match_INT_CONST()
350
+
351
+ @type = :INT_CONST
352
+ @type_int = INT_CONST
353
+ # 357:12: ( DIGIT )+
354
+ # 357:12: ( DIGIT )+
355
+ matchedOnce1 = false
356
+ while true
357
+ alt1 = 2
358
+ #
359
+ look_ahead1_0 = @input.look_ahead(1)
360
+ look_ahead1_0 = -1 if look_ahead1_0 == :EOF
361
+ if (look_ahead1_0 >= ?0 && look_ahead1_0 <= ?9)
362
+ alt1 = 1
363
+ end
364
+ case alt1
365
+ when 1
366
+ # 357:12: DIGIT
367
+ match_DIGIT()
368
+ else
369
+ break
370
+ end
371
+ matchedOnce1 = true
372
+ end
373
+
374
+ if !matchedOnce1
375
+ raise "Expected at least one match: 357:12: ( DIGIT )+"
376
+ end
377
+ end
378
+
379
+ def match_NUM_CONST()
380
+
381
+ @type = :NUM_CONST
382
+ @type_int = NUM_CONST
383
+ # 358:12: ( DIGIT )* '.' ( DIGIT )+ ( ( 'E' | 'e' ) ( '+' | '-' )? ( DIGIT )+ )?
384
+ # 358:12: ( DIGIT )*
385
+ while true
386
+ alt2 = 2
387
+ #
388
+ look_ahead2_0 = @input.look_ahead(1)
389
+ look_ahead2_0 = -1 if look_ahead2_0 == :EOF
390
+ if (look_ahead2_0 >= ?0 && look_ahead2_0 <= ?9)
391
+ alt2 = 1
392
+ end
393
+ case alt2
394
+ when 1
395
+ # 358:12: DIGIT
396
+ match_DIGIT()
397
+ else
398
+ break
399
+ end
400
+ end
401
+ match(?.)
402
+ # 358:23: ( DIGIT )+
403
+ matchedOnce3 = false
404
+ while true
405
+ alt3 = 2
406
+ #
407
+ look_ahead3_0 = @input.look_ahead(1)
408
+ look_ahead3_0 = -1 if look_ahead3_0 == :EOF
409
+ if (look_ahead3_0 >= ?0 && look_ahead3_0 <= ?9)
410
+ alt3 = 1
411
+ end
412
+ case alt3
413
+ when 1
414
+ # 358:23: DIGIT
415
+ match_DIGIT()
416
+ else
417
+ break
418
+ end
419
+ matchedOnce3 = true
420
+ end
421
+
422
+ if !matchedOnce3
423
+ raise "Expected at least one match: 358:23: ( DIGIT )+"
424
+ end
425
+ # 358:30: ( ( 'E' | 'e' ) ( '+' | '-' )? ( DIGIT )+ )?
426
+ alt6 = 2
427
+ #
428
+ look_ahead6_0 = @input.look_ahead(1)
429
+
430
+ look_ahead6_0 = -1 if look_ahead6_0 == :EOF
431
+ if look_ahead6_0 == ?E || look_ahead6_0 == ?e
432
+ alt6 = 1
433
+ end
434
+ case alt6
435
+ when 1
436
+ # 358:31: ( 'E' | 'e' ) ( '+' | '-' )? ( DIGIT )+
437
+ if @input.look_ahead(1) == ?E || @input.look_ahead(1) == ?e
438
+ match()
439
+ else
440
+ raise "Expected set"
441
+ end
442
+ # 358:41: ( '+' | '-' )?
443
+ alt4 = 2
444
+ #
445
+ look_ahead4_0 = @input.look_ahead(1)
446
+
447
+ look_ahead4_0 = -1 if look_ahead4_0 == :EOF
448
+ if look_ahead4_0 == ?+ || look_ahead4_0 == ?-
449
+ alt4 = 1
450
+ end
451
+ case alt4
452
+ when 1
453
+ #
454
+ if @input.look_ahead(1) == ?+ || @input.look_ahead(1) == ?-
455
+ match()
456
+ else
457
+ raise "Expected set"
458
+ end
459
+ end
460
+ # 358:52: ( DIGIT )+
461
+ matchedOnce5 = false
462
+ while true
463
+ alt5 = 2
464
+ #
465
+ look_ahead5_0 = @input.look_ahead(1)
466
+ look_ahead5_0 = -1 if look_ahead5_0 == :EOF
467
+ if (look_ahead5_0 >= ?0 && look_ahead5_0 <= ?9)
468
+ alt5 = 1
469
+ end
470
+ case alt5
471
+ when 1
472
+ # 358:52: DIGIT
473
+ match_DIGIT()
474
+ else
475
+ break
476
+ end
477
+ matchedOnce5 = true
478
+ end
479
+
480
+ if !matchedOnce5
481
+ raise "Expected at least one match: 358:52: ( DIGIT )+"
482
+ end
483
+ end
484
+ end
485
+
486
+ def match_STR_CONST()
487
+
488
+ @type = :STR_CONST
489
+ @type_int = STR_CONST
490
+ # 359:12: '\"' ~ '\"' '\"'
491
+ match(?")
492
+ if (@input.look_ahead(1) >= 0x0000 && @input.look_ahead(1) <= ?!) || (@input.look_ahead(1) >= ?# && @input.look_ahead(1) <= 0x00FF)
493
+ match()
494
+ else
495
+ raise "Expected set"
496
+ end
497
+ match(?")
498
+ end
499
+
500
+ def match_REF2D()
501
+
502
+ @type = :REF2D
503
+ @type_int = REF2D
504
+ # 360:8: ( '$' )? ( 'A' .. 'I' )? ( 'A' .. 'Z' ) ( '$' )? ( DIGIT )+
505
+ # 360:8: ( '$' )?
506
+ alt7 = 2
507
+ #
508
+ look_ahead7_0 = @input.look_ahead(1)
509
+
510
+ look_ahead7_0 = -1 if look_ahead7_0 == :EOF
511
+ if look_ahead7_0 == ?$
512
+ alt7 = 1
513
+ end
514
+ case alt7
515
+ when 1
516
+ # 360:8: '$'
517
+ match(?$)
518
+ end
519
+ # 360:13: ( 'A' .. 'I' )?
520
+ alt8 = 2
521
+ #
522
+ look_ahead8_0 = @input.look_ahead(1)
523
+
524
+ look_ahead8_0 = -1 if look_ahead8_0 == :EOF
525
+ if (look_ahead8_0 >= ?A && look_ahead8_0 <= ?I)
526
+ #
527
+ look_ahead8_1 = @input.look_ahead(2)
528
+
529
+ look_ahead8_1 = -1 if look_ahead8_1 == :EOF
530
+ if (look_ahead8_1 >= ?A && look_ahead8_1 <= ?Z)
531
+ alt8 = 1
532
+ end
533
+ end
534
+ case alt8
535
+ when 1
536
+ # 360:14: 'A' .. 'I'
537
+ match_range(?A, ?I)
538
+ end
539
+ # 360:26: 'A' .. 'Z'
540
+ match_range(?A, ?Z)
541
+ # 360:36: ( '$' )?
542
+ alt9 = 2
543
+ #
544
+ look_ahead9_0 = @input.look_ahead(1)
545
+
546
+ look_ahead9_0 = -1 if look_ahead9_0 == :EOF
547
+ if look_ahead9_0 == ?$
548
+ alt9 = 1
549
+ end
550
+ case alt9
551
+ when 1
552
+ # 360:36: '$'
553
+ match(?$)
554
+ end
555
+ # 360:41: ( DIGIT )+
556
+ matchedOnce10 = false
557
+ while true
558
+ alt10 = 2
559
+ #
560
+ look_ahead10_0 = @input.look_ahead(1)
561
+ look_ahead10_0 = -1 if look_ahead10_0 == :EOF
562
+ if (look_ahead10_0 >= ?0 && look_ahead10_0 <= ?9)
563
+ alt10 = 1
564
+ end
565
+ case alt10
566
+ when 1
567
+ # 360:41: DIGIT
568
+ match_DIGIT()
569
+ else
570
+ break
571
+ end
572
+ matchedOnce10 = true
573
+ end
574
+
575
+ if !matchedOnce10
576
+ raise "Expected at least one match: 360:41: ( DIGIT )+"
577
+ end
578
+ end
579
+
580
+ def match_TRUE_CONST()
581
+
582
+ @type = :TRUE_CONST
583
+ @type_int = TRUE_CONST
584
+ # 361:13: ( 'T' | 't' ) ( 'R' | 'r' ) ( 'U' | 'u' ) ( 'E' | 'e' )
585
+ if @input.look_ahead(1) == ?T || @input.look_ahead(1) == ?t
586
+ match()
587
+ else
588
+ raise "Expected set"
589
+ end
590
+ if @input.look_ahead(1) == ?R || @input.look_ahead(1) == ?r
591
+ match()
592
+ else
593
+ raise "Expected set"
594
+ end
595
+ if @input.look_ahead(1) == ?U || @input.look_ahead(1) == ?u
596
+ match()
597
+ else
598
+ raise "Expected set"
599
+ end
600
+ if @input.look_ahead(1) == ?E || @input.look_ahead(1) == ?e
601
+ match()
602
+ else
603
+ raise "Expected set"
604
+ end
605
+ end
606
+
607
+ def match_FALSE_CONST()
608
+
609
+ @type = :FALSE_CONST
610
+ @type_int = FALSE_CONST
611
+ # 362:14: ( 'F' | 'f' ) ( 'A' | 'a' ) ( 'L' | 'l' ) ( 'S' | 's' ) ( 'E' | 'e' )
612
+ if @input.look_ahead(1) == ?F || @input.look_ahead(1) == ?f
613
+ match()
614
+ else
615
+ raise "Expected set"
616
+ end
617
+ if @input.look_ahead(1) == ?A || @input.look_ahead(1) == ?a
618
+ match()
619
+ else
620
+ raise "Expected set"
621
+ end
622
+ if @input.look_ahead(1) == ?L || @input.look_ahead(1) == ?l
623
+ match()
624
+ else
625
+ raise "Expected set"
626
+ end
627
+ if @input.look_ahead(1) == ?S || @input.look_ahead(1) == ?s
628
+ match()
629
+ else
630
+ raise "Expected set"
631
+ end
632
+ if @input.look_ahead(1) == ?E || @input.look_ahead(1) == ?e
633
+ match()
634
+ else
635
+ raise "Expected set"
636
+ end
637
+ end
638
+
639
+ def match_NAME()
640
+
641
+ @type = :NAME
642
+ @type_int = NAME
643
+ # 363:7: '\\w[\\.\\w]*'
644
+ match("w[.w]*")
645
+
646
+ end
647
+
648
+ def match_QUOTENAME()
649
+
650
+ @type = :QUOTENAME
651
+ @type_int = QUOTENAME
652
+ # 364:12: '\\'(?:[^\\']|\\'\\')*\\''
653
+ match("'(?:[^']|'')*'")
654
+
655
+ end
656
+
657
+ def match_FUNC_IF()
658
+
659
+ @type = :FUNC_IF
660
+ @type_int = FUNC_IF
661
+ # 365:10: 'IF'
662
+ match("IF")
663
+
664
+ end
665
+
666
+ def match_FUNC_CHOOSE()
667
+
668
+ @type = :FUNC_CHOOSE
669
+ @type_int = FUNC_CHOOSE
670
+ # 366:14: 'CHOOSE'
671
+ match("CHOOSE")
672
+
673
+ end
674
+
675
+ def match_Tokens()
676
+
677
+ # 1:8: ( LT | GT | NE | LE | GE | ADD | SUB | MUL | DIV | COLON | SEMICOLON | COMMA | LP | RP | CONCAT | PERCENT | POWER | BANG | DIGIT | INT_CONST | NUM_CONST | STR_CONST | REF2D | TRUE_CONST | FALSE_CONST | NAME | QUOTENAME | FUNC_IF | FUNC_CHOOSE )
678
+ alt11 = 29
679
+ alt11 = DFA11.predict(self, @input)
680
+ case alt11
681
+ when 1
682
+ # 1:10: LT
683
+ match_LT()
684
+ when 2
685
+ # 1:13: GT
686
+ match_GT()
687
+ when 3
688
+ # 1:16: NE
689
+ match_NE()
690
+ when 4
691
+ # 1:19: LE
692
+ match_LE()
693
+ when 5
694
+ # 1:22: GE
695
+ match_GE()
696
+ when 6
697
+ # 1:25: ADD
698
+ match_ADD()
699
+ when 7
700
+ # 1:29: SUB
701
+ match_SUB()
702
+ when 8
703
+ # 1:33: MUL
704
+ match_MUL()
705
+ when 9
706
+ # 1:37: DIV
707
+ match_DIV()
708
+ when 10
709
+ # 1:41: COLON
710
+ match_COLON()
711
+ when 11
712
+ # 1:47: SEMICOLON
713
+ match_SEMICOLON()
714
+ when 12
715
+ # 1:57: COMMA
716
+ match_COMMA()
717
+ when 13
718
+ # 1:63: LP
719
+ match_LP()
720
+ when 14
721
+ # 1:66: RP
722
+ match_RP()
723
+ when 15
724
+ # 1:69: CONCAT
725
+ match_CONCAT()
726
+ when 16
727
+ # 1:76: PERCENT
728
+ match_PERCENT()
729
+ when 17
730
+ # 1:84: POWER
731
+ match_POWER()
732
+ when 18
733
+ # 1:90: BANG
734
+ match_BANG()
735
+ when 19
736
+ # 1:95: DIGIT
737
+ match_DIGIT()
738
+ when 20
739
+ # 1:101: INT_CONST
740
+ match_INT_CONST()
741
+ when 21
742
+ # 1:111: NUM_CONST
743
+ match_NUM_CONST()
744
+ when 22
745
+ # 1:121: STR_CONST
746
+ match_STR_CONST()
747
+ when 23
748
+ # 1:131: REF2D
749
+ match_REF2D()
750
+ when 24
751
+ # 1:137: TRUE_CONST
752
+ match_TRUE_CONST()
753
+ when 25
754
+ # 1:148: FALSE_CONST
755
+ match_FALSE_CONST()
756
+ when 26
757
+ # 1:160: NAME
758
+ match_NAME()
759
+ when 27
760
+ # 1:165: QUOTENAME
761
+ match_QUOTENAME()
762
+ when 28
763
+ # 1:175: FUNC_IF
764
+ match_FUNC_IF()
765
+ when 29
766
+ # 1:183: FUNC_CHOOSE
767
+ match_FUNC_CHOOSE()
768
+ end
769
+
770
+ end
771
+
772
+
773
+ class DFA
774
+ def initialize(eot, eof, min, max, accept, special, transition)
775
+ @eot = eot
776
+ @eof = eof
777
+ @min = min
778
+ @max = max
779
+ @accept = accept
780
+ @special = special
781
+ @transition = transition
782
+ end
783
+
784
+ def predict(parser, input)
785
+ mark = input.mark()
786
+ s = 0 # we always start at s0
787
+ begin
788
+ loop do
789
+ special_state = @special[s]
790
+ if special_state >= 0
791
+ s = parser.special_state_transition(special_state)
792
+ input.consume()
793
+ next
794
+ end
795
+
796
+ if @accept[s] >= 1
797
+ return @accept[s]
798
+ end
799
+
800
+ # look for a normal char transition
801
+ c = input.look_ahead(1).to_i
802
+ if c != :EOF && c >= @min[s] && c <= @max[s]
803
+ next_state = @transition[s][c - @min[s]] # move to next state
804
+ if next_state < 0
805
+ # was in range but not a normal transition
806
+ # must check EOT, which is like the else clause.
807
+ # eot[s]>=0 indicates that an EOT edge goes to another
808
+ # state.
809
+ if @eot[s] >= 0 # EOT Transition to accept state?
810
+ s = @eot[s]
811
+ input.consume()
812
+ next
813
+ end
814
+ raise "No viable alt"
815
+ end
816
+ s = next_state
817
+ input.consume()
818
+ next
819
+ end
820
+ if @eot[s] >= 0 # EOT Transition?
821
+ s = @eot[s]
822
+ input.consume()
823
+ next
824
+ end
825
+ if c == :EOF && @eof[s] >= 0 # EOF Transition to accept state?
826
+ return @accept[@eof[s]]
827
+ end
828
+
829
+ # not in range and not EOF/EOT, must be invalid symbol
830
+ raise "No viable alt"
831
+ end
832
+ ensure
833
+ input.rewind(mark)
834
+ end
835
+ end
836
+ end
837
+
838
+ DFA11 = DFA.new(
839
+ [-1,30,32,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,33,-1,-1,-1,-1,
840
+ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,38,-1,39,-1,-1,-1,-1],
841
+ [-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
842
+ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1],
843
+ [0,61,61,0,0,0,0,0,0,0,0,0,0,0,0,0,46,0,0,0,36,36,0,36,0,0,0,36,
844
+ 0,0,0,0,0,0,46,36,36,36,0,0,0],
845
+ [116,62,61,0,0,0,0,0,0,0,0,0,0,0,0,0,57,0,0,0,97,114,0,90,0,0,0,
846
+ 90,0,0,0,0,0,0,57,108,57,79,0,0,0],
847
+ [-1,-1,-1,6,7,8,9,10,11,12,13,14,15,16,17,18,-1,21,22,23,-1,-1,24,
848
+ -1,25,26,27,-1,3,4,1,5,2,19,-1,-1,-1,-1,20,28,29],
849
+ [-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
850
+ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1],
851
+ [
852
+ [25,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
853
+ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,15,18,-1,19,13,12,
854
+ 26,10,11,5,3,9,4,17,6,16,16,16,16,16,16,16,16,16,16,7,8,
855
+ 1,-1,2,-1,-1,19,19,27,19,19,20,19,19,23,19,19,19,19,19,
856
+ 19,19,19,19,19,21,19,19,19,19,19,19,-1,-1,-1,14,-1,-1,-1,
857
+ -1,-1,-1,-1,24,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,22],
858
+ [29,28],
859
+ [31],
860
+ [],
861
+ [],
862
+ [],
863
+ [],
864
+ [],
865
+ [],
866
+ [],
867
+ [],
868
+ [],
869
+ [],
870
+ [],
871
+ [],
872
+ [],
873
+ [17,-1,34,34,34,34,34,34,34,34,34,34],
874
+ [],
875
+ [],
876
+ [],
877
+ [19,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,19,19,19,19,19,19,19,19,
878
+ 19,19,-1,-1,-1,-1,-1,-1,-1,35,19,19,19,19,19,19,19,19,19,
879
+ 19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,-1,-1,-1,
880
+ -1,-1,-1,24],
881
+ [19,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,19,19,19,19,19,19,19,19,
882
+ 19,19,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
883
+ -1,-1,-1,-1,-1,-1,-1,22,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
884
+ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
885
+ -1,22],
886
+ [],
887
+ [19,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,19,19,19,19,19,19,19,19,
888
+ 19,19,-1,-1,-1,-1,-1,-1,-1,19,19,19,19,19,36,19,19,19,19,
889
+ 19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19],
890
+ [],
891
+ [],
892
+ [],
893
+ [19,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,19,19,19,19,19,19,19,19,
894
+ 19,19,-1,-1,-1,-1,-1,-1,-1,19,19,19,19,19,19,19,37,19,19,
895
+ 19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19],
896
+ [],
897
+ [],
898
+ [],
899
+ [],
900
+ [],
901
+ [],
902
+ [17,-1,34,34,34,34,34,34,34,34,34,34],
903
+ [19,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,19,19,19,19,19,19,19,19,
904
+ 19,19,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
905
+ -1,24,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
906
+ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,24],
907
+ [19,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,19,19,19,19,19,19,19,19,
908
+ 19,19],
909
+ [19,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,19,19,19,19,19,19,19,19,
910
+ 19,19,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
911
+ -1,-1,-1,-1,40],
912
+ [],
913
+ [],
914
+ []
915
+ ])
916
+
917
+ def special_state_transition(s)
918
+ -1
919
+ end
920
+
921
+ public :special_state_transition
922
+ end