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
@@ -3,79 +3,134 @@
|
|
3
3
|
%%{
|
4
4
|
machine bel;
|
5
5
|
|
6
|
+
include 'common.rl';
|
6
7
|
include 'identifier.rl';
|
7
8
|
include 'string.rl';
|
8
9
|
|
9
|
-
action
|
10
|
-
|
11
|
-
@
|
10
|
+
action start_list {
|
11
|
+
trace('LIST start_list')
|
12
|
+
@list_opened = true
|
13
|
+
@incomplete[:list] = list()
|
12
14
|
}
|
13
15
|
|
14
|
-
action
|
15
|
-
|
16
|
+
action stop_list {
|
17
|
+
trace('LIST stop_list')
|
18
|
+
@list_closed = true
|
16
19
|
}
|
17
20
|
|
18
|
-
action
|
19
|
-
|
21
|
+
action add_string {
|
22
|
+
trace('LIST add_string')
|
23
|
+
string = @buffers.delete(:string)
|
24
|
+
item = list_item(string, complete: string.complete)
|
25
|
+
@incomplete[:list] <<= item
|
20
26
|
}
|
21
27
|
|
22
|
-
action
|
23
|
-
|
28
|
+
action add_ident {
|
29
|
+
trace('LIST add_ident')
|
30
|
+
ident = @buffers.delete(:ident)
|
31
|
+
item = list_item(ident, complete: ident.complete)
|
32
|
+
@incomplete[:list] <<= item
|
24
33
|
}
|
25
34
|
|
26
|
-
action
|
27
|
-
|
28
|
-
if @
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
35
|
+
action list_end {
|
36
|
+
trace('LIST list_end')
|
37
|
+
if @list_opened && @list_closed
|
38
|
+
list = @incomplete.delete(:list)
|
39
|
+
list.complete = true
|
40
|
+
elsif !@list_closed
|
41
|
+
list = @incomplete.delete(:list)
|
42
|
+
list.complete = false
|
33
43
|
end
|
44
|
+
@buffers[:list] = list
|
34
45
|
}
|
35
46
|
|
36
|
-
action
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
47
|
+
action a_list_eof {
|
48
|
+
trace('LIST a_list_eof')
|
49
|
+
list = @incomplete.delete(:list)
|
50
|
+
string = @buffers.delete(:string)
|
51
|
+
unless string.nil?
|
52
|
+
item = list_item(string, complete: string.complete)
|
53
|
+
list <<= item
|
54
|
+
end
|
55
|
+
ident = @buffers.delete(:ident)
|
56
|
+
unless ident.nil?
|
57
|
+
item = list_item(ident, complete: ident.complete)
|
58
|
+
list <<= item
|
59
|
+
end
|
60
|
+
if @list_opened && @list_closed
|
61
|
+
list.complete = true
|
62
|
+
else
|
63
|
+
list.complete = false
|
64
|
+
end
|
65
|
+
@buffers[:list] = list
|
43
66
|
}
|
44
67
|
|
45
|
-
action
|
46
|
-
|
47
|
-
|
68
|
+
action list_node_eof {
|
69
|
+
trace('LIST list_node_eof')
|
70
|
+
list = @incomplete.delete(:list)
|
71
|
+
string = @buffers.delete(:string)
|
72
|
+
item = list_item(string, complete: string.complete)
|
73
|
+
list <<= item
|
74
|
+
list.complete = false
|
75
|
+
yield list
|
48
76
|
}
|
49
77
|
|
50
|
-
action
|
78
|
+
action yield_list {
|
79
|
+
trace('LIST yield_list')
|
51
80
|
yield @buffers[:list]
|
52
81
|
}
|
53
82
|
|
54
|
-
|
55
|
-
|
56
|
-
yield @buffers[:list]
|
57
|
-
}
|
83
|
+
START_LIST = '{' SP* >start_list;
|
84
|
+
END_LIST = '}' %stop_list;
|
58
85
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
86
|
+
string_item =
|
87
|
+
a_string
|
88
|
+
%add_string
|
89
|
+
;
|
90
|
+
|
91
|
+
ident_item =
|
92
|
+
an_ident
|
93
|
+
%add_ident
|
94
|
+
;
|
95
|
+
|
96
|
+
item =
|
97
|
+
string_item |
|
98
|
+
ident_item
|
99
|
+
;
|
100
|
+
|
101
|
+
list_item_0 =
|
102
|
+
item
|
103
|
+
;
|
104
|
+
|
105
|
+
list_item_n =
|
106
|
+
COMMA_DELIM
|
107
|
+
item
|
108
|
+
;
|
109
|
+
|
110
|
+
items =
|
111
|
+
list_item_0
|
112
|
+
list_item_n*
|
66
113
|
SP*
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
114
|
+
;
|
115
|
+
|
116
|
+
a_list =
|
117
|
+
START_LIST
|
118
|
+
items
|
119
|
+
END_LIST
|
120
|
+
%list_end
|
121
|
+
@eof(a_list_eof)
|
122
|
+
;
|
123
|
+
|
124
|
+
list_node :=
|
125
|
+
START_LIST
|
126
|
+
items?
|
127
|
+
@eof(list_node_eof)
|
128
|
+
END_LIST?
|
129
|
+
@eof(list_node_eof)
|
130
|
+
NL?
|
131
|
+
%list_end
|
132
|
+
%yield_list
|
133
|
+
;
|
79
134
|
}%%
|
80
135
|
=end
|
81
136
|
# end: ragel
|
@@ -83,6 +138,7 @@
|
|
83
138
|
require_relative '../ast/node'
|
84
139
|
require_relative '../mixin/buffer'
|
85
140
|
require_relative '../nonblocking_io_wrapper'
|
141
|
+
require_relative '../tracer'
|
86
142
|
|
87
143
|
module BELParser
|
88
144
|
module Parsers
|
@@ -108,25 +164,29 @@ module BELParser
|
|
108
164
|
include Enumerable
|
109
165
|
include BELParser::Parsers::Buffer
|
110
166
|
include BELParser::Parsers::AST::Sexp
|
167
|
+
include BELParser::Parsers::Tracer
|
111
168
|
|
112
169
|
def initialize(content)
|
113
170
|
@content = content
|
114
|
-
# begin: ragel
|
171
|
+
# begin: ragel
|
115
172
|
%% write data;
|
116
|
-
# end: ragel
|
173
|
+
# end: ragel
|
117
174
|
end
|
118
175
|
|
119
176
|
def each
|
120
|
-
@buffers
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
177
|
+
@buffers = {}
|
178
|
+
@incomplete = {}
|
179
|
+
@list_opened = false
|
180
|
+
@list_closed = false
|
181
|
+
data = @content.unpack('C*')
|
182
|
+
p = 0
|
183
|
+
pe = data.length
|
184
|
+
eof = data.length
|
185
|
+
|
186
|
+
# begin: ragel
|
127
187
|
%% write init;
|
128
188
|
%% write exec;
|
129
|
-
# end: ragel
|
189
|
+
# end: ragel
|
130
190
|
end
|
131
191
|
end
|
132
192
|
end
|
@@ -5,10 +5,12 @@
|
|
5
5
|
|
6
6
|
=end
|
7
7
|
# end: ragel
|
8
|
+
# ('\"' | ^(0 .. 31 | 34))* ^'\\"'
|
8
9
|
|
9
10
|
require_relative '../ast/node'
|
10
11
|
require_relative '../mixin/buffer'
|
11
12
|
require_relative '../nonblocking_io_wrapper'
|
13
|
+
require_relative '../tracer'
|
12
14
|
|
13
15
|
module BELParser
|
14
16
|
module Parsers
|
@@ -34,18 +36,19 @@ module BELParser
|
|
34
36
|
include Enumerable
|
35
37
|
include BELParser::Parsers::Buffer
|
36
38
|
include BELParser::Parsers::AST::Sexp
|
39
|
+
include BELParser::Parsers::Tracer
|
37
40
|
|
38
41
|
def initialize(content)
|
39
42
|
@content = content
|
40
|
-
# begin: ragel
|
43
|
+
# begin: ragel
|
41
44
|
|
42
45
|
class << self
|
43
46
|
attr_accessor :_bel_trans_keys
|
44
47
|
private :_bel_trans_keys, :_bel_trans_keys=
|
45
48
|
end
|
46
49
|
self._bel_trans_keys = [
|
47
|
-
0, 0,
|
48
|
-
|
50
|
+
0, 0, 9, 34, 34, 92,
|
51
|
+
34, 92, 0, 0, 0,
|
49
52
|
0, 0
|
50
53
|
]
|
51
54
|
|
@@ -54,7 +57,7 @@ class << self
|
|
54
57
|
private :_bel_key_spans, :_bel_key_spans=
|
55
58
|
end
|
56
59
|
self._bel_key_spans = [
|
57
|
-
0,
|
60
|
+
0, 26, 59, 59, 0, 0
|
58
61
|
]
|
59
62
|
|
60
63
|
class << self
|
@@ -62,7 +65,7 @@ class << self
|
|
62
65
|
private :_bel_index_offsets, :_bel_index_offsets=
|
63
66
|
end
|
64
67
|
self._bel_index_offsets = [
|
65
|
-
0, 0,
|
68
|
+
0, 0, 27, 87, 147, 148
|
66
69
|
]
|
67
70
|
|
68
71
|
class << self
|
@@ -70,15 +73,25 @@ class << self
|
|
70
73
|
private :_bel_indicies, :_bel_indicies=
|
71
74
|
end
|
72
75
|
self._bel_indicies = [
|
73
|
-
1,
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
76
|
+
1, 1, 1, 1, 1, 0, 0, 0,
|
77
|
+
0, 0, 0, 0, 0, 0, 0, 0,
|
78
|
+
0, 0, 0, 0, 0, 0, 0, 1,
|
79
|
+
0, 2, 0, 4, 3, 3, 3, 3,
|
80
|
+
3, 3, 3, 3, 3, 3, 3, 3,
|
81
|
+
3, 3, 3, 3, 3, 3, 3, 3,
|
82
|
+
3, 3, 3, 3, 3, 3, 3, 3,
|
83
|
+
3, 3, 3, 3, 3, 3, 3, 3,
|
84
|
+
3, 3, 3, 3, 3, 3, 3, 3,
|
85
|
+
3, 3, 3, 3, 3, 3, 3, 3,
|
86
|
+
3, 3, 3, 3, 3, 5, 3, 7,
|
87
|
+
6, 6, 6, 6, 6, 6, 6, 6,
|
88
|
+
6, 6, 6, 6, 6, 6, 6, 6,
|
89
|
+
6, 6, 6, 6, 6, 6, 6, 6,
|
90
|
+
6, 6, 6, 6, 6, 6, 6, 6,
|
91
|
+
6, 6, 6, 6, 6, 6, 6, 6,
|
92
|
+
6, 6, 6, 6, 6, 6, 6, 6,
|
93
|
+
6, 6, 6, 6, 6, 6, 6, 6,
|
94
|
+
6, 8, 6, 6, 0, 0
|
82
95
|
]
|
83
96
|
|
84
97
|
class << self
|
@@ -86,7 +99,8 @@ class << self
|
|
86
99
|
private :_bel_trans_targs, :_bel_trans_targs=
|
87
100
|
end
|
88
101
|
self._bel_trans_targs = [
|
89
|
-
0,
|
102
|
+
0, 1, 2, 3, 5, 4, 3, 5,
|
103
|
+
4
|
90
104
|
]
|
91
105
|
|
92
106
|
class << self
|
@@ -94,7 +108,8 @@ class << self
|
|
94
108
|
private :_bel_trans_actions, :_bel_trans_actions=
|
95
109
|
end
|
96
110
|
self._bel_trans_actions = [
|
97
|
-
|
111
|
+
2, 0, 0, 4, 5, 4, 0, 6,
|
112
|
+
0
|
98
113
|
]
|
99
114
|
|
100
115
|
class << self
|
@@ -102,7 +117,7 @@ class << self
|
|
102
117
|
private :_bel_eof_actions, :_bel_eof_actions=
|
103
118
|
end
|
104
119
|
self._bel_eof_actions = [
|
105
|
-
0, 1,
|
120
|
+
0, 1, 3, 3, 3, 0
|
106
121
|
]
|
107
122
|
|
108
123
|
class << self
|
@@ -119,22 +134,27 @@ end
|
|
119
134
|
self.bel_error = 0;
|
120
135
|
|
121
136
|
class << self
|
122
|
-
attr_accessor :
|
137
|
+
attr_accessor :bel_en_string_node
|
123
138
|
end
|
124
|
-
self.
|
139
|
+
self.bel_en_string_node = 1;
|
125
140
|
|
126
141
|
|
127
|
-
# end: ragel
|
142
|
+
# end: ragel
|
128
143
|
end
|
129
144
|
|
130
145
|
def each
|
131
|
-
@buffers
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
146
|
+
@buffers = {}
|
147
|
+
@incomplete = {}
|
148
|
+
@string_opened = false
|
149
|
+
@string_closed = false
|
150
|
+
data = @content.unpack('C*')
|
151
|
+
p_start = 0
|
152
|
+
p_end = 0
|
153
|
+
p = 0
|
154
|
+
pe = data.length
|
155
|
+
eof = data.length
|
156
|
+
|
157
|
+
# begin: ragel
|
138
158
|
|
139
159
|
begin
|
140
160
|
p ||= 0
|
@@ -179,38 +199,66 @@ begin
|
|
179
199
|
cs = _bel_trans_targs[_trans]
|
180
200
|
if _bel_trans_actions[_trans] != 0
|
181
201
|
case _bel_trans_actions[_trans]
|
182
|
-
when
|
202
|
+
when 4 then
|
183
203
|
begin
|
184
204
|
|
185
|
-
(
|
205
|
+
trace('STRING start_string')
|
206
|
+
@string_opened = true
|
207
|
+
p_start = p
|
186
208
|
end
|
187
209
|
when 2 then
|
188
210
|
begin
|
189
211
|
|
190
|
-
|
212
|
+
trace('STRING string_node_err')
|
213
|
+
p_end = p
|
214
|
+
chars = data[p_start...p_end]
|
215
|
+
ast_node = string(utf8_string(chars), complete: false)
|
216
|
+
yield ast_node
|
191
217
|
end
|
218
|
+
when 6 then
|
192
219
|
begin
|
193
220
|
|
194
|
-
(
|
221
|
+
trace('STRING stop_string')
|
222
|
+
@string_closed = true
|
223
|
+
p_end = p
|
195
224
|
end
|
196
|
-
when 4 then
|
197
225
|
begin
|
198
226
|
|
199
|
-
|
227
|
+
trace('STRING string_end')
|
228
|
+
completed = @string_opened && @string_closed
|
229
|
+
chars = data[p_start...p_end]
|
230
|
+
ast_node = string(utf8_string(chars), complete: true)
|
231
|
+
@buffers[:string] = ast_node
|
200
232
|
end
|
201
233
|
begin
|
202
234
|
|
235
|
+
trace('STRING yield_string')
|
203
236
|
yield @buffers[:string]
|
204
237
|
end
|
205
|
-
when
|
238
|
+
when 5 then
|
239
|
+
begin
|
240
|
+
|
241
|
+
trace('STRING start_string')
|
242
|
+
@string_opened = true
|
243
|
+
p_start = p
|
244
|
+
end
|
245
|
+
begin
|
246
|
+
|
247
|
+
trace('STRING stop_string')
|
248
|
+
@string_closed = true
|
249
|
+
p_end = p
|
250
|
+
end
|
206
251
|
begin
|
207
252
|
|
208
|
-
|
209
|
-
|
253
|
+
trace('STRING string_end')
|
254
|
+
completed = @string_opened && @string_closed
|
255
|
+
chars = data[p_start...p_end]
|
256
|
+
ast_node = string(utf8_string(chars), complete: true)
|
257
|
+
@buffers[:string] = ast_node
|
210
258
|
end
|
211
259
|
begin
|
212
260
|
|
213
|
-
|
261
|
+
trace('STRING yield_string')
|
214
262
|
yield @buffers[:string]
|
215
263
|
end
|
216
264
|
end
|
@@ -233,12 +281,37 @@ begin
|
|
233
281
|
when 1 then
|
234
282
|
begin
|
235
283
|
|
236
|
-
|
237
|
-
|
284
|
+
trace('STRING string_node_err')
|
285
|
+
p_end = p
|
286
|
+
chars = data[p_start...p_end]
|
287
|
+
ast_node = string(utf8_string(chars), complete: false)
|
288
|
+
yield ast_node
|
289
|
+
end
|
290
|
+
begin
|
291
|
+
|
292
|
+
trace('STRING string_node_eof')
|
293
|
+
yield @buffers[:string]
|
294
|
+
end
|
295
|
+
when 3 then
|
296
|
+
begin
|
297
|
+
|
298
|
+
trace('STRING eof_string')
|
299
|
+
p_end = p
|
300
|
+
chars = data[p_start...p_end]
|
301
|
+
ast_node = string(utf8_string(chars), complete: false)
|
302
|
+
@buffers[:string] = ast_node
|
303
|
+
end
|
304
|
+
begin
|
305
|
+
|
306
|
+
trace('STRING string_node_err')
|
307
|
+
p_end = p
|
308
|
+
chars = data[p_start...p_end]
|
309
|
+
ast_node = string(utf8_string(chars), complete: false)
|
310
|
+
yield ast_node
|
238
311
|
end
|
239
312
|
begin
|
240
313
|
|
241
|
-
|
314
|
+
trace('STRING string_node_eof')
|
242
315
|
yield @buffers[:string]
|
243
316
|
end
|
244
317
|
end
|
@@ -251,7 +324,7 @@ begin
|
|
251
324
|
end
|
252
325
|
end
|
253
326
|
|
254
|
-
# end: ragel
|
327
|
+
# end: ragel
|
255
328
|
end
|
256
329
|
end
|
257
330
|
end
|
@@ -5,45 +5,102 @@
|
|
5
5
|
|
6
6
|
include 'common.rl';
|
7
7
|
|
8
|
-
action
|
9
|
-
|
8
|
+
action string_end {
|
9
|
+
trace('STRING string_end')
|
10
|
+
completed = @string_opened && @string_closed
|
11
|
+
chars = data[p_start...p_end]
|
12
|
+
ast_node = string(utf8_string(chars), complete: true)
|
13
|
+
@buffers[:string] = ast_node
|
10
14
|
}
|
11
15
|
|
12
|
-
action
|
13
|
-
(
|
16
|
+
action yield_string {
|
17
|
+
trace('STRING yield_string')
|
18
|
+
yield @buffers[:string]
|
14
19
|
}
|
15
20
|
|
16
|
-
action
|
17
|
-
|
21
|
+
action start_string {
|
22
|
+
trace('STRING start_string')
|
23
|
+
@string_opened = true
|
24
|
+
p_start = p
|
18
25
|
}
|
19
26
|
|
20
|
-
action
|
21
|
-
|
22
|
-
@
|
27
|
+
action stop_string {
|
28
|
+
trace('STRING stop_string')
|
29
|
+
@string_closed = true
|
30
|
+
p_end = p
|
23
31
|
}
|
24
32
|
|
25
|
-
action
|
26
|
-
|
33
|
+
action eof_string {
|
34
|
+
trace('STRING eof_string')
|
35
|
+
p_end = p
|
36
|
+
chars = data[p_start...p_end]
|
37
|
+
ast_node = string(utf8_string(chars), complete: false)
|
38
|
+
@buffers[:string] = ast_node
|
27
39
|
}
|
28
40
|
|
29
|
-
action
|
30
|
-
|
41
|
+
action string_node_eof {
|
42
|
+
trace('STRING string_node_eof')
|
31
43
|
yield @buffers[:string]
|
32
44
|
}
|
33
45
|
|
34
|
-
|
35
|
-
('
|
46
|
+
action a_string_err {
|
47
|
+
trace('STRING a_string_err')
|
48
|
+
p_end = p
|
49
|
+
chars = data[p_start...p_end]
|
50
|
+
ast_node = string(utf8_string(chars), complete: false)
|
51
|
+
@buffers[:string] = ast_node
|
52
|
+
}
|
53
|
+
|
54
|
+
action string_node_err {
|
55
|
+
trace('STRING string_node_err')
|
56
|
+
p_end = p
|
57
|
+
chars = data[p_start...p_end]
|
58
|
+
ast_node = string(utf8_string(chars), complete: false)
|
59
|
+
yield ast_node
|
60
|
+
}
|
36
61
|
|
37
|
-
|
38
|
-
|
39
|
-
|
62
|
+
#single =
|
63
|
+
# WS* SQ (NOT_SQESC | ESCAPED)*
|
64
|
+
# >start_string
|
65
|
+
# $eof(eof_string)
|
66
|
+
# %stop_string
|
67
|
+
# %string_end
|
68
|
+
# SQ
|
69
|
+
# ;
|
70
|
+
|
71
|
+
double =
|
72
|
+
WS* DQ (NOT_DQESC | ESCAPED)*
|
73
|
+
>start_string
|
74
|
+
$eof(eof_string)
|
75
|
+
%stop_string
|
76
|
+
%string_end
|
77
|
+
DQ
|
78
|
+
;
|
79
|
+
|
80
|
+
a_string =
|
81
|
+
#(single | double)
|
82
|
+
double
|
83
|
+
$err(a_string_err)
|
84
|
+
;
|
85
|
+
|
86
|
+
string_node :=
|
87
|
+
(
|
88
|
+
#single |
|
89
|
+
double
|
90
|
+
)
|
91
|
+
$err(string_node_err)
|
92
|
+
@eof(string_node_eof)
|
93
|
+
@yield_string
|
94
|
+
;
|
40
95
|
}%%
|
41
96
|
=end
|
42
97
|
# end: ragel
|
98
|
+
# ('\"' | ^(0 .. 31 | 34))* ^'\\"'
|
43
99
|
|
44
100
|
require_relative '../ast/node'
|
45
101
|
require_relative '../mixin/buffer'
|
46
102
|
require_relative '../nonblocking_io_wrapper'
|
103
|
+
require_relative '../tracer'
|
47
104
|
|
48
105
|
module BELParser
|
49
106
|
module Parsers
|
@@ -69,25 +126,31 @@ module BELParser
|
|
69
126
|
include Enumerable
|
70
127
|
include BELParser::Parsers::Buffer
|
71
128
|
include BELParser::Parsers::AST::Sexp
|
129
|
+
include BELParser::Parsers::Tracer
|
72
130
|
|
73
131
|
def initialize(content)
|
74
132
|
@content = content
|
75
|
-
# begin: ragel
|
133
|
+
# begin: ragel
|
76
134
|
%% write data;
|
77
|
-
# end: ragel
|
135
|
+
# end: ragel
|
78
136
|
end
|
79
137
|
|
80
138
|
def each
|
81
|
-
@buffers
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
139
|
+
@buffers = {}
|
140
|
+
@incomplete = {}
|
141
|
+
@string_opened = false
|
142
|
+
@string_closed = false
|
143
|
+
data = @content.unpack('C*')
|
144
|
+
p_start = 0
|
145
|
+
p_end = 0
|
146
|
+
p = 0
|
147
|
+
pe = data.length
|
148
|
+
eof = data.length
|
149
|
+
|
150
|
+
# begin: ragel
|
88
151
|
%% write init;
|
89
152
|
%% write exec;
|
90
|
-
# end: ragel
|
153
|
+
# end: ragel
|
91
154
|
end
|
92
155
|
end
|
93
156
|
end
|