bel_parser 1.0.0.alpha.38-java → 1.0.0.alpha.39-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/bel_parser/ast_filter.rb +6 -2
- data/lib/bel_parser/parsers/ast/node.rb +113 -58
- data/lib/bel_parser/parsers/bel_script/define_annotation.rb +4175 -3097
- data/lib/bel_parser/parsers/bel_script/define_annotation.rl +142 -49
- data/lib/bel_parser/parsers/bel_script/define_namespace.rb +980 -461
- data/lib/bel_parser/parsers/bel_script/define_namespace.rl +79 -39
- data/lib/bel_parser/parsers/bel_script/set.rb +4878 -2743
- data/lib/bel_parser/parsers/bel_script/set.rl +114 -32
- data/lib/bel_parser/parsers/bel_script/set_document.rb +5839 -5292
- data/lib/bel_parser/parsers/bel_script/set_document.rl +130 -27
- data/lib/bel_parser/parsers/bel_script/unset.rb +321 -234
- data/lib/bel_parser/parsers/bel_script/unset.rl +49 -21
- data/lib/bel_parser/parsers/common/blank_line.rb +12 -11
- data/lib/bel_parser/parsers/common/blank_line.rl +12 -12
- data/lib/bel_parser/parsers/common/comment_line.rb +65 -40
- data/lib/bel_parser/parsers/common/comment_line.rl +26 -26
- data/lib/bel_parser/parsers/common/common.rl +60 -0
- data/lib/bel_parser/parsers/common/function.rb +319 -0
- data/lib/bel_parser/parsers/common/function.rl +149 -0
- data/lib/bel_parser/parsers/common/identifier.rb +72 -68
- data/lib/bel_parser/parsers/common/identifier.rl +73 -29
- data/lib/bel_parser/parsers/common/list.rb +1617 -1243
- data/lib/bel_parser/parsers/common/list.rl +120 -60
- data/lib/bel_parser/parsers/common/string.rb +114 -41
- data/lib/bel_parser/parsers/common/string.rl +91 -28
- data/lib/bel_parser/parsers/common.rb +1 -0
- data/lib/bel_parser/parsers/expression/comment.rb +70 -38
- data/lib/bel_parser/parsers/expression/comment.rl +37 -20
- data/lib/bel_parser/parsers/expression/nested_statement.rb +63116 -13958
- data/lib/bel_parser/parsers/expression/nested_statement.rl +53 -23
- data/lib/bel_parser/parsers/expression/observed_term.rb +32497 -5188
- data/lib/bel_parser/parsers/expression/observed_term.rl +25 -20
- data/lib/bel_parser/parsers/expression/parameter.rb +2861 -847
- data/lib/bel_parser/parsers/expression/parameter.rl +178 -21
- data/lib/bel_parser/parsers/expression/relationship.rb +73 -55
- data/lib/bel_parser/parsers/expression/relationship.rl +41 -23
- data/lib/bel_parser/parsers/expression/simple_statement.rb +42895 -7846
- data/lib/bel_parser/parsers/expression/simple_statement.rl +41 -24
- data/lib/bel_parser/parsers/expression/term.rb +16498 -2602
- data/lib/bel_parser/parsers/expression/term.rl +52 -35
- data/lib/bel_parser/parsers/line_parser.rb +1 -0
- data/lib/bel_parser/parsers/mixin/buffer.rb +4 -0
- data/lib/bel_parser/parsers/tracer.rb +19 -0
- data/lib/bel_parser/script/state/namespace_definition.rb +1 -0
- metadata +10 -7
@@ -8,69 +8,156 @@
|
|
8
8
|
include 'string.rl';
|
9
9
|
include 'list.rl';
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
PATTERN_KW = [pP][aA][tT][tT][eE][rR][nN];
|
16
|
-
URL_KW = [uU][rR][lL];
|
17
|
-
|
18
|
-
action annotation_keyword {
|
19
|
-
@buffers[:annotation_definition] = annotation_definition()
|
11
|
+
action add_name {
|
12
|
+
trace('DEFINE_ANNOTATION add_name')
|
13
|
+
name = @buffers.delete(:ident)
|
14
|
+
@buffers[:annotation_definition_name] = name
|
20
15
|
}
|
21
16
|
|
22
|
-
action
|
23
|
-
|
24
|
-
|
17
|
+
action add_string_value {
|
18
|
+
trace('DEFINE_ANNOTATION add_string_value')
|
19
|
+
string_node = @buffers.delete(:string)
|
20
|
+
if @url_domain
|
21
|
+
leaf = domain(url(string_node))
|
22
|
+
leaf.complete = string_node.complete
|
23
|
+
elsif @pattern_domain
|
24
|
+
leaf = domain(pattern(string_node))
|
25
|
+
leaf.complete = string_node.complete
|
26
|
+
else
|
27
|
+
leaf = domain(string_node)
|
28
|
+
# defined as list, given string
|
29
|
+
leaf.complete = false
|
30
|
+
end
|
31
|
+
@buffers[:annotation_definition_domain] = leaf
|
25
32
|
}
|
26
33
|
|
27
|
-
action
|
28
|
-
|
34
|
+
action add_list_value {
|
35
|
+
trace('DEFINE_ANNOTATION add_list_value')
|
36
|
+
list_node = @buffers.delete(:list)
|
37
|
+
if @url_domain
|
38
|
+
leaf = domain(url(list_node))
|
39
|
+
# defined as url, given list
|
40
|
+
leaf.completed = false
|
41
|
+
elsif @pattern_domain
|
42
|
+
leaf = domain(pattern(list_node))
|
43
|
+
# defined as url, given pattern
|
44
|
+
leaf.complete = false
|
45
|
+
else
|
46
|
+
leaf = domain(list_node)
|
47
|
+
leaf.complete = list_node.complete
|
48
|
+
end
|
49
|
+
@buffers[:annotation_definition_domain] = leaf
|
29
50
|
}
|
30
51
|
|
31
|
-
action
|
32
|
-
|
52
|
+
action add_list_domain {
|
53
|
+
trace('DEFINE_ANNOTATION add_list_domain')
|
54
|
+
@list_domain = true
|
33
55
|
}
|
34
56
|
|
35
|
-
action
|
36
|
-
|
57
|
+
action add_url_domain {
|
58
|
+
trace('DEFINE_ANNOTATION add_url_domain')
|
59
|
+
@url_domain = true
|
37
60
|
}
|
38
61
|
|
39
|
-
action
|
40
|
-
|
41
|
-
|
42
|
-
domain.children[0] << @buffers[:string])
|
43
|
-
@buffers[:annotation_definition] = annotation_definition(keyword, domain)
|
62
|
+
action add_pattern_domain {
|
63
|
+
trace('DEFINE_ANNOTATION add_pattern_domain')
|
64
|
+
@pattern_domain = true
|
44
65
|
}
|
45
66
|
|
46
|
-
action
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
67
|
+
action define_annotation_end {
|
68
|
+
trace('DEFINE_ANNOTATION define_annotation_end')
|
69
|
+
annotation_definition_node = annotation_definition()
|
70
|
+
domain = @buffers.delete(:annotation_definition_domain)
|
71
|
+
unless domain.nil?
|
72
|
+
annotation_definition_node <<= domain
|
73
|
+
annotation_definition_node.complete = domain.complete
|
74
|
+
end
|
75
|
+
@buffers[:annotation_definition] = annotation_definition_node
|
51
76
|
}
|
52
77
|
|
53
|
-
action
|
54
|
-
|
55
|
-
|
56
|
-
@buffers[:list])
|
57
|
-
@buffers[:annotation_definition] = annotation_definition(keyword, domain)
|
78
|
+
action yield_define_annotation {
|
79
|
+
trace('DEFINE_ANNOTATION yield_define_annotation')
|
80
|
+
yield @buffers[:annotation_definition]
|
58
81
|
}
|
59
82
|
|
60
|
-
action
|
61
|
-
|
83
|
+
action define_annotation_node_eof {
|
84
|
+
trace('DEFINE_ANNOTATION define_annotation_node_eof')
|
85
|
+
annotation_definition_node = annotation_definition()
|
86
|
+
if @url_domain
|
87
|
+
domain_node = domain(url())
|
88
|
+
elsif @pattern_domain
|
89
|
+
domain_node = domain(pattern())
|
90
|
+
else
|
91
|
+
domain_node = domain()
|
92
|
+
end
|
93
|
+
|
94
|
+
domain_node.complete = false
|
95
|
+
list_node = @buffers.delete(:list)
|
96
|
+
unless list_node.nil?
|
97
|
+
domain_node <<= list_node
|
98
|
+
domain_node.complete = list_node.complete
|
99
|
+
end
|
100
|
+
string_node = @buffers.delete(:string)
|
101
|
+
unless string_node.nil?
|
102
|
+
domain_node <<= string_node
|
103
|
+
domain_node.complete = string_node.complete
|
104
|
+
end
|
105
|
+
annotation_definition_node <<= domain_node
|
106
|
+
annotation_definition_node.complete = domain_node.complete
|
107
|
+
yield annotation_definition_node
|
62
108
|
}
|
63
109
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
110
|
+
string_value =
|
111
|
+
a_string
|
112
|
+
%add_string_value
|
113
|
+
;
|
114
|
+
|
115
|
+
list_value =
|
116
|
+
a_list
|
117
|
+
%add_list_value
|
118
|
+
;
|
119
|
+
|
120
|
+
value =
|
121
|
+
string_value |
|
122
|
+
list_value
|
123
|
+
;
|
124
|
+
|
125
|
+
list_domain =
|
126
|
+
KW_LIST
|
127
|
+
%add_list_domain
|
128
|
+
;
|
129
|
+
|
130
|
+
url_domain =
|
131
|
+
KW_URL
|
132
|
+
%add_url_domain
|
133
|
+
;
|
134
|
+
|
135
|
+
pattern_domain =
|
136
|
+
KW_PATTERN
|
137
|
+
%add_pattern_domain
|
138
|
+
;
|
139
|
+
|
140
|
+
domain =
|
141
|
+
list_domain |
|
142
|
+
url_domain |
|
143
|
+
pattern_domain
|
144
|
+
;
|
145
|
+
|
146
|
+
define_annotation_node :=
|
147
|
+
DEFINE_ANNOTATION
|
148
|
+
SP+
|
149
|
+
an_ident
|
150
|
+
%add_name
|
151
|
+
SP+
|
152
|
+
KW_AS
|
153
|
+
SP+
|
154
|
+
domain
|
155
|
+
SP+
|
156
|
+
value
|
157
|
+
@eof(define_annotation_node_eof)
|
158
|
+
%define_annotation_end
|
159
|
+
%yield_define_annotation
|
160
|
+
;
|
74
161
|
}%%
|
75
162
|
=end
|
76
163
|
# end: ragel
|
@@ -78,6 +165,7 @@
|
|
78
165
|
require_relative '../ast/node'
|
79
166
|
require_relative '../mixin/buffer'
|
80
167
|
require_relative '../nonblocking_io_wrapper'
|
168
|
+
require_relative '../tracer'
|
81
169
|
|
82
170
|
module BELParser
|
83
171
|
module Parsers
|
@@ -103,25 +191,30 @@ module BELParser
|
|
103
191
|
include Enumerable
|
104
192
|
include BELParser::Parsers::Buffer
|
105
193
|
include BELParser::Parsers::AST::Sexp
|
194
|
+
include BELParser::Parsers::Tracer
|
106
195
|
|
107
196
|
def initialize(content)
|
108
197
|
@content = content
|
109
|
-
# begin: ragel
|
198
|
+
# begin: ragel
|
110
199
|
%% write data;
|
111
|
-
# end: ragel
|
200
|
+
# end: ragel
|
112
201
|
end
|
113
202
|
|
114
203
|
def each
|
115
204
|
@buffers = {}
|
205
|
+
@incomplete = {}
|
206
|
+
@list_domain = false
|
207
|
+
@url_domain = false
|
208
|
+
@pattern_domain = false
|
116
209
|
data = @content.unpack('C*')
|
117
210
|
p = 0
|
118
211
|
pe = data.length
|
119
212
|
eof = data.length
|
120
213
|
|
121
|
-
# begin: ragel
|
214
|
+
# begin: ragel
|
122
215
|
%% write init;
|
123
216
|
%% write exec;
|
124
|
-
# end: ragel
|
217
|
+
# end: ragel
|
125
218
|
end
|
126
219
|
end
|
127
220
|
end
|