ruby-cldr 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (97) hide show
  1. data/Gemfile +7 -0
  2. data/Gemfile.lock +23 -0
  3. data/README.textile +9 -6
  4. data/VERSION +1 -1
  5. data/lib/cldr.rb +1 -1
  6. data/lib/cldr/data.rb +9 -29
  7. data/lib/cldr/download.rb +2 -2
  8. data/lib/cldr/export.rb +8 -2
  9. data/lib/cldr/export/code.rb +34 -0
  10. data/lib/cldr/export/code/numbers.rb +29 -0
  11. data/lib/cldr/export/data.rb +36 -0
  12. data/lib/cldr/export/data/base.rb +61 -0
  13. data/lib/cldr/export/data/calendars.rb +14 -0
  14. data/lib/cldr/export/data/calendars/gregorian.rb +142 -0
  15. data/lib/cldr/export/data/currencies.rb +28 -0
  16. data/lib/cldr/export/data/delimiters.rb +29 -0
  17. data/lib/cldr/export/data/languages.rb +19 -0
  18. data/lib/cldr/export/data/numbers.rb +67 -0
  19. data/lib/cldr/export/data/plurals.rb +41 -0
  20. data/lib/cldr/{data → export/data}/plurals/cldr_grammar.treetop +0 -0
  21. data/lib/cldr/export/data/plurals/grammar.rb +538 -0
  22. data/lib/cldr/export/data/plurals/rules.rb +119 -0
  23. data/lib/cldr/export/data/territories.rb +19 -0
  24. data/lib/cldr/export/data/timezones.rb +27 -0
  25. data/lib/cldr/export/data/units.rb +29 -0
  26. data/lib/cldr/export/ruby.rb +1 -1
  27. data/lib/cldr/export/yaml.rb +1 -1
  28. data/lib/cldr/format.rb +1 -97
  29. data/lib/cldr/format/currency.rb +1 -1
  30. data/lib/cldr/format/date.rb +1 -1
  31. data/lib/cldr/format/datetime.rb +14 -18
  32. data/lib/cldr/format/datetime/base.rb +1 -1
  33. data/lib/cldr/format/decimal.rb +1 -1
  34. data/lib/cldr/format/decimal/base.rb +1 -1
  35. data/lib/cldr/format/decimal/fraction.rb +1 -1
  36. data/lib/cldr/format/decimal/integer.rb +1 -1
  37. data/lib/cldr/format/decimal/number.rb +1 -1
  38. data/lib/cldr/format/percent.rb +1 -1
  39. data/lib/cldr/format/time.rb +1 -1
  40. data/lib/cldr/thor.rb +3 -3
  41. data/test/all.rb +1 -1
  42. data/test/export/code/numbers_test.rb +11 -0
  43. data/test/{data → export/data}/all.rb +1 -1
  44. data/test/{data → export/data}/calendars_test.rb +18 -18
  45. data/test/{data → export/data}/currencies_test.rb +6 -6
  46. data/test/{data → export/data}/delimiters_test.rb +6 -6
  47. data/test/{data → export/data}/languages_test.rb +6 -6
  48. data/test/{data → export/data}/numbers_test.rb +8 -8
  49. data/test/export/data/plurals_test.rb +141 -0
  50. data/test/{data → export/data}/territories_test.rb +6 -6
  51. data/test/{data → export/data}/timezones_test.rb +6 -6
  52. data/test/{data → export/data}/units_test.rb +6 -6
  53. data/test/export_test.rb +8 -8
  54. data/test/{formats → format}/all.rb +1 -1
  55. data/test/format/currency_test.rb +0 -0
  56. data/test/format/date_test.rb +265 -0
  57. data/test/format/datetime_test.rb +18 -0
  58. data/test/{formats → format}/decimal/fraction_test.rb +4 -4
  59. data/test/{formats → format}/decimal/integer_test.rb +17 -17
  60. data/test/{formats → format}/decimal/number_test.rb +19 -19
  61. data/test/{formats → format}/decimal_test.rb +5 -5
  62. data/test/format/percent_test.rb +0 -0
  63. data/test/format/time_test.rb +195 -0
  64. data/test/test_autotest.rb +36 -0
  65. data/test/test_helper.rb +16 -1
  66. metadata +124 -114
  67. data/lib/cldr/data/base.rb +0 -66
  68. data/lib/cldr/data/calendars.rb +0 -12
  69. data/lib/cldr/data/calendars/gregorian.rb +0 -124
  70. data/lib/cldr/data/currencies.rb +0 -26
  71. data/lib/cldr/data/delimiters.rb +0 -21
  72. data/lib/cldr/data/languages.rb +0 -17
  73. data/lib/cldr/data/numbers.rb +0 -60
  74. data/lib/cldr/data/plurals.rb +0 -39
  75. data/lib/cldr/data/plurals/grammar.rb +0 -536
  76. data/lib/cldr/data/plurals/rules.rb +0 -113
  77. data/lib/cldr/data/territories.rb +0 -17
  78. data/lib/cldr/data/timezones.rb +0 -25
  79. data/lib/cldr/data/units.rb +0 -25
  80. data/test/data/plurals_test.rb +0 -132
  81. data/test/formats/datetime/all.rb +0 -3
  82. data/test/formats/datetime/date_test.rb +0 -31
  83. data/test/formats/datetime/datetime_test.rb +0 -18
  84. data/test/formats/datetime/day_test.rb +0 -41
  85. data/test/formats/datetime/hour_test.rb +0 -79
  86. data/test/formats/datetime/minute_test.rb +0 -25
  87. data/test/formats/datetime/month_test.rb +0 -76
  88. data/test/formats/datetime/period_test.rb +0 -20
  89. data/test/formats/datetime/quarter_test.rb +0 -118
  90. data/test/formats/datetime/second_test.rb +0 -80
  91. data/test/formats/datetime/time_test.rb +0 -33
  92. data/test/formats/datetime/timezone_test.rb +0 -23
  93. data/test/formats/datetime/year_test.rb +0 -57
  94. data/test/formats/format_test.rb +0 -66
  95. data/test/formats/rails_compat/all.rb +0 -3
  96. data/test/formats/rails_compat/format_integer_test.rb +0 -56
  97. data/test/formats/rails_compat/format_number_test.rb +0 -134
@@ -0,0 +1,28 @@
1
+ module Cldr
2
+ module Export
3
+ module Data
4
+ class Currencies < Base
5
+ def initialize(locale)
6
+ super
7
+ update(:currencies => currencies)
8
+ end
9
+
10
+ def currencies
11
+ select('numbers/currencies/*').inject({}) do |result, node|
12
+ currency = self.currency(node)
13
+ result[node.attribute('type').value.to_sym] = currency unless currency.empty?
14
+ result
15
+ end
16
+ end
17
+
18
+ def currency(node)
19
+ select(node, 'displayName').inject({}) do |result, node|
20
+ count = node.attribute('count') ? node.attribute('count').value.to_sym : :one
21
+ result[count] = node.content unless draft?(node)
22
+ result
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,29 @@
1
+ module Cldr
2
+ module Export
3
+ module Data
4
+ class Delimiters < Base
5
+ def initialize(locale)
6
+ super
7
+ update(
8
+ :delimiters => {
9
+ :quotes => {
10
+ :default => quotes('quotation'),
11
+ :alternate => quotes('alternateQuotation')
12
+ }
13
+ }
14
+ )
15
+ end
16
+
17
+ def quotes(type)
18
+ start = select("delimiters/#{type}Start").first
19
+ end_ = select("delimiters/#{type}End").first
20
+
21
+ result = {}
22
+ result[:start] = start.content if start
23
+ result[:end] = end_.content if end_
24
+ result
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,19 @@
1
+ module Cldr
2
+ module Export
3
+ module Data
4
+ class Languages < Base
5
+ def initialize(locale)
6
+ super
7
+ update(:languages => languages)
8
+ end
9
+
10
+ def languages
11
+ @languages ||= select('localeDisplayNames/languages/language').inject({}) do |result, node|
12
+ result[node.attribute('type').value.gsub('_', '-').to_sym] = node.content unless draft?(node)
13
+ result
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,67 @@
1
+ module Cldr
2
+ module Export
3
+ module Data
4
+ class Numbers < Base
5
+ def initialize(locale)
6
+ super
7
+ update(
8
+ :numbers => {
9
+ :symbols => symbols,
10
+ :formats => {
11
+ :decimal => {
12
+ :patterns => format('decimal')
13
+ },
14
+ :scientific => {
15
+ :patterns => format('scientific')
16
+ },
17
+ :percent => {
18
+ :patterns => format('percent')
19
+ },
20
+ :currency => {
21
+ :patterns => format('currency'),
22
+ :unit => unit
23
+ }
24
+ }
25
+ }
26
+ )
27
+ end
28
+
29
+ def currency
30
+ currency = format('currency')
31
+ currency.update(:unit => unit) unless unit.empty?
32
+ currency
33
+ end
34
+
35
+ def symbols
36
+ select('numbers/symbols/*').inject({}) do |result, node|
37
+ result[name(node).to_sym] = node.content unless draft?(node)
38
+ result
39
+ end
40
+ end
41
+
42
+ def format(type)
43
+ result = select("numbers/#{type}Formats/#{type}FormatLength/#{type}Format").inject({}) do |format_result, format_node|
44
+ format_key = format_node.parent.attribute('type')
45
+ format_result[format_key ? format_key.value : :default] = select(format_node, "pattern").inject({}) do |pattern_result, pattern_node|
46
+ pattern_key = pattern_node.attribute('type')
47
+ pattern_result[pattern_key ? pattern_key.value : :default] = pattern_node.content unless draft?(pattern_node)
48
+ pattern_result
49
+ end
50
+ format_result
51
+ end
52
+
53
+ result[:default] = result[:default][:default] if result[:default]
54
+ result
55
+ end
56
+
57
+ def unit
58
+ @unit ||= select("numbers/currencyFormats/unitPattern").inject({}) do |result, node|
59
+ count = node.attribute('count').value rescue 'one'
60
+ result[count] = node.content
61
+ result
62
+ end
63
+ end
64
+ end
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,41 @@
1
+ require 'fileutils'
2
+
3
+ module Cldr
4
+ module Export
5
+ module Data
6
+ class Plurals < String
7
+ autoload :Grammar, 'cldr/export/data/plurals/grammar'
8
+ autoload :Parser, 'cldr/export/data/plurals/grammar'
9
+ autoload :Rules, 'cldr/export/data/plurals/rules'
10
+ autoload :Rule, 'cldr/export/data/plurals/rules'
11
+ autoload :Proposition, 'cldr/export/data/plurals/rules'
12
+ autoload :Expression, 'cldr/export/data/plurals/rules'
13
+
14
+ class << self
15
+ def rules
16
+ @@rules ||= Rules.parse(source)
17
+ end
18
+
19
+ def source
20
+ File.read("#{Cldr::Export::Data.dir}/supplemental/plurals.xml")
21
+ end
22
+ end
23
+
24
+ attr_reader :locale
25
+
26
+ def initialize(locale)
27
+ @locale = locale
28
+ super(rule ? ruby : "")
29
+ end
30
+
31
+ def ruby
32
+ "{ :#{locale} => { :i18n => {:plural => { :keys => #{rule.keys.inspect}, :rule => #{rule.to_ruby} } } } }"
33
+ end
34
+
35
+ def rule
36
+ @rule = Plurals.rules.rule(locale)
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,538 @@
1
+ # http://unicode.org/draft/reports/tr35/tr35.html#Language_Plural_Rules
2
+ #
3
+ # condition = and_condition ('or' and_condition)*
4
+ # and_condition = relation ('and' relation)*
5
+ # relation = is_relation | in_relation | within_relation | 'n' <EOL>
6
+ # is_relation = expr 'is' ('not')? value
7
+ # in_relation = expr ('not')? 'in' range
8
+ # within_relation = expr ('not')? 'within' range
9
+ # expr = 'n' ('mod' value)?
10
+ # value = digit+
11
+ # digit = 0|1|2|3|4|5|6|7|8|9
12
+ # range = value'..'value
13
+
14
+ module Cldr
15
+ module Export
16
+ module Data
17
+ class Plurals
18
+ module Grammar
19
+ include Treetop::Runtime
20
+
21
+ def root
22
+ @root || :or_condition
23
+ end
24
+
25
+ module OrCondition0
26
+ def and_condition
27
+ elements[1]
28
+ end
29
+ end
30
+
31
+ module OrCondition1
32
+ def and_condition
33
+ elements[0]
34
+ end
35
+
36
+ end
37
+
38
+ def _nt_or_condition
39
+ start_index = index
40
+ if node_cache[:or_condition].has_key?(index)
41
+ cached = node_cache[:or_condition][index]
42
+ @index = cached.interval.end if cached
43
+ return cached
44
+ end
45
+
46
+ i0, s0 = index, []
47
+ r1 = _nt_and_condition
48
+ s0 << r1
49
+ if r1
50
+ i3, s3 = index, []
51
+ if input.index(" or ", index) == index
52
+ r4 = instantiate_node(SyntaxNode,input, index...(index + 4))
53
+ @index += 4
54
+ else
55
+ terminal_parse_failure(" or ")
56
+ r4 = nil
57
+ end
58
+ s3 << r4
59
+ if r4
60
+ r5 = _nt_and_condition
61
+ s3 << r5
62
+ end
63
+ if s3.last
64
+ r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
65
+ r3.extend(OrCondition0)
66
+ else
67
+ self.index = i3
68
+ r3 = nil
69
+ end
70
+ if r3
71
+ r2 = r3
72
+ else
73
+ r2 = instantiate_node(SyntaxNode,input, index...index)
74
+ end
75
+ s0 << r2
76
+ end
77
+ if s0.last
78
+ r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
79
+ r0.extend(OrCondition1)
80
+ else
81
+ self.index = i0
82
+ r0 = nil
83
+ end
84
+
85
+ node_cache[:or_condition][start_index] = r0
86
+
87
+ return r0
88
+ end
89
+
90
+ module AndCondition0
91
+ def relation
92
+ elements[1]
93
+ end
94
+ end
95
+
96
+ module AndCondition1
97
+ def relation
98
+ elements[0]
99
+ end
100
+
101
+ end
102
+
103
+ def _nt_and_condition
104
+ start_index = index
105
+ if node_cache[:and_condition].has_key?(index)
106
+ cached = node_cache[:and_condition][index]
107
+ @index = cached.interval.end if cached
108
+ return cached
109
+ end
110
+
111
+ i0, s0 = index, []
112
+ r1 = _nt_relation
113
+ s0 << r1
114
+ if r1
115
+ i3, s3 = index, []
116
+ if input.index(" and ", index) == index
117
+ r4 = instantiate_node(SyntaxNode,input, index...(index + 5))
118
+ @index += 5
119
+ else
120
+ terminal_parse_failure(" and ")
121
+ r4 = nil
122
+ end
123
+ s3 << r4
124
+ if r4
125
+ r5 = _nt_relation
126
+ s3 << r5
127
+ end
128
+ if s3.last
129
+ r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
130
+ r3.extend(AndCondition0)
131
+ else
132
+ self.index = i3
133
+ r3 = nil
134
+ end
135
+ if r3
136
+ r2 = r3
137
+ else
138
+ r2 = instantiate_node(SyntaxNode,input, index...index)
139
+ end
140
+ s0 << r2
141
+ end
142
+ if s0.last
143
+ r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
144
+ r0.extend(AndCondition1)
145
+ else
146
+ self.index = i0
147
+ r0 = nil
148
+ end
149
+
150
+ node_cache[:and_condition][start_index] = r0
151
+
152
+ return r0
153
+ end
154
+
155
+ def _nt_relation
156
+ start_index = index
157
+ if node_cache[:relation].has_key?(index)
158
+ cached = node_cache[:relation][index]
159
+ @index = cached.interval.end if cached
160
+ return cached
161
+ end
162
+
163
+ i0 = index
164
+ r1 = _nt_is_relation
165
+ if r1
166
+ r0 = r1
167
+ else
168
+ r2 = _nt_in_relation
169
+ if r2
170
+ r0 = r2
171
+ else
172
+ r3 = _nt_within_relation
173
+ if r3
174
+ r0 = r3
175
+ else
176
+ if input.index("n", index) == index
177
+ r4 = instantiate_node(SyntaxNode,input, index...(index + 1))
178
+ @index += 1
179
+ else
180
+ terminal_parse_failure("n")
181
+ r4 = nil
182
+ end
183
+ if r4
184
+ r0 = r4
185
+ else
186
+ self.index = i0
187
+ r0 = nil
188
+ end
189
+ end
190
+ end
191
+ end
192
+
193
+ node_cache[:relation][start_index] = r0
194
+
195
+ return r0
196
+ end
197
+
198
+ module IsRelation0
199
+ def expr
200
+ elements[0]
201
+ end
202
+
203
+ def value
204
+ elements[3]
205
+ end
206
+ end
207
+
208
+ def _nt_is_relation
209
+ start_index = index
210
+ if node_cache[:is_relation].has_key?(index)
211
+ cached = node_cache[:is_relation][index]
212
+ @index = cached.interval.end if cached
213
+ return cached
214
+ end
215
+
216
+ i0, s0 = index, []
217
+ r1 = _nt_expr
218
+ s0 << r1
219
+ if r1
220
+ if input.index(" is ", index) == index
221
+ r2 = instantiate_node(SyntaxNode,input, index...(index + 4))
222
+ @index += 4
223
+ else
224
+ terminal_parse_failure(" is ")
225
+ r2 = nil
226
+ end
227
+ s0 << r2
228
+ if r2
229
+ if input.index("not ", index) == index
230
+ r4 = instantiate_node(SyntaxNode,input, index...(index + 4))
231
+ @index += 4
232
+ else
233
+ terminal_parse_failure("not ")
234
+ r4 = nil
235
+ end
236
+ if r4
237
+ r3 = r4
238
+ else
239
+ r3 = instantiate_node(SyntaxNode,input, index...index)
240
+ end
241
+ s0 << r3
242
+ if r3
243
+ r5 = _nt_value
244
+ s0 << r5
245
+ end
246
+ end
247
+ end
248
+ if s0.last
249
+ r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
250
+ r0.extend(IsRelation0)
251
+ else
252
+ self.index = i0
253
+ r0 = nil
254
+ end
255
+
256
+ node_cache[:is_relation][start_index] = r0
257
+
258
+ return r0
259
+ end
260
+
261
+ module InRelation0
262
+ def expr
263
+ elements[0]
264
+ end
265
+
266
+ def range
267
+ elements[3]
268
+ end
269
+ end
270
+
271
+ def _nt_in_relation
272
+ start_index = index
273
+ if node_cache[:in_relation].has_key?(index)
274
+ cached = node_cache[:in_relation][index]
275
+ @index = cached.interval.end if cached
276
+ return cached
277
+ end
278
+
279
+ i0, s0 = index, []
280
+ r1 = _nt_expr
281
+ s0 << r1
282
+ if r1
283
+ if input.index(" not", index) == index
284
+ r3 = instantiate_node(SyntaxNode,input, index...(index + 4))
285
+ @index += 4
286
+ else
287
+ terminal_parse_failure(" not")
288
+ r3 = nil
289
+ end
290
+ if r3
291
+ r2 = r3
292
+ else
293
+ r2 = instantiate_node(SyntaxNode,input, index...index)
294
+ end
295
+ s0 << r2
296
+ if r2
297
+ if input.index(" in ", index) == index
298
+ r4 = instantiate_node(SyntaxNode,input, index...(index + 4))
299
+ @index += 4
300
+ else
301
+ terminal_parse_failure(" in ")
302
+ r4 = nil
303
+ end
304
+ s0 << r4
305
+ if r4
306
+ r5 = _nt_range
307
+ s0 << r5
308
+ end
309
+ end
310
+ end
311
+ if s0.last
312
+ r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
313
+ r0.extend(InRelation0)
314
+ else
315
+ self.index = i0
316
+ r0 = nil
317
+ end
318
+
319
+ node_cache[:in_relation][start_index] = r0
320
+
321
+ return r0
322
+ end
323
+
324
+ module WithinRelation0
325
+ def expr
326
+ elements[0]
327
+ end
328
+
329
+ def range
330
+ elements[3]
331
+ end
332
+ end
333
+
334
+ def _nt_within_relation
335
+ start_index = index
336
+ if node_cache[:within_relation].has_key?(index)
337
+ cached = node_cache[:within_relation][index]
338
+ @index = cached.interval.end if cached
339
+ return cached
340
+ end
341
+
342
+ i0, s0 = index, []
343
+ r1 = _nt_expr
344
+ s0 << r1
345
+ if r1
346
+ if input.index(" not", index) == index
347
+ r3 = instantiate_node(SyntaxNode,input, index...(index + 4))
348
+ @index += 4
349
+ else
350
+ terminal_parse_failure(" not")
351
+ r3 = nil
352
+ end
353
+ if r3
354
+ r2 = r3
355
+ else
356
+ r2 = instantiate_node(SyntaxNode,input, index...index)
357
+ end
358
+ s0 << r2
359
+ if r2
360
+ if input.index(" within ", index) == index
361
+ r4 = instantiate_node(SyntaxNode,input, index...(index + 8))
362
+ @index += 8
363
+ else
364
+ terminal_parse_failure(" within ")
365
+ r4 = nil
366
+ end
367
+ s0 << r4
368
+ if r4
369
+ r5 = _nt_range
370
+ s0 << r5
371
+ end
372
+ end
373
+ end
374
+ if s0.last
375
+ r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
376
+ r0.extend(WithinRelation0)
377
+ else
378
+ self.index = i0
379
+ r0 = nil
380
+ end
381
+
382
+ node_cache[:within_relation][start_index] = r0
383
+
384
+ return r0
385
+ end
386
+
387
+ module Expr0
388
+ def value
389
+ elements[1]
390
+ end
391
+ end
392
+
393
+ module Expr1
394
+ end
395
+
396
+ def _nt_expr
397
+ start_index = index
398
+ if node_cache[:expr].has_key?(index)
399
+ cached = node_cache[:expr][index]
400
+ @index = cached.interval.end if cached
401
+ return cached
402
+ end
403
+
404
+ i0, s0 = index, []
405
+ if input.index("n", index) == index
406
+ r1 = instantiate_node(SyntaxNode,input, index...(index + 1))
407
+ @index += 1
408
+ else
409
+ terminal_parse_failure("n")
410
+ r1 = nil
411
+ end
412
+ s0 << r1
413
+ if r1
414
+ i3, s3 = index, []
415
+ if input.index(" mod ", index) == index
416
+ r4 = instantiate_node(SyntaxNode,input, index...(index + 5))
417
+ @index += 5
418
+ else
419
+ terminal_parse_failure(" mod ")
420
+ r4 = nil
421
+ end
422
+ s3 << r4
423
+ if r4
424
+ r5 = _nt_value
425
+ s3 << r5
426
+ end
427
+ if s3.last
428
+ r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
429
+ r3.extend(Expr0)
430
+ else
431
+ self.index = i3
432
+ r3 = nil
433
+ end
434
+ if r3
435
+ r2 = r3
436
+ else
437
+ r2 = instantiate_node(SyntaxNode,input, index...index)
438
+ end
439
+ s0 << r2
440
+ end
441
+ if s0.last
442
+ r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
443
+ r0.extend(Expr1)
444
+ else
445
+ self.index = i0
446
+ r0 = nil
447
+ end
448
+
449
+ node_cache[:expr][start_index] = r0
450
+
451
+ return r0
452
+ end
453
+
454
+ module Range0
455
+ def value
456
+ elements[0]
457
+ end
458
+
459
+ def value
460
+ elements[2]
461
+ end
462
+ end
463
+
464
+ def _nt_range
465
+ start_index = index
466
+ if node_cache[:range].has_key?(index)
467
+ cached = node_cache[:range][index]
468
+ @index = cached.interval.end if cached
469
+ return cached
470
+ end
471
+
472
+ i0, s0 = index, []
473
+ r1 = _nt_value
474
+ s0 << r1
475
+ if r1
476
+ if input.index("..", index) == index
477
+ r2 = instantiate_node(SyntaxNode,input, index...(index + 2))
478
+ @index += 2
479
+ else
480
+ terminal_parse_failure("..")
481
+ r2 = nil
482
+ end
483
+ s0 << r2
484
+ if r2
485
+ r3 = _nt_value
486
+ s0 << r3
487
+ end
488
+ end
489
+ if s0.last
490
+ r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
491
+ r0.extend(Range0)
492
+ else
493
+ self.index = i0
494
+ r0 = nil
495
+ end
496
+
497
+ node_cache[:range][start_index] = r0
498
+
499
+ return r0
500
+ end
501
+
502
+ def _nt_value
503
+ start_index = index
504
+ if node_cache[:value].has_key?(index)
505
+ cached = node_cache[:value][index]
506
+ @index = cached.interval.end if cached
507
+ return cached
508
+ end
509
+
510
+ s0, i0 = [], index
511
+ loop do
512
+ if input.index(Regexp.new('[0-9]'), index) == index
513
+ r1 = instantiate_node(SyntaxNode,input, index...(index + 1))
514
+ @index += 1
515
+ else
516
+ r1 = nil
517
+ end
518
+ if r1
519
+ s0 << r1
520
+ else
521
+ break
522
+ end
523
+ end
524
+ r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
525
+
526
+ node_cache[:value][start_index] = r0
527
+
528
+ return r0
529
+ end
530
+ end
531
+ end
532
+
533
+ class Parser < Treetop::Runtime::CompiledParser
534
+ include Grammar
535
+ end
536
+ end
537
+ end
538
+ end