cskit 1.0.1 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +7 -4
- data/History.txt +5 -0
- data/cskit.gemspec +5 -8
- data/lib/cskit.rb +15 -66
- data/lib/cskit/annotated_string.rb +1 -1
- data/lib/cskit/annotator.rb +1 -3
- data/lib/cskit/formatters.rb +3 -4
- data/lib/cskit/formatters/bible.rb +4 -5
- data/lib/cskit/formatters/bible/bible_html_formatter.rb +2 -2
- data/lib/cskit/formatters/bible/bible_json_formatter.rb +17 -0
- data/lib/cskit/formatters/bible/bible_plain_text_formatter.rb +3 -3
- data/lib/cskit/formatters/science_health.rb +3 -5
- data/lib/cskit/formatters/science_health/science_health_html_formatter.rb +3 -4
- data/lib/cskit/formatters/science_health/science_health_plain_text_formatter.rb +5 -4
- data/lib/cskit/lesson.rb +3 -5
- data/lib/cskit/lesson/lesson.rb +3 -3
- data/lib/cskit/lesson/section.rb +1 -1
- data/lib/cskit/parsers.rb +6 -3
- data/lib/cskit/parsers/bible.rb +10 -0
- data/lib/cskit/parsers/bible/bible_parser.rb +192 -0
- data/lib/cskit/parsers/bible/bible_tokenizer.rb +32 -0
- data/lib/cskit/parsers/parser.rb +68 -0
- data/lib/cskit/parsers/science_health.rb +10 -0
- data/lib/cskit/parsers/science_health/science_health_parser.rb +201 -0
- data/lib/cskit/parsers/science_health/science_health_tokenizer.rb +33 -0
- data/lib/cskit/parsers/token.rb +17 -0
- data/lib/cskit/parsers/tokenizer.rb +43 -0
- data/lib/cskit/readers.rb +4 -4
- data/lib/cskit/readers/bible_reader.rb +2 -2
- data/lib/cskit/readers/reading.rb +8 -1
- data/lib/cskit/readers/science_health_reader.rb +8 -8
- data/lib/cskit/registry.rb +65 -0
- data/lib/cskit/resources/volumes.rb +3 -3
- data/lib/cskit/resources/volumes/bible.rb +11 -9
- data/lib/cskit/resources/volumes/science_health.rb +10 -9
- data/lib/cskit/version.rb +1 -1
- data/lib/cskit/volume.rb +1 -1
- data/spec/parsers/bible/bible_parser_spec.rb +205 -0
- data/spec/parsers/science_health/science_health_parser_spec.rb +153 -0
- data/spec/spec_helper.rb +8 -0
- metadata +16 -38
- data/lib/cskit/parsers/bible/bible.rb +0 -1005
- data/lib/cskit/parsers/bible/bible.treetop +0 -64
- data/lib/cskit/parsers/bible/nodes.rb +0 -153
- data/lib/cskit/parsers/bible/objects.rb +0 -81
- data/lib/cskit/parsers/science_health/nodes.rb +0 -82
- data/lib/cskit/parsers/science_health/objects.rb +0 -47
- data/lib/cskit/parsers/science_health/science_health.rb +0 -607
- data/lib/cskit/parsers/science_health/science_health.treetop +0 -44
@@ -1,64 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
require 'cskit/parsers/bible/nodes'
|
4
|
-
require 'cskit/parsers/bible/objects'
|
5
|
-
|
6
|
-
module CSKit
|
7
|
-
module Parsers
|
8
|
-
|
9
|
-
grammar Bible
|
10
|
-
rule citation
|
11
|
-
book [\s]* chapter_list <CitationNode>
|
12
|
-
end
|
13
|
-
|
14
|
-
rule chapter_list
|
15
|
-
chapter ([\s]* ";" [\s]* chapter_list)? <ChapterListNode>
|
16
|
-
end
|
17
|
-
|
18
|
-
rule book
|
19
|
-
[a-zA-Z\.\s]+ <BookNode>
|
20
|
-
end
|
21
|
-
|
22
|
-
rule chapter
|
23
|
-
[\d]+ [\s]* ":" [\s]* verse_list <ChapterNode>
|
24
|
-
end
|
25
|
-
|
26
|
-
rule verse_list
|
27
|
-
verse ([\s]* "," [\s]* verse_list)? <VerseListNode>
|
28
|
-
end
|
29
|
-
|
30
|
-
rule verse
|
31
|
-
(compound_verse_number / verse_number) [\s]* starter [\s]* terminator <VerseNode>
|
32
|
-
end
|
33
|
-
|
34
|
-
rule compound_verse_number
|
35
|
-
verse_number [\s]* "-" [\s]* verse_number <CompoundVerseNumberNode>
|
36
|
-
end
|
37
|
-
|
38
|
-
rule verse_number
|
39
|
-
[\d]+ <VerseNumberNode>
|
40
|
-
end
|
41
|
-
|
42
|
-
rule starter
|
43
|
-
(cardinality [\s]* starter_fragment <StarterNode>)?
|
44
|
-
end
|
45
|
-
|
46
|
-
rule starter_fragment
|
47
|
-
([^\(\)\,\;]+ <FragmentNode>)?
|
48
|
-
end
|
49
|
-
|
50
|
-
rule terminator
|
51
|
-
("(" [\s]* "to" [\s]* cardinality [\s]* terminator_fragment [\s]* ")" <TerminatorNode>)?
|
52
|
-
end
|
53
|
-
|
54
|
-
rule terminator_fragment
|
55
|
-
([^\(\)]+ <FragmentNode>)?
|
56
|
-
end
|
57
|
-
|
58
|
-
rule cardinality
|
59
|
-
("1st" / "2nd" / "3rd")?
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
end
|
64
|
-
end
|
@@ -1,153 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
module CSKit
|
4
|
-
module Parsers
|
5
|
-
module Bible
|
6
|
-
|
7
|
-
class CitationNode < Treetop::Runtime::SyntaxNode
|
8
|
-
def to_sexp
|
9
|
-
[[:book, book.to_sexp], [:chapters, chapter_list.to_sexp]]
|
10
|
-
end
|
11
|
-
|
12
|
-
def to_object
|
13
|
-
CSKit::Parsers::Bible::Citation.new(
|
14
|
-
book.text_value,
|
15
|
-
chapter_list.to_object
|
16
|
-
)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
class BookNode < Treetop::Runtime::SyntaxNode
|
21
|
-
def to_sexp
|
22
|
-
text_value
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
class ChapterListNode < Treetop::Runtime::SyntaxNode
|
27
|
-
def to_sexp
|
28
|
-
result = [chapter.to_sexp]
|
29
|
-
|
30
|
-
if elements[1] && elements[1].respond_to?(:chapter_list)
|
31
|
-
result += elements[1].chapter_list.to_sexp
|
32
|
-
end
|
33
|
-
|
34
|
-
result
|
35
|
-
end
|
36
|
-
|
37
|
-
def to_object
|
38
|
-
result = [chapter.to_object]
|
39
|
-
|
40
|
-
if elements[1] && elements[1].respond_to?(:chapter_list)
|
41
|
-
result += elements[1].chapter_list.to_object
|
42
|
-
end
|
43
|
-
|
44
|
-
result
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
class ChapterNode < Treetop::Runtime::SyntaxNode
|
49
|
-
def text_value
|
50
|
-
super.to_i
|
51
|
-
end
|
52
|
-
|
53
|
-
def to_sexp
|
54
|
-
[text_value, verse_list.to_sexp]
|
55
|
-
end
|
56
|
-
|
57
|
-
def to_object
|
58
|
-
CSKit::Parsers::Bible::Chapter.new(
|
59
|
-
text_value,
|
60
|
-
verse_list.to_object
|
61
|
-
)
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
class VerseListNode < Treetop::Runtime::SyntaxNode
|
66
|
-
def to_sexp
|
67
|
-
result = [verse.to_sexp]
|
68
|
-
|
69
|
-
if elements[1] && elements[1].respond_to?(:verse_list)
|
70
|
-
result += elements[1].verse_list.to_sexp
|
71
|
-
end
|
72
|
-
|
73
|
-
result
|
74
|
-
end
|
75
|
-
|
76
|
-
def to_object
|
77
|
-
result = [verse.to_object]
|
78
|
-
|
79
|
-
if elements[1] && elements[1].respond_to?(:verse_list)
|
80
|
-
result += elements[1].verse_list.to_object
|
81
|
-
end
|
82
|
-
|
83
|
-
result
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
class VerseNode < Treetop::Runtime::SyntaxNode
|
88
|
-
def to_sexp
|
89
|
-
elements.flat_map { |e| e.to_sexp if e.respond_to?(:to_sexp) }
|
90
|
-
end
|
91
|
-
|
92
|
-
def to_object
|
93
|
-
line_numbers = elements[0].to_sexp.first
|
94
|
-
|
95
|
-
CSKit::Parsers::Bible::Verse.new(
|
96
|
-
line_numbers.first,
|
97
|
-
line_numbers.last,
|
98
|
-
(starter.to_object rescue nil),
|
99
|
-
(terminator.to_object rescue nil)
|
100
|
-
)
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
class CompoundVerseNumberNode < Treetop::Runtime::SyntaxNode
|
105
|
-
def to_sexp
|
106
|
-
[[verse_number1.text_value.to_i, verse_number2.text_value.to_i]]
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
|
-
class VerseNumberNode < Treetop::Runtime::SyntaxNode
|
111
|
-
def to_sexp
|
112
|
-
[[text_value.to_i, text_value.to_i]]
|
113
|
-
end
|
114
|
-
end
|
115
|
-
|
116
|
-
class PositionalNode < Treetop::Runtime::SyntaxNode
|
117
|
-
def to_sexp
|
118
|
-
[get_cardinality, fragment.value]
|
119
|
-
end
|
120
|
-
|
121
|
-
def get_cardinality
|
122
|
-
card_val = cardinality.text_value.to_i
|
123
|
-
card_val == 0 ? 1 : card_val
|
124
|
-
end
|
125
|
-
|
126
|
-
def to_object
|
127
|
-
Positional.new(get_cardinality, fragment.value)
|
128
|
-
end
|
129
|
-
end
|
130
|
-
|
131
|
-
class StarterNode < PositionalNode
|
132
|
-
def fragment
|
133
|
-
starter_fragment
|
134
|
-
end
|
135
|
-
end
|
136
|
-
|
137
|
-
class TerminatorNode < PositionalNode
|
138
|
-
def fragment
|
139
|
-
terminator_fragment
|
140
|
-
end
|
141
|
-
end
|
142
|
-
|
143
|
-
class FragmentNode < Treetop::Runtime::SyntaxNode
|
144
|
-
def value
|
145
|
-
text_value.strip
|
146
|
-
end
|
147
|
-
|
148
|
-
alias :to_sexp :value
|
149
|
-
end
|
150
|
-
|
151
|
-
end
|
152
|
-
end
|
153
|
-
end
|
@@ -1,81 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
module CSKit
|
4
|
-
module Parsers
|
5
|
-
module Bible
|
6
|
-
|
7
|
-
Citation = Struct.new(:book, :chapter_list) do
|
8
|
-
def to_s
|
9
|
-
"#{book.strip} #{chapter_list.map(&:to_s).join("; ")}"
|
10
|
-
end
|
11
|
-
|
12
|
-
def to_hash
|
13
|
-
{
|
14
|
-
:book => book,
|
15
|
-
:chapters => chapter_list.map(&:to_hash)
|
16
|
-
}
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
Chapter = Struct.new(:chapter_number, :verse_list) do
|
21
|
-
def to_s
|
22
|
-
"#{chapter_number}:#{verse_list.map(&:to_s).join(", ")}"
|
23
|
-
end
|
24
|
-
|
25
|
-
def to_hash
|
26
|
-
{
|
27
|
-
:chapter_number => chapter_number,
|
28
|
-
:verses => verse_list.map(&:to_hash)
|
29
|
-
}
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
Verse = Struct.new(:start, :finish, :starter, :terminator) do
|
34
|
-
def to_s
|
35
|
-
str = if start == finish
|
36
|
-
start.to_s
|
37
|
-
else
|
38
|
-
"#{start}-#{finish}"
|
39
|
-
end
|
40
|
-
|
41
|
-
str << " #{starter}" if starter
|
42
|
-
str << " (to #{terminator})" if terminator
|
43
|
-
str
|
44
|
-
end
|
45
|
-
|
46
|
-
def to_hash
|
47
|
-
{
|
48
|
-
:start => start,
|
49
|
-
:finish => finish,
|
50
|
-
:starter => starter ? starter.to_hash : nil,
|
51
|
-
:terminator => terminator ? terminator.to_hash : nil
|
52
|
-
}
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
Positional = Struct.new(:cardinality, :fragment) do
|
57
|
-
def to_s
|
58
|
-
card_s = case cardinality
|
59
|
-
when 1 then "1st"
|
60
|
-
when 2 then "2nd"
|
61
|
-
when 3 then "3rd"
|
62
|
-
end
|
63
|
-
|
64
|
-
if cardinality
|
65
|
-
"#{card_s} #{fragment}"
|
66
|
-
else
|
67
|
-
fragment
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
def to_hash
|
72
|
-
{
|
73
|
-
:cardinality => cardinality,
|
74
|
-
:fragment => fragment
|
75
|
-
}
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
@@ -1,82 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
module CSKit
|
4
|
-
module Parsers
|
5
|
-
module ScienceHealth
|
6
|
-
|
7
|
-
class CitationNode < Treetop::Runtime::SyntaxNode
|
8
|
-
def to_sexp
|
9
|
-
[[:page, page.to_sexp], [:lines, line_list.to_sexp]]
|
10
|
-
end
|
11
|
-
|
12
|
-
def to_object
|
13
|
-
CSKit::Parsers::ScienceHealth::Citation.new(
|
14
|
-
page.text_value,
|
15
|
-
line_list.to_object
|
16
|
-
)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
class PageNode < Treetop::Runtime::SyntaxNode
|
21
|
-
def to_sexp
|
22
|
-
text_value
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
class LineListNode < Treetop::Runtime::SyntaxNode
|
27
|
-
def to_sexp
|
28
|
-
result = [line.to_sexp]
|
29
|
-
|
30
|
-
if elements[1] && elements[1].respond_to?(:line_list)
|
31
|
-
result += elements[1].line_list.to_sexp
|
32
|
-
end
|
33
|
-
|
34
|
-
result
|
35
|
-
end
|
36
|
-
|
37
|
-
def to_object
|
38
|
-
to_sexp.map do |line|
|
39
|
-
only = line[1] == :only
|
40
|
-
CSKit::Parsers::ScienceHealth::Line.new(
|
41
|
-
line[0].first,
|
42
|
-
line[0].last,
|
43
|
-
only,
|
44
|
-
only ? nil : line[1]
|
45
|
-
)
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
class LineNode < Treetop::Runtime::SyntaxNode
|
51
|
-
def to_sexp
|
52
|
-
elements.flat_map { |e| e.to_sexp if e.respond_to?(:to_sexp) }
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
class CompoundLineNumberNode < Treetop::Runtime::SyntaxNode
|
57
|
-
def to_sexp
|
58
|
-
[[line_number1.text_value.to_i, line_number2.text_value.to_i]]
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
class LineNumberNode < Treetop::Runtime::SyntaxNode
|
63
|
-
def to_sexp
|
64
|
-
[[text_value.to_i, nil]]
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
class OnlyNode < Treetop::Runtime::SyntaxNode
|
69
|
-
def to_sexp
|
70
|
-
:only
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
class StartFragmentNode < Treetop::Runtime::SyntaxNode
|
75
|
-
def to_sexp
|
76
|
-
text_value.strip
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
@@ -1,47 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
module CSKit
|
4
|
-
module Parsers
|
5
|
-
module ScienceHealth
|
6
|
-
|
7
|
-
Citation = Struct.new(:page, :lines) do
|
8
|
-
def to_s
|
9
|
-
"#{page}:#{lines.map(&:to_s).join(", ")}"
|
10
|
-
end
|
11
|
-
|
12
|
-
def to_hash
|
13
|
-
{
|
14
|
-
:page => page,
|
15
|
-
:lines => lines.map(&:to_hash)
|
16
|
-
}
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
Line = Struct.new(:start, :finish, :only, :start_fragment) do
|
21
|
-
alias :only? :only
|
22
|
-
|
23
|
-
def to_s
|
24
|
-
str = if finish
|
25
|
-
"#{start}-#{finish}"
|
26
|
-
else
|
27
|
-
start.to_s
|
28
|
-
end
|
29
|
-
|
30
|
-
str << " (only)" if only?
|
31
|
-
str << " #{start_fragment}" if start_fragment
|
32
|
-
str
|
33
|
-
end
|
34
|
-
|
35
|
-
def to_hash
|
36
|
-
{
|
37
|
-
:start => start,
|
38
|
-
:finish => finish,
|
39
|
-
:only => only,
|
40
|
-
:start_fragment => start_fragment
|
41
|
-
}
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
@@ -1,607 +0,0 @@
|
|
1
|
-
# Autogenerated from a Treetop grammar. Edits may be lost.
|
2
|
-
|
3
|
-
|
4
|
-
# encoding: UTF-8
|
5
|
-
|
6
|
-
require 'cskit/parsers/science_health/nodes'
|
7
|
-
require 'cskit/parsers/science_health/objects'
|
8
|
-
|
9
|
-
module CSKit
|
10
|
-
module Parsers
|
11
|
-
|
12
|
-
module ScienceHealth
|
13
|
-
include Treetop::Runtime
|
14
|
-
|
15
|
-
def root
|
16
|
-
@root ||= :citation
|
17
|
-
end
|
18
|
-
|
19
|
-
module Citation0
|
20
|
-
def page
|
21
|
-
elements[0]
|
22
|
-
end
|
23
|
-
|
24
|
-
def line_list
|
25
|
-
elements[4]
|
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_page
|
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
|
-
if has_terminal?(":", false, index)
|
62
|
-
r4 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
63
|
-
@index += 1
|
64
|
-
else
|
65
|
-
terminal_parse_failure(":")
|
66
|
-
r4 = nil
|
67
|
-
end
|
68
|
-
s0 << r4
|
69
|
-
if r4
|
70
|
-
s5, i5 = [], index
|
71
|
-
loop do
|
72
|
-
if has_terminal?('\G[\\s]', true, index)
|
73
|
-
r6 = true
|
74
|
-
@index += 1
|
75
|
-
else
|
76
|
-
r6 = nil
|
77
|
-
end
|
78
|
-
if r6
|
79
|
-
s5 << r6
|
80
|
-
else
|
81
|
-
break
|
82
|
-
end
|
83
|
-
end
|
84
|
-
r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
|
85
|
-
s0 << r5
|
86
|
-
if r5
|
87
|
-
r7 = _nt_line_list
|
88
|
-
s0 << r7
|
89
|
-
end
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end
|
93
|
-
if s0.last
|
94
|
-
r0 = instantiate_node(CitationNode,input, i0...index, s0)
|
95
|
-
r0.extend(Citation0)
|
96
|
-
else
|
97
|
-
@index = i0
|
98
|
-
r0 = nil
|
99
|
-
end
|
100
|
-
|
101
|
-
node_cache[:citation][start_index] = r0
|
102
|
-
|
103
|
-
r0
|
104
|
-
end
|
105
|
-
|
106
|
-
def _nt_page
|
107
|
-
start_index = index
|
108
|
-
if node_cache[:page].has_key?(index)
|
109
|
-
cached = node_cache[:page][index]
|
110
|
-
if cached
|
111
|
-
cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
112
|
-
@index = cached.interval.end
|
113
|
-
end
|
114
|
-
return cached
|
115
|
-
end
|
116
|
-
|
117
|
-
s0, i0 = [], index
|
118
|
-
loop do
|
119
|
-
if has_terminal?('\G[\\d{1,3}|vi{2}|xi{1,2}|i{0,1}x]', true, index)
|
120
|
-
r1 = true
|
121
|
-
@index += 1
|
122
|
-
else
|
123
|
-
r1 = nil
|
124
|
-
end
|
125
|
-
if r1
|
126
|
-
s0 << r1
|
127
|
-
else
|
128
|
-
break
|
129
|
-
end
|
130
|
-
end
|
131
|
-
if s0.empty?
|
132
|
-
@index = i0
|
133
|
-
r0 = nil
|
134
|
-
else
|
135
|
-
r0 = instantiate_node(PageNode,input, i0...index, s0)
|
136
|
-
end
|
137
|
-
|
138
|
-
node_cache[:page][start_index] = r0
|
139
|
-
|
140
|
-
r0
|
141
|
-
end
|
142
|
-
|
143
|
-
module LineList0
|
144
|
-
def line_list
|
145
|
-
elements[3]
|
146
|
-
end
|
147
|
-
end
|
148
|
-
|
149
|
-
module LineList1
|
150
|
-
def line
|
151
|
-
elements[0]
|
152
|
-
end
|
153
|
-
|
154
|
-
end
|
155
|
-
|
156
|
-
def _nt_line_list
|
157
|
-
start_index = index
|
158
|
-
if node_cache[:line_list].has_key?(index)
|
159
|
-
cached = node_cache[:line_list][index]
|
160
|
-
if cached
|
161
|
-
cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
162
|
-
@index = cached.interval.end
|
163
|
-
end
|
164
|
-
return cached
|
165
|
-
end
|
166
|
-
|
167
|
-
i0, s0 = index, []
|
168
|
-
r1 = _nt_line
|
169
|
-
s0 << r1
|
170
|
-
if r1
|
171
|
-
i3, s3 = index, []
|
172
|
-
s4, i4 = [], index
|
173
|
-
loop do
|
174
|
-
if has_terminal?('\G[\\s]', true, index)
|
175
|
-
r5 = true
|
176
|
-
@index += 1
|
177
|
-
else
|
178
|
-
r5 = nil
|
179
|
-
end
|
180
|
-
if r5
|
181
|
-
s4 << r5
|
182
|
-
else
|
183
|
-
break
|
184
|
-
end
|
185
|
-
end
|
186
|
-
r4 = instantiate_node(SyntaxNode,input, i4...index, s4)
|
187
|
-
s3 << r4
|
188
|
-
if r4
|
189
|
-
if has_terminal?(",", false, index)
|
190
|
-
r6 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
191
|
-
@index += 1
|
192
|
-
else
|
193
|
-
terminal_parse_failure(",")
|
194
|
-
r6 = nil
|
195
|
-
end
|
196
|
-
s3 << r6
|
197
|
-
if r6
|
198
|
-
s7, i7 = [], index
|
199
|
-
loop do
|
200
|
-
if has_terminal?('\G[\\s]', true, index)
|
201
|
-
r8 = true
|
202
|
-
@index += 1
|
203
|
-
else
|
204
|
-
r8 = nil
|
205
|
-
end
|
206
|
-
if r8
|
207
|
-
s7 << r8
|
208
|
-
else
|
209
|
-
break
|
210
|
-
end
|
211
|
-
end
|
212
|
-
r7 = instantiate_node(SyntaxNode,input, i7...index, s7)
|
213
|
-
s3 << r7
|
214
|
-
if r7
|
215
|
-
r9 = _nt_line_list
|
216
|
-
s3 << r9
|
217
|
-
end
|
218
|
-
end
|
219
|
-
end
|
220
|
-
if s3.last
|
221
|
-
r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
|
222
|
-
r3.extend(LineList0)
|
223
|
-
else
|
224
|
-
@index = i3
|
225
|
-
r3 = nil
|
226
|
-
end
|
227
|
-
if r3
|
228
|
-
r2 = r3
|
229
|
-
else
|
230
|
-
r2 = instantiate_node(SyntaxNode,input, index...index)
|
231
|
-
end
|
232
|
-
s0 << r2
|
233
|
-
end
|
234
|
-
if s0.last
|
235
|
-
r0 = instantiate_node(LineListNode,input, i0...index, s0)
|
236
|
-
r0.extend(LineList1)
|
237
|
-
else
|
238
|
-
@index = i0
|
239
|
-
r0 = nil
|
240
|
-
end
|
241
|
-
|
242
|
-
node_cache[:line_list][start_index] = r0
|
243
|
-
|
244
|
-
r0
|
245
|
-
end
|
246
|
-
|
247
|
-
module Line0
|
248
|
-
end
|
249
|
-
|
250
|
-
def _nt_line
|
251
|
-
start_index = index
|
252
|
-
if node_cache[:line].has_key?(index)
|
253
|
-
cached = node_cache[:line][index]
|
254
|
-
if cached
|
255
|
-
cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
256
|
-
@index = cached.interval.end
|
257
|
-
end
|
258
|
-
return cached
|
259
|
-
end
|
260
|
-
|
261
|
-
i0, s0 = index, []
|
262
|
-
i1 = index
|
263
|
-
r2 = _nt_compound_line_number
|
264
|
-
if r2
|
265
|
-
r1 = r2
|
266
|
-
else
|
267
|
-
r3 = _nt_line_number
|
268
|
-
if r3
|
269
|
-
r1 = r3
|
270
|
-
else
|
271
|
-
@index = i1
|
272
|
-
r1 = nil
|
273
|
-
end
|
274
|
-
end
|
275
|
-
s0 << r1
|
276
|
-
if r1
|
277
|
-
i5 = index
|
278
|
-
r6 = _nt_only
|
279
|
-
if r6
|
280
|
-
r5 = r6
|
281
|
-
else
|
282
|
-
r7 = _nt_start_fragment
|
283
|
-
if r7
|
284
|
-
r5 = r7
|
285
|
-
else
|
286
|
-
@index = i5
|
287
|
-
r5 = nil
|
288
|
-
end
|
289
|
-
end
|
290
|
-
if r5
|
291
|
-
r4 = r5
|
292
|
-
else
|
293
|
-
r4 = instantiate_node(SyntaxNode,input, index...index)
|
294
|
-
end
|
295
|
-
s0 << r4
|
296
|
-
end
|
297
|
-
if s0.last
|
298
|
-
r0 = instantiate_node(LineNode,input, i0...index, s0)
|
299
|
-
r0.extend(Line0)
|
300
|
-
else
|
301
|
-
@index = i0
|
302
|
-
r0 = nil
|
303
|
-
end
|
304
|
-
|
305
|
-
node_cache[:line][start_index] = r0
|
306
|
-
|
307
|
-
r0
|
308
|
-
end
|
309
|
-
|
310
|
-
module CompoundLineNumber0
|
311
|
-
def line_number1
|
312
|
-
elements[0]
|
313
|
-
end
|
314
|
-
|
315
|
-
def line_number2
|
316
|
-
elements[4]
|
317
|
-
end
|
318
|
-
end
|
319
|
-
|
320
|
-
def _nt_compound_line_number
|
321
|
-
start_index = index
|
322
|
-
if node_cache[:compound_line_number].has_key?(index)
|
323
|
-
cached = node_cache[:compound_line_number][index]
|
324
|
-
if cached
|
325
|
-
cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
326
|
-
@index = cached.interval.end
|
327
|
-
end
|
328
|
-
return cached
|
329
|
-
end
|
330
|
-
|
331
|
-
i0, s0 = index, []
|
332
|
-
r1 = _nt_line_number
|
333
|
-
s0 << r1
|
334
|
-
if r1
|
335
|
-
s2, i2 = [], index
|
336
|
-
loop do
|
337
|
-
if has_terminal?('\G[\\s]', true, index)
|
338
|
-
r3 = true
|
339
|
-
@index += 1
|
340
|
-
else
|
341
|
-
r3 = nil
|
342
|
-
end
|
343
|
-
if r3
|
344
|
-
s2 << r3
|
345
|
-
else
|
346
|
-
break
|
347
|
-
end
|
348
|
-
end
|
349
|
-
r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
|
350
|
-
s0 << r2
|
351
|
-
if r2
|
352
|
-
if has_terminal?("-", false, index)
|
353
|
-
r4 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
354
|
-
@index += 1
|
355
|
-
else
|
356
|
-
terminal_parse_failure("-")
|
357
|
-
r4 = nil
|
358
|
-
end
|
359
|
-
s0 << r4
|
360
|
-
if r4
|
361
|
-
s5, i5 = [], index
|
362
|
-
loop do
|
363
|
-
if has_terminal?('\G[\\s]', true, index)
|
364
|
-
r6 = true
|
365
|
-
@index += 1
|
366
|
-
else
|
367
|
-
r6 = nil
|
368
|
-
end
|
369
|
-
if r6
|
370
|
-
s5 << r6
|
371
|
-
else
|
372
|
-
break
|
373
|
-
end
|
374
|
-
end
|
375
|
-
r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
|
376
|
-
s0 << r5
|
377
|
-
if r5
|
378
|
-
r7 = _nt_line_number
|
379
|
-
s0 << r7
|
380
|
-
end
|
381
|
-
end
|
382
|
-
end
|
383
|
-
end
|
384
|
-
if s0.last
|
385
|
-
r0 = instantiate_node(CompoundLineNumberNode,input, i0...index, s0)
|
386
|
-
r0.extend(CompoundLineNumber0)
|
387
|
-
else
|
388
|
-
@index = i0
|
389
|
-
r0 = nil
|
390
|
-
end
|
391
|
-
|
392
|
-
node_cache[:compound_line_number][start_index] = r0
|
393
|
-
|
394
|
-
r0
|
395
|
-
end
|
396
|
-
|
397
|
-
def _nt_line_number
|
398
|
-
start_index = index
|
399
|
-
if node_cache[:line_number].has_key?(index)
|
400
|
-
cached = node_cache[:line_number][index]
|
401
|
-
if cached
|
402
|
-
cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
403
|
-
@index = cached.interval.end
|
404
|
-
end
|
405
|
-
return cached
|
406
|
-
end
|
407
|
-
|
408
|
-
s0, i0 = [], index
|
409
|
-
loop do
|
410
|
-
if has_terminal?('\G[\\d]', true, index)
|
411
|
-
r1 = true
|
412
|
-
@index += 1
|
413
|
-
else
|
414
|
-
r1 = nil
|
415
|
-
end
|
416
|
-
if r1
|
417
|
-
s0 << r1
|
418
|
-
else
|
419
|
-
break
|
420
|
-
end
|
421
|
-
end
|
422
|
-
if s0.empty?
|
423
|
-
@index = i0
|
424
|
-
r0 = nil
|
425
|
-
else
|
426
|
-
r0 = instantiate_node(LineNumberNode,input, i0...index, s0)
|
427
|
-
end
|
428
|
-
|
429
|
-
node_cache[:line_number][start_index] = r0
|
430
|
-
|
431
|
-
r0
|
432
|
-
end
|
433
|
-
|
434
|
-
module Only0
|
435
|
-
end
|
436
|
-
|
437
|
-
def _nt_only
|
438
|
-
start_index = index
|
439
|
-
if node_cache[:only].has_key?(index)
|
440
|
-
cached = node_cache[:only][index]
|
441
|
-
if cached
|
442
|
-
cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
443
|
-
@index = cached.interval.end
|
444
|
-
end
|
445
|
-
return cached
|
446
|
-
end
|
447
|
-
|
448
|
-
i0, s0 = index, []
|
449
|
-
s1, i1 = [], index
|
450
|
-
loop do
|
451
|
-
if has_terminal?('\G[\\s]', true, index)
|
452
|
-
r2 = true
|
453
|
-
@index += 1
|
454
|
-
else
|
455
|
-
r2 = nil
|
456
|
-
end
|
457
|
-
if r2
|
458
|
-
s1 << r2
|
459
|
-
else
|
460
|
-
break
|
461
|
-
end
|
462
|
-
end
|
463
|
-
r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
|
464
|
-
s0 << r1
|
465
|
-
if r1
|
466
|
-
if has_terminal?("(", false, index)
|
467
|
-
r3 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
468
|
-
@index += 1
|
469
|
-
else
|
470
|
-
terminal_parse_failure("(")
|
471
|
-
r3 = nil
|
472
|
-
end
|
473
|
-
s0 << r3
|
474
|
-
if r3
|
475
|
-
s4, i4 = [], index
|
476
|
-
loop do
|
477
|
-
if has_terminal?('\G[\\s]', true, index)
|
478
|
-
r5 = true
|
479
|
-
@index += 1
|
480
|
-
else
|
481
|
-
r5 = nil
|
482
|
-
end
|
483
|
-
if r5
|
484
|
-
s4 << r5
|
485
|
-
else
|
486
|
-
break
|
487
|
-
end
|
488
|
-
end
|
489
|
-
r4 = instantiate_node(SyntaxNode,input, i4...index, s4)
|
490
|
-
s0 << r4
|
491
|
-
if r4
|
492
|
-
if has_terminal?("only", false, index)
|
493
|
-
r6 = instantiate_node(SyntaxNode,input, index...(index + 4))
|
494
|
-
@index += 4
|
495
|
-
else
|
496
|
-
terminal_parse_failure("only")
|
497
|
-
r6 = nil
|
498
|
-
end
|
499
|
-
s0 << r6
|
500
|
-
if r6
|
501
|
-
s7, i7 = [], index
|
502
|
-
loop do
|
503
|
-
if has_terminal?('\G[\\s]', true, index)
|
504
|
-
r8 = true
|
505
|
-
@index += 1
|
506
|
-
else
|
507
|
-
r8 = nil
|
508
|
-
end
|
509
|
-
if r8
|
510
|
-
s7 << r8
|
511
|
-
else
|
512
|
-
break
|
513
|
-
end
|
514
|
-
end
|
515
|
-
r7 = instantiate_node(SyntaxNode,input, i7...index, s7)
|
516
|
-
s0 << r7
|
517
|
-
if r7
|
518
|
-
if has_terminal?(")", false, index)
|
519
|
-
r9 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
520
|
-
@index += 1
|
521
|
-
else
|
522
|
-
terminal_parse_failure(")")
|
523
|
-
r9 = nil
|
524
|
-
end
|
525
|
-
s0 << r9
|
526
|
-
if r9
|
527
|
-
s10, i10 = [], index
|
528
|
-
loop do
|
529
|
-
if has_terminal?('\G[\\s]', true, index)
|
530
|
-
r11 = true
|
531
|
-
@index += 1
|
532
|
-
else
|
533
|
-
r11 = nil
|
534
|
-
end
|
535
|
-
if r11
|
536
|
-
s10 << r11
|
537
|
-
else
|
538
|
-
break
|
539
|
-
end
|
540
|
-
end
|
541
|
-
r10 = instantiate_node(SyntaxNode,input, i10...index, s10)
|
542
|
-
s0 << r10
|
543
|
-
end
|
544
|
-
end
|
545
|
-
end
|
546
|
-
end
|
547
|
-
end
|
548
|
-
end
|
549
|
-
if s0.last
|
550
|
-
r0 = instantiate_node(OnlyNode,input, i0...index, s0)
|
551
|
-
r0.extend(Only0)
|
552
|
-
else
|
553
|
-
@index = i0
|
554
|
-
r0 = nil
|
555
|
-
end
|
556
|
-
|
557
|
-
node_cache[:only][start_index] = r0
|
558
|
-
|
559
|
-
r0
|
560
|
-
end
|
561
|
-
|
562
|
-
def _nt_start_fragment
|
563
|
-
start_index = index
|
564
|
-
if node_cache[:start_fragment].has_key?(index)
|
565
|
-
cached = node_cache[:start_fragment][index]
|
566
|
-
if cached
|
567
|
-
cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
568
|
-
@index = cached.interval.end
|
569
|
-
end
|
570
|
-
return cached
|
571
|
-
end
|
572
|
-
|
573
|
-
s0, i0 = [], index
|
574
|
-
loop do
|
575
|
-
if has_terminal?('\G[^,]', true, index)
|
576
|
-
r1 = true
|
577
|
-
@index += 1
|
578
|
-
else
|
579
|
-
r1 = nil
|
580
|
-
end
|
581
|
-
if r1
|
582
|
-
s0 << r1
|
583
|
-
else
|
584
|
-
break
|
585
|
-
end
|
586
|
-
end
|
587
|
-
if s0.empty?
|
588
|
-
@index = i0
|
589
|
-
r0 = nil
|
590
|
-
else
|
591
|
-
r0 = instantiate_node(StartFragmentNode,input, i0...index, s0)
|
592
|
-
end
|
593
|
-
|
594
|
-
node_cache[:start_fragment][start_index] = r0
|
595
|
-
|
596
|
-
r0
|
597
|
-
end
|
598
|
-
|
599
|
-
end
|
600
|
-
|
601
|
-
class ScienceHealthParser < Treetop::Runtime::CompiledParser
|
602
|
-
include ScienceHealth
|
603
|
-
end
|
604
|
-
|
605
|
-
|
606
|
-
end
|
607
|
-
end
|