cskit 1.0.1 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +7 -4
  3. data/History.txt +5 -0
  4. data/cskit.gemspec +5 -8
  5. data/lib/cskit.rb +15 -66
  6. data/lib/cskit/annotated_string.rb +1 -1
  7. data/lib/cskit/annotator.rb +1 -3
  8. data/lib/cskit/formatters.rb +3 -4
  9. data/lib/cskit/formatters/bible.rb +4 -5
  10. data/lib/cskit/formatters/bible/bible_html_formatter.rb +2 -2
  11. data/lib/cskit/formatters/bible/bible_json_formatter.rb +17 -0
  12. data/lib/cskit/formatters/bible/bible_plain_text_formatter.rb +3 -3
  13. data/lib/cskit/formatters/science_health.rb +3 -5
  14. data/lib/cskit/formatters/science_health/science_health_html_formatter.rb +3 -4
  15. data/lib/cskit/formatters/science_health/science_health_plain_text_formatter.rb +5 -4
  16. data/lib/cskit/lesson.rb +3 -5
  17. data/lib/cskit/lesson/lesson.rb +3 -3
  18. data/lib/cskit/lesson/section.rb +1 -1
  19. data/lib/cskit/parsers.rb +6 -3
  20. data/lib/cskit/parsers/bible.rb +10 -0
  21. data/lib/cskit/parsers/bible/bible_parser.rb +192 -0
  22. data/lib/cskit/parsers/bible/bible_tokenizer.rb +32 -0
  23. data/lib/cskit/parsers/parser.rb +68 -0
  24. data/lib/cskit/parsers/science_health.rb +10 -0
  25. data/lib/cskit/parsers/science_health/science_health_parser.rb +201 -0
  26. data/lib/cskit/parsers/science_health/science_health_tokenizer.rb +33 -0
  27. data/lib/cskit/parsers/token.rb +17 -0
  28. data/lib/cskit/parsers/tokenizer.rb +43 -0
  29. data/lib/cskit/readers.rb +4 -4
  30. data/lib/cskit/readers/bible_reader.rb +2 -2
  31. data/lib/cskit/readers/reading.rb +8 -1
  32. data/lib/cskit/readers/science_health_reader.rb +8 -8
  33. data/lib/cskit/registry.rb +65 -0
  34. data/lib/cskit/resources/volumes.rb +3 -3
  35. data/lib/cskit/resources/volumes/bible.rb +11 -9
  36. data/lib/cskit/resources/volumes/science_health.rb +10 -9
  37. data/lib/cskit/version.rb +1 -1
  38. data/lib/cskit/volume.rb +1 -1
  39. data/spec/parsers/bible/bible_parser_spec.rb +205 -0
  40. data/spec/parsers/science_health/science_health_parser_spec.rb +153 -0
  41. data/spec/spec_helper.rb +8 -0
  42. metadata +16 -38
  43. data/lib/cskit/parsers/bible/bible.rb +0 -1005
  44. data/lib/cskit/parsers/bible/bible.treetop +0 -64
  45. data/lib/cskit/parsers/bible/nodes.rb +0 -153
  46. data/lib/cskit/parsers/bible/objects.rb +0 -81
  47. data/lib/cskit/parsers/science_health/nodes.rb +0 -82
  48. data/lib/cskit/parsers/science_health/objects.rb +0 -47
  49. data/lib/cskit/parsers/science_health/science_health.rb +0 -607
  50. data/lib/cskit/parsers/science_health/science_health.treetop +0 -44
@@ -0,0 +1,153 @@
1
+ # encoding: UTF-8
2
+
3
+ require 'spec_helper'
4
+
5
+ include CSKit::Parsers::ScienceHealth
6
+
7
+ describe ScienceHealthParser do
8
+ let(:parser) { described_class.new(citation_text) }
9
+
10
+ context 'single page, single line' do
11
+ let(:citation_text) { '35:19' }
12
+
13
+ it 'parses correctly' do
14
+ expect(parser.parse.to_hash).to eq({
15
+ page: '35', lines: [{
16
+ start: 19, finish: 19, starter: nil, terminator: nil
17
+ }]
18
+ })
19
+ end
20
+ end
21
+
22
+ context 'single page, multiple lines' do
23
+ let(:citation_text) { '35:19-21' }
24
+
25
+ it 'parses correctly' do
26
+ expect(parser.parse.to_hash).to eq({
27
+ page: '35', lines: [{
28
+ start: 19, finish: 21, starter: nil, terminator: nil
29
+ }]
30
+ })
31
+ end
32
+ end
33
+
34
+ context 'single page, multiple lines, starter fragment' do
35
+ let(:citation_text) { '35:19-21 and' }
36
+
37
+ it 'parses correctly' do
38
+ expect(parser.parse.to_hash).to eq({
39
+ page: '35', lines: [{
40
+ start: 19, finish: 21, terminator: nil, starter: {
41
+ fragment: 'and', cardinality: 1
42
+ }
43
+ }]
44
+ })
45
+ end
46
+ end
47
+
48
+ context 'single page, multiple lines, starter fragment with cardinality' do
49
+ let(:citation_text) { '35:19-21 2nd and' }
50
+
51
+ it 'parses correctly' do
52
+ expect(parser.parse.to_hash).to eq({
53
+ page: '35', lines: [{
54
+ start: 19, finish: 21, terminator: nil, starter: {
55
+ fragment: 'and', cardinality: 2
56
+ }
57
+ }]
58
+ })
59
+ end
60
+ end
61
+
62
+ context 'single page, multiple lines, starter fragment, terminator fragment' do
63
+ let(:citation_text) { '35:19-21 and (to .)' }
64
+
65
+ it 'parses correctly' do
66
+ expect(parser.parse.to_hash).to eq({
67
+ page: '35', lines: [{
68
+ start: 19, finish: 21, terminator: {
69
+ fragment: '.', cardinality: 1
70
+ }, starter: {
71
+ fragment: 'and', cardinality: 1
72
+ }
73
+ }]
74
+ })
75
+ end
76
+ end
77
+
78
+ context 'single page, multiple lines, starter fragment, terminator fragment with cardinality' do
79
+ let(:citation_text) { '35:19-21 and (to 3rd .)' }
80
+
81
+ it 'parses correctly' do
82
+ expect(parser.parse.to_hash).to eq({
83
+ page: '35', lines: [{
84
+ start: 19, finish: 21, terminator: {
85
+ fragment: '.', cardinality: 3
86
+ }, starter: {
87
+ fragment: 'and', cardinality: 1
88
+ }
89
+ }]
90
+ })
91
+ end
92
+ end
93
+
94
+ context 'single page, multiple lines, starter fragment with cardinality, terminator fragment with cardinality' do
95
+ let(:citation_text) { '35:19-21 2nd and (to 3rd .)' }
96
+
97
+ it 'parses correctly' do
98
+ expect(parser.parse.to_hash).to eq({
99
+ page: '35', lines: [{
100
+ start: 19, finish: 21, terminator: {
101
+ fragment: '.', cardinality: 3
102
+ }, starter: {
103
+ fragment: 'and', cardinality: 2
104
+ }
105
+ }]
106
+ })
107
+ end
108
+ end
109
+
110
+ context 'single page, multiple lines, starter fragment, terminator fragment with only' do
111
+ let(:citation_text) { '35:19-21 and (only)' }
112
+
113
+ it 'parses correctly' do
114
+ expect(parser.parse.to_hash).to eq({
115
+ page: '35', lines: [{
116
+ start: 19, finish: 21, terminator: {
117
+ only: true
118
+ }, starter: {
119
+ fragment: 'and', cardinality: 1
120
+ }
121
+ }]
122
+ })
123
+ end
124
+ end
125
+
126
+ context 'single page, multiple lines, terminator fragment with only' do
127
+ let(:citation_text) { '35:19-21 (only)' }
128
+
129
+ it 'parses correctly' do
130
+ expect(parser.parse.to_hash).to eq({
131
+ page: '35', lines: [{
132
+ start: 19, finish: 21, starter: nil, terminator: {
133
+ only: true
134
+ }
135
+ }]
136
+ })
137
+ end
138
+ end
139
+
140
+ context 'single page, terminator fragment with only' do
141
+ let(:citation_text) { '35:19 (only)' }
142
+
143
+ it 'parses correctly' do
144
+ expect(parser.parse.to_hash).to eq({
145
+ page: '35', lines: [{
146
+ start: 19, finish: 19, starter: nil, terminator: {
147
+ only: true
148
+ }
149
+ }]
150
+ })
151
+ end
152
+ end
153
+ end
@@ -0,0 +1,8 @@
1
+ # encoding: UTF-8
2
+
3
+ require 'rspec'
4
+ require 'cskit'
5
+ require 'pry-byebug'
6
+
7
+ RSpec.configure do |config|
8
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cskit
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cameron Dutro
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-03 00:00:00.000000000 Z
11
+ date: 2017-01-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -24,34 +24,6 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
- - !ruby/object:Gem::Dependency
28
- name: treetop
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: '0'
41
- - !ruby/object:Gem::Dependency
42
- name: rake
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: '0'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: '0'
55
27
  description: Christian Science citation library for Ruby.
56
28
  email:
57
29
  - camertron@gmail.com
@@ -71,6 +43,7 @@ files:
71
43
  - lib/cskit/formatters.rb
72
44
  - lib/cskit/formatters/bible.rb
73
45
  - lib/cskit/formatters/bible/bible_html_formatter.rb
46
+ - lib/cskit/formatters/bible/bible_json_formatter.rb
74
47
  - lib/cskit/formatters/bible/bible_plain_text_formatter.rb
75
48
  - lib/cskit/formatters/science_health.rb
76
49
  - lib/cskit/formatters/science_health/science_health_html_formatter.rb
@@ -79,23 +52,28 @@ files:
79
52
  - lib/cskit/lesson/lesson.rb
80
53
  - lib/cskit/lesson/section.rb
81
54
  - lib/cskit/parsers.rb
82
- - lib/cskit/parsers/bible/bible.rb
83
- - lib/cskit/parsers/bible/bible.treetop
84
- - lib/cskit/parsers/bible/nodes.rb
85
- - lib/cskit/parsers/bible/objects.rb
86
- - lib/cskit/parsers/science_health/nodes.rb
87
- - lib/cskit/parsers/science_health/objects.rb
88
- - lib/cskit/parsers/science_health/science_health.rb
89
- - lib/cskit/parsers/science_health/science_health.treetop
55
+ - lib/cskit/parsers/bible.rb
56
+ - lib/cskit/parsers/bible/bible_parser.rb
57
+ - lib/cskit/parsers/bible/bible_tokenizer.rb
58
+ - lib/cskit/parsers/parser.rb
59
+ - lib/cskit/parsers/science_health.rb
60
+ - lib/cskit/parsers/science_health/science_health_parser.rb
61
+ - lib/cskit/parsers/science_health/science_health_tokenizer.rb
62
+ - lib/cskit/parsers/token.rb
63
+ - lib/cskit/parsers/tokenizer.rb
90
64
  - lib/cskit/readers.rb
91
65
  - lib/cskit/readers/bible_reader.rb
92
66
  - lib/cskit/readers/reading.rb
93
67
  - lib/cskit/readers/science_health_reader.rb
68
+ - lib/cskit/registry.rb
94
69
  - lib/cskit/resources/volumes.rb
95
70
  - lib/cskit/resources/volumes/bible.rb
96
71
  - lib/cskit/resources/volumes/science_health.rb
97
72
  - lib/cskit/version.rb
98
73
  - lib/cskit/volume.rb
74
+ - spec/parsers/bible/bible_parser_spec.rb
75
+ - spec/parsers/science_health/science_health_parser_spec.rb
76
+ - spec/spec_helper.rb
99
77
  homepage: http://github.com/camertron
100
78
  licenses: []
101
79
  metadata: {}
@@ -1,1005 +0,0 @@
1
- # Autogenerated from a Treetop grammar. Edits may be lost.
2
-
3
-
4
- # encoding: UTF-8
5
-
6
- require 'cskit/parsers/bible/nodes'
7
- require 'cskit/parsers/bible/objects'
8
-
9
- module CSKit
10
- module Parsers
11
-
12
- module Bible
13
- include Treetop::Runtime
14
-
15
- def root
16
- @root ||= :citation
17
- end
18
-
19
- module Citation0
20
- def book
21
- elements[0]
22
- end
23
-
24
- def chapter_list
25
- elements[2]
26
- end
27
- end
28
-
29
- def _nt_citation
30
- start_index = index
31
- if node_cache[:citation].has_key?(index)
32
- cached = node_cache[:citation][index]
33
- if cached
34
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
35
- @index = cached.interval.end
36
- end
37
- return cached
38
- end
39
-
40
- i0, s0 = index, []
41
- r1 = _nt_book
42
- s0 << r1
43
- if r1
44
- s2, i2 = [], index
45
- loop do
46
- if has_terminal?('\G[\\s]', true, index)
47
- r3 = true
48
- @index += 1
49
- else
50
- r3 = nil
51
- end
52
- if r3
53
- s2 << r3
54
- else
55
- break
56
- end
57
- end
58
- r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
59
- s0 << r2
60
- if r2
61
- r4 = _nt_chapter_list
62
- s0 << r4
63
- end
64
- end
65
- if s0.last
66
- r0 = instantiate_node(CitationNode,input, i0...index, s0)
67
- r0.extend(Citation0)
68
- else
69
- @index = i0
70
- r0 = nil
71
- end
72
-
73
- node_cache[:citation][start_index] = r0
74
-
75
- r0
76
- end
77
-
78
- module ChapterList0
79
- def chapter_list
80
- elements[3]
81
- end
82
- end
83
-
84
- module ChapterList1
85
- def chapter
86
- elements[0]
87
- end
88
-
89
- end
90
-
91
- def _nt_chapter_list
92
- start_index = index
93
- if node_cache[:chapter_list].has_key?(index)
94
- cached = node_cache[:chapter_list][index]
95
- if cached
96
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
97
- @index = cached.interval.end
98
- end
99
- return cached
100
- end
101
-
102
- i0, s0 = index, []
103
- r1 = _nt_chapter
104
- s0 << r1
105
- if r1
106
- i3, s3 = index, []
107
- s4, i4 = [], index
108
- loop do
109
- if has_terminal?('\G[\\s]', true, index)
110
- r5 = true
111
- @index += 1
112
- else
113
- r5 = nil
114
- end
115
- if r5
116
- s4 << r5
117
- else
118
- break
119
- end
120
- end
121
- r4 = instantiate_node(SyntaxNode,input, i4...index, s4)
122
- s3 << r4
123
- if r4
124
- if has_terminal?(";", false, index)
125
- r6 = instantiate_node(SyntaxNode,input, index...(index + 1))
126
- @index += 1
127
- else
128
- terminal_parse_failure(";")
129
- r6 = nil
130
- end
131
- s3 << r6
132
- if r6
133
- s7, i7 = [], index
134
- loop do
135
- if has_terminal?('\G[\\s]', true, index)
136
- r8 = true
137
- @index += 1
138
- else
139
- r8 = nil
140
- end
141
- if r8
142
- s7 << r8
143
- else
144
- break
145
- end
146
- end
147
- r7 = instantiate_node(SyntaxNode,input, i7...index, s7)
148
- s3 << r7
149
- if r7
150
- r9 = _nt_chapter_list
151
- s3 << r9
152
- end
153
- end
154
- end
155
- if s3.last
156
- r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
157
- r3.extend(ChapterList0)
158
- else
159
- @index = i3
160
- r3 = nil
161
- end
162
- if r3
163
- r2 = r3
164
- else
165
- r2 = instantiate_node(SyntaxNode,input, index...index)
166
- end
167
- s0 << r2
168
- end
169
- if s0.last
170
- r0 = instantiate_node(ChapterListNode,input, i0...index, s0)
171
- r0.extend(ChapterList1)
172
- else
173
- @index = i0
174
- r0 = nil
175
- end
176
-
177
- node_cache[:chapter_list][start_index] = r0
178
-
179
- r0
180
- end
181
-
182
- def _nt_book
183
- start_index = index
184
- if node_cache[:book].has_key?(index)
185
- cached = node_cache[:book][index]
186
- if cached
187
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
188
- @index = cached.interval.end
189
- end
190
- return cached
191
- end
192
-
193
- s0, i0 = [], index
194
- loop do
195
- if has_terminal?('\G[a-zA-Z\\.\\s]', true, index)
196
- r1 = true
197
- @index += 1
198
- else
199
- r1 = nil
200
- end
201
- if r1
202
- s0 << r1
203
- else
204
- break
205
- end
206
- end
207
- if s0.empty?
208
- @index = i0
209
- r0 = nil
210
- else
211
- r0 = instantiate_node(BookNode,input, i0...index, s0)
212
- end
213
-
214
- node_cache[:book][start_index] = r0
215
-
216
- r0
217
- end
218
-
219
- module Chapter0
220
- def verse_list
221
- elements[4]
222
- end
223
- end
224
-
225
- def _nt_chapter
226
- start_index = index
227
- if node_cache[:chapter].has_key?(index)
228
- cached = node_cache[:chapter][index]
229
- if cached
230
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
231
- @index = cached.interval.end
232
- end
233
- return cached
234
- end
235
-
236
- i0, s0 = index, []
237
- s1, i1 = [], index
238
- loop do
239
- if has_terminal?('\G[\\d]', true, index)
240
- r2 = true
241
- @index += 1
242
- else
243
- r2 = nil
244
- end
245
- if r2
246
- s1 << r2
247
- else
248
- break
249
- end
250
- end
251
- if s1.empty?
252
- @index = i1
253
- r1 = nil
254
- else
255
- r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
256
- end
257
- s0 << r1
258
- if r1
259
- s3, i3 = [], index
260
- loop do
261
- if has_terminal?('\G[\\s]', true, index)
262
- r4 = true
263
- @index += 1
264
- else
265
- r4 = nil
266
- end
267
- if r4
268
- s3 << r4
269
- else
270
- break
271
- end
272
- end
273
- r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
274
- s0 << r3
275
- if r3
276
- if has_terminal?(":", false, index)
277
- r5 = instantiate_node(SyntaxNode,input, index...(index + 1))
278
- @index += 1
279
- else
280
- terminal_parse_failure(":")
281
- r5 = nil
282
- end
283
- s0 << r5
284
- if r5
285
- s6, i6 = [], index
286
- loop do
287
- if has_terminal?('\G[\\s]', true, index)
288
- r7 = true
289
- @index += 1
290
- else
291
- r7 = nil
292
- end
293
- if r7
294
- s6 << r7
295
- else
296
- break
297
- end
298
- end
299
- r6 = instantiate_node(SyntaxNode,input, i6...index, s6)
300
- s0 << r6
301
- if r6
302
- r8 = _nt_verse_list
303
- s0 << r8
304
- end
305
- end
306
- end
307
- end
308
- if s0.last
309
- r0 = instantiate_node(ChapterNode,input, i0...index, s0)
310
- r0.extend(Chapter0)
311
- else
312
- @index = i0
313
- r0 = nil
314
- end
315
-
316
- node_cache[:chapter][start_index] = r0
317
-
318
- r0
319
- end
320
-
321
- module VerseList0
322
- def verse_list
323
- elements[3]
324
- end
325
- end
326
-
327
- module VerseList1
328
- def verse
329
- elements[0]
330
- end
331
-
332
- end
333
-
334
- def _nt_verse_list
335
- start_index = index
336
- if node_cache[:verse_list].has_key?(index)
337
- cached = node_cache[:verse_list][index]
338
- if cached
339
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
340
- @index = cached.interval.end
341
- end
342
- return cached
343
- end
344
-
345
- i0, s0 = index, []
346
- r1 = _nt_verse
347
- s0 << r1
348
- if r1
349
- i3, s3 = index, []
350
- s4, i4 = [], index
351
- loop do
352
- if has_terminal?('\G[\\s]', true, index)
353
- r5 = true
354
- @index += 1
355
- else
356
- r5 = nil
357
- end
358
- if r5
359
- s4 << r5
360
- else
361
- break
362
- end
363
- end
364
- r4 = instantiate_node(SyntaxNode,input, i4...index, s4)
365
- s3 << r4
366
- if r4
367
- if has_terminal?(",", false, index)
368
- r6 = instantiate_node(SyntaxNode,input, index...(index + 1))
369
- @index += 1
370
- else
371
- terminal_parse_failure(",")
372
- r6 = nil
373
- end
374
- s3 << r6
375
- if r6
376
- s7, i7 = [], index
377
- loop do
378
- if has_terminal?('\G[\\s]', true, index)
379
- r8 = true
380
- @index += 1
381
- else
382
- r8 = nil
383
- end
384
- if r8
385
- s7 << r8
386
- else
387
- break
388
- end
389
- end
390
- r7 = instantiate_node(SyntaxNode,input, i7...index, s7)
391
- s3 << r7
392
- if r7
393
- r9 = _nt_verse_list
394
- s3 << r9
395
- end
396
- end
397
- end
398
- if s3.last
399
- r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
400
- r3.extend(VerseList0)
401
- else
402
- @index = i3
403
- r3 = nil
404
- end
405
- if r3
406
- r2 = r3
407
- else
408
- r2 = instantiate_node(SyntaxNode,input, index...index)
409
- end
410
- s0 << r2
411
- end
412
- if s0.last
413
- r0 = instantiate_node(VerseListNode,input, i0...index, s0)
414
- r0.extend(VerseList1)
415
- else
416
- @index = i0
417
- r0 = nil
418
- end
419
-
420
- node_cache[:verse_list][start_index] = r0
421
-
422
- r0
423
- end
424
-
425
- module Verse0
426
- def starter
427
- elements[2]
428
- end
429
-
430
- def terminator
431
- elements[4]
432
- end
433
- end
434
-
435
- def _nt_verse
436
- start_index = index
437
- if node_cache[:verse].has_key?(index)
438
- cached = node_cache[:verse][index]
439
- if cached
440
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
441
- @index = cached.interval.end
442
- end
443
- return cached
444
- end
445
-
446
- i0, s0 = index, []
447
- i1 = index
448
- r2 = _nt_compound_verse_number
449
- if r2
450
- r1 = r2
451
- else
452
- r3 = _nt_verse_number
453
- if r3
454
- r1 = r3
455
- else
456
- @index = i1
457
- r1 = nil
458
- end
459
- end
460
- s0 << r1
461
- if r1
462
- s4, i4 = [], index
463
- loop do
464
- if has_terminal?('\G[\\s]', true, index)
465
- r5 = true
466
- @index += 1
467
- else
468
- r5 = nil
469
- end
470
- if r5
471
- s4 << r5
472
- else
473
- break
474
- end
475
- end
476
- r4 = instantiate_node(SyntaxNode,input, i4...index, s4)
477
- s0 << r4
478
- if r4
479
- r6 = _nt_starter
480
- s0 << r6
481
- if r6
482
- s7, i7 = [], index
483
- loop do
484
- if has_terminal?('\G[\\s]', true, index)
485
- r8 = true
486
- @index += 1
487
- else
488
- r8 = nil
489
- end
490
- if r8
491
- s7 << r8
492
- else
493
- break
494
- end
495
- end
496
- r7 = instantiate_node(SyntaxNode,input, i7...index, s7)
497
- s0 << r7
498
- if r7
499
- r9 = _nt_terminator
500
- s0 << r9
501
- end
502
- end
503
- end
504
- end
505
- if s0.last
506
- r0 = instantiate_node(VerseNode,input, i0...index, s0)
507
- r0.extend(Verse0)
508
- else
509
- @index = i0
510
- r0 = nil
511
- end
512
-
513
- node_cache[:verse][start_index] = r0
514
-
515
- r0
516
- end
517
-
518
- module CompoundVerseNumber0
519
- def verse_number1
520
- elements[0]
521
- end
522
-
523
- def verse_number2
524
- elements[4]
525
- end
526
- end
527
-
528
- def _nt_compound_verse_number
529
- start_index = index
530
- if node_cache[:compound_verse_number].has_key?(index)
531
- cached = node_cache[:compound_verse_number][index]
532
- if cached
533
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
534
- @index = cached.interval.end
535
- end
536
- return cached
537
- end
538
-
539
- i0, s0 = index, []
540
- r1 = _nt_verse_number
541
- s0 << r1
542
- if r1
543
- s2, i2 = [], index
544
- loop do
545
- if has_terminal?('\G[\\s]', true, index)
546
- r3 = true
547
- @index += 1
548
- else
549
- r3 = nil
550
- end
551
- if r3
552
- s2 << r3
553
- else
554
- break
555
- end
556
- end
557
- r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
558
- s0 << r2
559
- if r2
560
- if has_terminal?("-", false, index)
561
- r4 = instantiate_node(SyntaxNode,input, index...(index + 1))
562
- @index += 1
563
- else
564
- terminal_parse_failure("-")
565
- r4 = nil
566
- end
567
- s0 << r4
568
- if r4
569
- s5, i5 = [], index
570
- loop do
571
- if has_terminal?('\G[\\s]', true, index)
572
- r6 = true
573
- @index += 1
574
- else
575
- r6 = nil
576
- end
577
- if r6
578
- s5 << r6
579
- else
580
- break
581
- end
582
- end
583
- r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
584
- s0 << r5
585
- if r5
586
- r7 = _nt_verse_number
587
- s0 << r7
588
- end
589
- end
590
- end
591
- end
592
- if s0.last
593
- r0 = instantiate_node(CompoundVerseNumberNode,input, i0...index, s0)
594
- r0.extend(CompoundVerseNumber0)
595
- else
596
- @index = i0
597
- r0 = nil
598
- end
599
-
600
- node_cache[:compound_verse_number][start_index] = r0
601
-
602
- r0
603
- end
604
-
605
- def _nt_verse_number
606
- start_index = index
607
- if node_cache[:verse_number].has_key?(index)
608
- cached = node_cache[:verse_number][index]
609
- if cached
610
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
611
- @index = cached.interval.end
612
- end
613
- return cached
614
- end
615
-
616
- s0, i0 = [], index
617
- loop do
618
- if has_terminal?('\G[\\d]', true, index)
619
- r1 = true
620
- @index += 1
621
- else
622
- r1 = nil
623
- end
624
- if r1
625
- s0 << r1
626
- else
627
- break
628
- end
629
- end
630
- if s0.empty?
631
- @index = i0
632
- r0 = nil
633
- else
634
- r0 = instantiate_node(VerseNumberNode,input, i0...index, s0)
635
- end
636
-
637
- node_cache[:verse_number][start_index] = r0
638
-
639
- r0
640
- end
641
-
642
- module Starter0
643
- def cardinality
644
- elements[0]
645
- end
646
-
647
- def starter_fragment
648
- elements[2]
649
- end
650
- end
651
-
652
- def _nt_starter
653
- start_index = index
654
- if node_cache[:starter].has_key?(index)
655
- cached = node_cache[:starter][index]
656
- if cached
657
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
658
- @index = cached.interval.end
659
- end
660
- return cached
661
- end
662
-
663
- i1, s1 = index, []
664
- r2 = _nt_cardinality
665
- s1 << r2
666
- if r2
667
- s3, i3 = [], index
668
- loop do
669
- if has_terminal?('\G[\\s]', true, index)
670
- r4 = true
671
- @index += 1
672
- else
673
- r4 = nil
674
- end
675
- if r4
676
- s3 << r4
677
- else
678
- break
679
- end
680
- end
681
- r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
682
- s1 << r3
683
- if r3
684
- r5 = _nt_starter_fragment
685
- s1 << r5
686
- end
687
- end
688
- if s1.last
689
- r1 = instantiate_node(StarterNode,input, i1...index, s1)
690
- r1.extend(Starter0)
691
- else
692
- @index = i1
693
- r1 = nil
694
- end
695
- if r1
696
- r0 = r1
697
- else
698
- r0 = instantiate_node(SyntaxNode,input, index...index)
699
- end
700
-
701
- node_cache[:starter][start_index] = r0
702
-
703
- r0
704
- end
705
-
706
- def _nt_starter_fragment
707
- start_index = index
708
- if node_cache[:starter_fragment].has_key?(index)
709
- cached = node_cache[:starter_fragment][index]
710
- if cached
711
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
712
- @index = cached.interval.end
713
- end
714
- return cached
715
- end
716
-
717
- s1, i1 = [], index
718
- loop do
719
- if has_terminal?('\G[^\\(\\)\\,\\;]', true, index)
720
- r2 = true
721
- @index += 1
722
- else
723
- r2 = nil
724
- end
725
- if r2
726
- s1 << r2
727
- else
728
- break
729
- end
730
- end
731
- if s1.empty?
732
- @index = i1
733
- r1 = nil
734
- else
735
- r1 = instantiate_node(FragmentNode,input, i1...index, s1)
736
- end
737
- if r1
738
- r0 = r1
739
- else
740
- r0 = instantiate_node(SyntaxNode,input, index...index)
741
- end
742
-
743
- node_cache[:starter_fragment][start_index] = r0
744
-
745
- r0
746
- end
747
-
748
- module Terminator0
749
- def cardinality
750
- elements[4]
751
- end
752
-
753
- def terminator_fragment
754
- elements[6]
755
- end
756
-
757
- end
758
-
759
- def _nt_terminator
760
- start_index = index
761
- if node_cache[:terminator].has_key?(index)
762
- cached = node_cache[:terminator][index]
763
- if cached
764
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
765
- @index = cached.interval.end
766
- end
767
- return cached
768
- end
769
-
770
- i1, s1 = index, []
771
- if has_terminal?("(", false, index)
772
- r2 = instantiate_node(SyntaxNode,input, index...(index + 1))
773
- @index += 1
774
- else
775
- terminal_parse_failure("(")
776
- r2 = nil
777
- end
778
- s1 << r2
779
- if r2
780
- s3, i3 = [], index
781
- loop do
782
- if has_terminal?('\G[\\s]', true, index)
783
- r4 = true
784
- @index += 1
785
- else
786
- r4 = nil
787
- end
788
- if r4
789
- s3 << r4
790
- else
791
- break
792
- end
793
- end
794
- r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
795
- s1 << r3
796
- if r3
797
- if has_terminal?("to", false, index)
798
- r5 = instantiate_node(SyntaxNode,input, index...(index + 2))
799
- @index += 2
800
- else
801
- terminal_parse_failure("to")
802
- r5 = nil
803
- end
804
- s1 << r5
805
- if r5
806
- s6, i6 = [], index
807
- loop do
808
- if has_terminal?('\G[\\s]', true, index)
809
- r7 = true
810
- @index += 1
811
- else
812
- r7 = nil
813
- end
814
- if r7
815
- s6 << r7
816
- else
817
- break
818
- end
819
- end
820
- r6 = instantiate_node(SyntaxNode,input, i6...index, s6)
821
- s1 << r6
822
- if r6
823
- r8 = _nt_cardinality
824
- s1 << r8
825
- if r8
826
- s9, i9 = [], index
827
- loop do
828
- if has_terminal?('\G[\\s]', true, index)
829
- r10 = true
830
- @index += 1
831
- else
832
- r10 = nil
833
- end
834
- if r10
835
- s9 << r10
836
- else
837
- break
838
- end
839
- end
840
- r9 = instantiate_node(SyntaxNode,input, i9...index, s9)
841
- s1 << r9
842
- if r9
843
- r11 = _nt_terminator_fragment
844
- s1 << r11
845
- if r11
846
- s12, i12 = [], index
847
- loop do
848
- if has_terminal?('\G[\\s]', true, index)
849
- r13 = true
850
- @index += 1
851
- else
852
- r13 = nil
853
- end
854
- if r13
855
- s12 << r13
856
- else
857
- break
858
- end
859
- end
860
- r12 = instantiate_node(SyntaxNode,input, i12...index, s12)
861
- s1 << r12
862
- if r12
863
- if has_terminal?(")", false, index)
864
- r14 = instantiate_node(SyntaxNode,input, index...(index + 1))
865
- @index += 1
866
- else
867
- terminal_parse_failure(")")
868
- r14 = nil
869
- end
870
- s1 << r14
871
- end
872
- end
873
- end
874
- end
875
- end
876
- end
877
- end
878
- end
879
- if s1.last
880
- r1 = instantiate_node(TerminatorNode,input, i1...index, s1)
881
- r1.extend(Terminator0)
882
- else
883
- @index = i1
884
- r1 = nil
885
- end
886
- if r1
887
- r0 = r1
888
- else
889
- r0 = instantiate_node(SyntaxNode,input, index...index)
890
- end
891
-
892
- node_cache[:terminator][start_index] = r0
893
-
894
- r0
895
- end
896
-
897
- def _nt_terminator_fragment
898
- start_index = index
899
- if node_cache[:terminator_fragment].has_key?(index)
900
- cached = node_cache[:terminator_fragment][index]
901
- if cached
902
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
903
- @index = cached.interval.end
904
- end
905
- return cached
906
- end
907
-
908
- s1, i1 = [], index
909
- loop do
910
- if has_terminal?('\G[^\\(\\)]', true, index)
911
- r2 = true
912
- @index += 1
913
- else
914
- r2 = nil
915
- end
916
- if r2
917
- s1 << r2
918
- else
919
- break
920
- end
921
- end
922
- if s1.empty?
923
- @index = i1
924
- r1 = nil
925
- else
926
- r1 = instantiate_node(FragmentNode,input, i1...index, s1)
927
- end
928
- if r1
929
- r0 = r1
930
- else
931
- r0 = instantiate_node(SyntaxNode,input, index...index)
932
- end
933
-
934
- node_cache[:terminator_fragment][start_index] = r0
935
-
936
- r0
937
- end
938
-
939
- def _nt_cardinality
940
- start_index = index
941
- if node_cache[:cardinality].has_key?(index)
942
- cached = node_cache[:cardinality][index]
943
- if cached
944
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
945
- @index = cached.interval.end
946
- end
947
- return cached
948
- end
949
-
950
- i1 = index
951
- if has_terminal?("1st", false, index)
952
- r2 = instantiate_node(SyntaxNode,input, index...(index + 3))
953
- @index += 3
954
- else
955
- terminal_parse_failure("1st")
956
- r2 = nil
957
- end
958
- if r2
959
- r1 = r2
960
- else
961
- if has_terminal?("2nd", false, index)
962
- r3 = instantiate_node(SyntaxNode,input, index...(index + 3))
963
- @index += 3
964
- else
965
- terminal_parse_failure("2nd")
966
- r3 = nil
967
- end
968
- if r3
969
- r1 = r3
970
- else
971
- if has_terminal?("3rd", false, index)
972
- r4 = instantiate_node(SyntaxNode,input, index...(index + 3))
973
- @index += 3
974
- else
975
- terminal_parse_failure("3rd")
976
- r4 = nil
977
- end
978
- if r4
979
- r1 = r4
980
- else
981
- @index = i1
982
- r1 = nil
983
- end
984
- end
985
- end
986
- if r1
987
- r0 = r1
988
- else
989
- r0 = instantiate_node(SyntaxNode,input, index...index)
990
- end
991
-
992
- node_cache[:cardinality][start_index] = r0
993
-
994
- r0
995
- end
996
-
997
- end
998
-
999
- class BibleParser < Treetop::Runtime::CompiledParser
1000
- include Bible
1001
- end
1002
-
1003
-
1004
- end
1005
- end