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
@@ -0,0 +1,319 @@
|
|
1
|
+
|
2
|
+
# begin: ragel
|
3
|
+
=begin
|
4
|
+
|
5
|
+
|
6
|
+
=end
|
7
|
+
# end: ragel
|
8
|
+
|
9
|
+
require_relative '../ast/node'
|
10
|
+
require_relative '../mixin/buffer'
|
11
|
+
require_relative '../nonblocking_io_wrapper'
|
12
|
+
require_relative '../tracer'
|
13
|
+
|
14
|
+
module BELParser
|
15
|
+
module Parsers
|
16
|
+
module Common
|
17
|
+
module Function
|
18
|
+
|
19
|
+
class << self
|
20
|
+
|
21
|
+
MAX_LENGTH = 1024 * 128 # 128K
|
22
|
+
|
23
|
+
def parse(content)
|
24
|
+
return nil unless content
|
25
|
+
|
26
|
+
Parser.new(content).each do |obj|
|
27
|
+
yield obj
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
class Parser
|
35
|
+
include Enumerable
|
36
|
+
include BELParser::Parsers::Buffer
|
37
|
+
include BELParser::Parsers::AST::Sexp
|
38
|
+
include BELParser::Parsers::Tracer
|
39
|
+
|
40
|
+
def initialize(content)
|
41
|
+
@content = content
|
42
|
+
# begin: ragel
|
43
|
+
|
44
|
+
class << self
|
45
|
+
attr_accessor :_bel_trans_keys
|
46
|
+
private :_bel_trans_keys, :_bel_trans_keys=
|
47
|
+
end
|
48
|
+
self._bel_trans_keys = [
|
49
|
+
0, 0, 33, 126, 10, 126,
|
50
|
+
0, 0, 0
|
51
|
+
]
|
52
|
+
|
53
|
+
class << self
|
54
|
+
attr_accessor :_bel_key_spans
|
55
|
+
private :_bel_key_spans, :_bel_key_spans=
|
56
|
+
end
|
57
|
+
self._bel_key_spans = [
|
58
|
+
0, 94, 117, 0
|
59
|
+
]
|
60
|
+
|
61
|
+
class << self
|
62
|
+
attr_accessor :_bel_index_offsets
|
63
|
+
private :_bel_index_offsets, :_bel_index_offsets=
|
64
|
+
end
|
65
|
+
self._bel_index_offsets = [
|
66
|
+
0, 0, 95, 213
|
67
|
+
]
|
68
|
+
|
69
|
+
class << self
|
70
|
+
attr_accessor :_bel_indicies
|
71
|
+
private :_bel_indicies, :_bel_indicies=
|
72
|
+
end
|
73
|
+
self._bel_indicies = [
|
74
|
+
1, 0, 1, 1, 1, 1, 0, 0,
|
75
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
76
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
77
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
78
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
79
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
80
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
81
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
82
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
83
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
84
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
85
|
+
1, 1, 1, 1, 1, 1, 0, 2,
|
86
|
+
0, 0, 0, 0, 0, 0, 0, 0,
|
87
|
+
0, 0, 0, 0, 0, 0, 0, 0,
|
88
|
+
0, 0, 0, 0, 0, 0, 3, 0,
|
89
|
+
3, 3, 3, 3, 0, 0, 3, 3,
|
90
|
+
3, 3, 3, 3, 3, 3, 3, 3,
|
91
|
+
3, 3, 3, 3, 3, 3, 3, 3,
|
92
|
+
3, 3, 3, 3, 3, 3, 3, 3,
|
93
|
+
3, 3, 3, 3, 3, 3, 3, 3,
|
94
|
+
3, 3, 3, 3, 3, 3, 3, 3,
|
95
|
+
3, 3, 3, 3, 3, 3, 3, 3,
|
96
|
+
3, 3, 3, 3, 3, 3, 3, 3,
|
97
|
+
3, 3, 3, 3, 3, 3, 3, 3,
|
98
|
+
3, 3, 3, 3, 3, 3, 3, 3,
|
99
|
+
3, 3, 3, 3, 3, 3, 3, 3,
|
100
|
+
3, 3, 3, 3, 0, 4, 0
|
101
|
+
]
|
102
|
+
|
103
|
+
class << self
|
104
|
+
attr_accessor :_bel_trans_targs
|
105
|
+
private :_bel_trans_targs, :_bel_trans_targs=
|
106
|
+
end
|
107
|
+
self._bel_trans_targs = [
|
108
|
+
0, 2, 3, 2, 0
|
109
|
+
]
|
110
|
+
|
111
|
+
class << self
|
112
|
+
attr_accessor :_bel_trans_actions
|
113
|
+
private :_bel_trans_actions, :_bel_trans_actions=
|
114
|
+
end
|
115
|
+
self._bel_trans_actions = [
|
116
|
+
1, 2, 4, 0, 0
|
117
|
+
]
|
118
|
+
|
119
|
+
class << self
|
120
|
+
attr_accessor :_bel_eof_actions
|
121
|
+
private :_bel_eof_actions, :_bel_eof_actions=
|
122
|
+
end
|
123
|
+
self._bel_eof_actions = [
|
124
|
+
0, 1, 3, 5
|
125
|
+
]
|
126
|
+
|
127
|
+
class << self
|
128
|
+
attr_accessor :bel_start
|
129
|
+
end
|
130
|
+
self.bel_start = 1;
|
131
|
+
class << self
|
132
|
+
attr_accessor :bel_first_final
|
133
|
+
end
|
134
|
+
self.bel_first_final = 2;
|
135
|
+
class << self
|
136
|
+
attr_accessor :bel_error
|
137
|
+
end
|
138
|
+
self.bel_error = 0;
|
139
|
+
|
140
|
+
class << self
|
141
|
+
attr_accessor :bel_en_function_node
|
142
|
+
end
|
143
|
+
self.bel_en_function_node = 1;
|
144
|
+
|
145
|
+
|
146
|
+
# end: ragel
|
147
|
+
end
|
148
|
+
|
149
|
+
def each
|
150
|
+
@buffers = {}
|
151
|
+
@incomplete = {}
|
152
|
+
data = @content.unpack('C*')
|
153
|
+
p = 0
|
154
|
+
p_start = 0
|
155
|
+
p_end = 0
|
156
|
+
pe = data.length
|
157
|
+
eof = data.length
|
158
|
+
@function_started = false
|
159
|
+
|
160
|
+
# begin: ragel
|
161
|
+
|
162
|
+
begin
|
163
|
+
p ||= 0
|
164
|
+
pe ||= data.length
|
165
|
+
cs = bel_start
|
166
|
+
end
|
167
|
+
|
168
|
+
|
169
|
+
begin
|
170
|
+
testEof = false
|
171
|
+
_slen, _trans, _keys, _inds, _acts, _nacts = nil
|
172
|
+
_goto_level = 0
|
173
|
+
_resume = 10
|
174
|
+
_eof_trans = 15
|
175
|
+
_again = 20
|
176
|
+
_test_eof = 30
|
177
|
+
_out = 40
|
178
|
+
while true
|
179
|
+
if _goto_level <= 0
|
180
|
+
if p == pe
|
181
|
+
_goto_level = _test_eof
|
182
|
+
next
|
183
|
+
end
|
184
|
+
if cs == 0
|
185
|
+
_goto_level = _out
|
186
|
+
next
|
187
|
+
end
|
188
|
+
end
|
189
|
+
if _goto_level <= _resume
|
190
|
+
_keys = cs << 1
|
191
|
+
_inds = _bel_index_offsets[cs]
|
192
|
+
_slen = _bel_key_spans[cs]
|
193
|
+
_wide = data[p].ord
|
194
|
+
_trans = if ( _slen > 0 &&
|
195
|
+
_bel_trans_keys[_keys] <= _wide &&
|
196
|
+
_wide <= _bel_trans_keys[_keys + 1]
|
197
|
+
) then
|
198
|
+
_bel_indicies[ _inds + _wide - _bel_trans_keys[_keys] ]
|
199
|
+
else
|
200
|
+
_bel_indicies[ _inds + _slen ]
|
201
|
+
end
|
202
|
+
cs = _bel_trans_targs[_trans]
|
203
|
+
if _bel_trans_actions[_trans] != 0
|
204
|
+
case _bel_trans_actions[_trans]
|
205
|
+
when 2 then
|
206
|
+
begin
|
207
|
+
|
208
|
+
trace('FUNCTION start_function')
|
209
|
+
@function_started = true
|
210
|
+
p_start = p;
|
211
|
+
end
|
212
|
+
when 4 then
|
213
|
+
begin
|
214
|
+
|
215
|
+
trace('FUNCTION end_function')
|
216
|
+
p_end = p
|
217
|
+
chars = data[p_start...p_end]
|
218
|
+
completed = !chars.empty?
|
219
|
+
ident_node = identifier(utf8_string(chars), complete: completed)
|
220
|
+
fx_node = function(ident_node, complete: ident_node.complete)
|
221
|
+
@buffers[:function] = fx_node
|
222
|
+
end
|
223
|
+
when 1 then
|
224
|
+
begin
|
225
|
+
|
226
|
+
trace('FUNCTION function_node_err')
|
227
|
+
if @function_started
|
228
|
+
# hit invalid char, include it in the identifier that results
|
229
|
+
p_end = p + 1
|
230
|
+
chars = data[p_start...p_end]
|
231
|
+
completed = !chars.empty?
|
232
|
+
ident_node = identifier(utf8_string(chars), complete: completed)
|
233
|
+
fx_node = function(ident_node, complete: false)
|
234
|
+
@buffers[:function] = fx_node
|
235
|
+
yield @buffers[:function]
|
236
|
+
end
|
237
|
+
end
|
238
|
+
end
|
239
|
+
end
|
240
|
+
end
|
241
|
+
if _goto_level <= _again
|
242
|
+
if cs == 0
|
243
|
+
_goto_level = _out
|
244
|
+
next
|
245
|
+
end
|
246
|
+
p += 1
|
247
|
+
if p != pe
|
248
|
+
_goto_level = _resume
|
249
|
+
next
|
250
|
+
end
|
251
|
+
end
|
252
|
+
if _goto_level <= _test_eof
|
253
|
+
if p == eof
|
254
|
+
case _bel_eof_actions[cs]
|
255
|
+
when 1 then
|
256
|
+
begin
|
257
|
+
|
258
|
+
trace('FUNCTION function_node_err')
|
259
|
+
if @function_started
|
260
|
+
# hit invalid char, include it in the identifier that results
|
261
|
+
p_end = p + 1
|
262
|
+
chars = data[p_start...p_end]
|
263
|
+
completed = !chars.empty?
|
264
|
+
ident_node = identifier(utf8_string(chars), complete: completed)
|
265
|
+
fx_node = function(ident_node, complete: false)
|
266
|
+
@buffers[:function] = fx_node
|
267
|
+
yield @buffers[:function]
|
268
|
+
end
|
269
|
+
end
|
270
|
+
when 5 then
|
271
|
+
begin
|
272
|
+
|
273
|
+
trace('FUNCTION yield_function')
|
274
|
+
yield @buffers[:function]
|
275
|
+
end
|
276
|
+
when 3 then
|
277
|
+
begin
|
278
|
+
|
279
|
+
trace('FUNCTION end_function')
|
280
|
+
p_end = p
|
281
|
+
chars = data[p_start...p_end]
|
282
|
+
completed = !chars.empty?
|
283
|
+
ident_node = identifier(utf8_string(chars), complete: completed)
|
284
|
+
fx_node = function(ident_node, complete: ident_node.complete)
|
285
|
+
@buffers[:function] = fx_node
|
286
|
+
end
|
287
|
+
begin
|
288
|
+
|
289
|
+
trace('FUNCTION yield_function')
|
290
|
+
yield @buffers[:function]
|
291
|
+
end
|
292
|
+
end
|
293
|
+
end
|
294
|
+
|
295
|
+
end
|
296
|
+
if _goto_level <= _out
|
297
|
+
break
|
298
|
+
end
|
299
|
+
end
|
300
|
+
end
|
301
|
+
|
302
|
+
# end: ragel
|
303
|
+
end
|
304
|
+
end
|
305
|
+
end
|
306
|
+
end
|
307
|
+
end
|
308
|
+
end
|
309
|
+
|
310
|
+
if __FILE__ == $0
|
311
|
+
$stdin.each_line do |line|
|
312
|
+
BELParser::Parsers::Common::Function.parse(line) { |obj|
|
313
|
+
puts obj.inspect
|
314
|
+
}
|
315
|
+
end
|
316
|
+
end
|
317
|
+
|
318
|
+
# vim: ft=ruby ts=2 sw=2:
|
319
|
+
# encoding: utf-8
|
@@ -0,0 +1,149 @@
|
|
1
|
+
# begin: ragel
|
2
|
+
=begin
|
3
|
+
%%{
|
4
|
+
machine bel;
|
5
|
+
|
6
|
+
include 'common.rl';
|
7
|
+
|
8
|
+
action start_function {
|
9
|
+
trace('FUNCTION start_function')
|
10
|
+
@function_started = true
|
11
|
+
p_start = p;
|
12
|
+
}
|
13
|
+
|
14
|
+
action end_function {
|
15
|
+
trace('FUNCTION end_function')
|
16
|
+
p_end = p
|
17
|
+
chars = data[p_start...p_end]
|
18
|
+
completed = !chars.empty?
|
19
|
+
ident_node = identifier(utf8_string(chars), complete: completed)
|
20
|
+
fx_node = function(ident_node, complete: ident_node.complete)
|
21
|
+
@buffers[:function] = fx_node
|
22
|
+
}
|
23
|
+
|
24
|
+
action a_function_eof {
|
25
|
+
trace('FUNCTION a_function_eof')
|
26
|
+
if @function_started
|
27
|
+
p_end = p
|
28
|
+
chars = data[p_start...p_end]
|
29
|
+
completed = !chars.empty?
|
30
|
+
ident_node = identifier(utf8_string(chars), complete: completed)
|
31
|
+
fx_node = function(ident_node, complete: ident_node.complete)
|
32
|
+
@buffers[:function] = fx_node
|
33
|
+
end
|
34
|
+
}
|
35
|
+
|
36
|
+
action function_node_err {
|
37
|
+
trace('FUNCTION function_node_err')
|
38
|
+
if @function_started
|
39
|
+
# hit invalid char, include it in the identifier that results
|
40
|
+
p_end = p + 1
|
41
|
+
chars = data[p_start...p_end]
|
42
|
+
completed = !chars.empty?
|
43
|
+
ident_node = identifier(utf8_string(chars), complete: completed)
|
44
|
+
fx_node = function(ident_node, complete: false)
|
45
|
+
@buffers[:function] = fx_node
|
46
|
+
yield @buffers[:function]
|
47
|
+
end
|
48
|
+
}
|
49
|
+
|
50
|
+
action yield_function {
|
51
|
+
trace('FUNCTION yield_function')
|
52
|
+
yield @buffers[:function]
|
53
|
+
}
|
54
|
+
|
55
|
+
function =
|
56
|
+
FUNCTION
|
57
|
+
>start_function
|
58
|
+
%end_function
|
59
|
+
;
|
60
|
+
|
61
|
+
maybe_function =
|
62
|
+
function?
|
63
|
+
;
|
64
|
+
|
65
|
+
a_function =
|
66
|
+
function
|
67
|
+
$eof(a_function_eof)
|
68
|
+
;
|
69
|
+
|
70
|
+
function_node :=
|
71
|
+
function
|
72
|
+
$err(function_node_err)
|
73
|
+
NL?
|
74
|
+
%yield_function
|
75
|
+
;
|
76
|
+
}%%
|
77
|
+
=end
|
78
|
+
# end: ragel
|
79
|
+
|
80
|
+
require_relative '../ast/node'
|
81
|
+
require_relative '../mixin/buffer'
|
82
|
+
require_relative '../nonblocking_io_wrapper'
|
83
|
+
require_relative '../tracer'
|
84
|
+
|
85
|
+
module BELParser
|
86
|
+
module Parsers
|
87
|
+
module Common
|
88
|
+
module Function
|
89
|
+
|
90
|
+
class << self
|
91
|
+
|
92
|
+
MAX_LENGTH = 1024 * 128 # 128K
|
93
|
+
|
94
|
+
def parse(content)
|
95
|
+
return nil unless content
|
96
|
+
|
97
|
+
Parser.new(content).each do |obj|
|
98
|
+
yield obj
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
private
|
104
|
+
|
105
|
+
class Parser
|
106
|
+
include Enumerable
|
107
|
+
include BELParser::Parsers::Buffer
|
108
|
+
include BELParser::Parsers::AST::Sexp
|
109
|
+
include BELParser::Parsers::Tracer
|
110
|
+
|
111
|
+
def initialize(content)
|
112
|
+
@content = content
|
113
|
+
# begin: ragel
|
114
|
+
%% write data;
|
115
|
+
# end: ragel
|
116
|
+
end
|
117
|
+
|
118
|
+
def each
|
119
|
+
@buffers = {}
|
120
|
+
@incomplete = {}
|
121
|
+
data = @content.unpack('C*')
|
122
|
+
p = 0
|
123
|
+
p_start = 0
|
124
|
+
p_end = 0
|
125
|
+
pe = data.length
|
126
|
+
eof = data.length
|
127
|
+
@function_started = false
|
128
|
+
|
129
|
+
# begin: ragel
|
130
|
+
%% write init;
|
131
|
+
%% write exec;
|
132
|
+
# end: ragel
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
if __FILE__ == $0
|
141
|
+
$stdin.each_line do |line|
|
142
|
+
BELParser::Parsers::Common::Function.parse(line) { |obj|
|
143
|
+
puts obj.inspect
|
144
|
+
}
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
# vim: ft=ruby ts=2 sw=2:
|
149
|
+
# encoding: utf-8
|
@@ -9,6 +9,7 @@
|
|
9
9
|
require_relative '../ast/node'
|
10
10
|
require_relative '../mixin/buffer'
|
11
11
|
require_relative '../nonblocking_io_wrapper'
|
12
|
+
require_relative '../tracer'
|
12
13
|
|
13
14
|
module BELParser
|
14
15
|
module Parsers
|
@@ -34,10 +35,11 @@ module BELParser
|
|
34
35
|
include Enumerable
|
35
36
|
include BELParser::Parsers::Buffer
|
36
37
|
include BELParser::Parsers::AST::Sexp
|
38
|
+
include BELParser::Parsers::Tracer
|
37
39
|
|
38
40
|
def initialize(content)
|
39
41
|
@content = content
|
40
|
-
# begin: ragel
|
42
|
+
# begin: ragel
|
41
43
|
|
42
44
|
class << self
|
43
45
|
attr_accessor :_bel_trans_keys
|
@@ -69,30 +71,30 @@ class << self
|
|
69
71
|
private :_bel_indicies, :_bel_indicies=
|
70
72
|
end
|
71
73
|
self._bel_indicies = [
|
72
|
-
1, 1, 1, 1, 1, 1, 1, 1,
|
73
|
-
1, 1, 0, 0, 0, 0, 0, 0,
|
74
|
-
0, 1, 1, 1, 1, 1, 1, 1,
|
75
|
-
1, 1, 1, 1, 1, 1, 1, 1,
|
76
|
-
1, 1, 1, 1, 1, 1, 1, 1,
|
77
|
-
1, 1, 1, 0, 0, 0, 0, 1,
|
78
|
-
0, 1, 1, 1, 1, 1, 1, 1,
|
79
|
-
1, 1, 1, 1, 1, 1, 1, 1,
|
80
|
-
1, 1, 1, 1, 1, 1, 1, 1,
|
81
|
-
1, 1, 1, 0, 2, 0, 0, 0,
|
82
74
|
0, 0, 0, 0, 0, 0, 0, 0,
|
75
|
+
0, 0, 1, 1, 1, 1, 1, 1,
|
76
|
+
1, 0, 0, 0, 0, 0, 0, 0,
|
83
77
|
0, 0, 0, 0, 0, 0, 0, 0,
|
84
78
|
0, 0, 0, 0, 0, 0, 0, 0,
|
79
|
+
0, 0, 0, 1, 1, 1, 1, 0,
|
80
|
+
1, 0, 0, 0, 0, 0, 0, 0,
|
85
81
|
0, 0, 0, 0, 0, 0, 0, 0,
|
86
|
-
0, 0,
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
82
|
+
0, 0, 0, 0, 0, 0, 0, 0,
|
83
|
+
0, 0, 0, 1, 3, 2, 2, 2,
|
84
|
+
2, 2, 2, 2, 2, 2, 2, 2,
|
85
|
+
2, 2, 2, 2, 2, 2, 2, 2,
|
86
|
+
2, 2, 2, 2, 2, 2, 2, 2,
|
87
|
+
2, 2, 2, 2, 2, 2, 2, 2,
|
88
|
+
2, 2, 4, 4, 4, 4, 4, 4,
|
89
|
+
4, 4, 4, 4, 2, 2, 2, 2,
|
90
|
+
2, 2, 2, 4, 4, 4, 4, 4,
|
91
|
+
4, 4, 4, 4, 4, 4, 4, 4,
|
92
|
+
4, 4, 4, 4, 4, 4, 4, 4,
|
93
|
+
4, 4, 4, 4, 4, 2, 2, 2,
|
94
|
+
2, 4, 2, 4, 4, 4, 4, 4,
|
95
|
+
4, 4, 4, 4, 4, 4, 4, 4,
|
96
|
+
4, 4, 4, 4, 4, 4, 4, 4,
|
97
|
+
4, 4, 4, 4, 4, 2, 2, 0
|
96
98
|
]
|
97
99
|
|
98
100
|
class << self
|
@@ -100,7 +102,7 @@ class << self
|
|
100
102
|
private :_bel_trans_targs, :_bel_trans_targs=
|
101
103
|
end
|
102
104
|
self._bel_trans_targs = [
|
103
|
-
0,
|
105
|
+
2, 0, 0, 3, 2
|
104
106
|
]
|
105
107
|
|
106
108
|
class << self
|
@@ -108,7 +110,7 @@ class << self
|
|
108
110
|
private :_bel_trans_actions, :_bel_trans_actions=
|
109
111
|
end
|
110
112
|
self._bel_trans_actions = [
|
111
|
-
1,
|
113
|
+
1, 0, 3, 4, 0
|
112
114
|
]
|
113
115
|
|
114
116
|
class << self
|
@@ -116,7 +118,7 @@ class << self
|
|
116
118
|
private :_bel_eof_actions, :_bel_eof_actions=
|
117
119
|
end
|
118
120
|
self._bel_eof_actions = [
|
119
|
-
0,
|
121
|
+
0, 0, 2, 5
|
120
122
|
]
|
121
123
|
|
122
124
|
class << self
|
@@ -126,29 +128,33 @@ self.bel_start = 1;
|
|
126
128
|
class << self
|
127
129
|
attr_accessor :bel_first_final
|
128
130
|
end
|
129
|
-
self.bel_first_final =
|
131
|
+
self.bel_first_final = 2;
|
130
132
|
class << self
|
131
133
|
attr_accessor :bel_error
|
132
134
|
end
|
133
135
|
self.bel_error = 0;
|
134
136
|
|
135
137
|
class << self
|
136
|
-
attr_accessor :
|
138
|
+
attr_accessor :bel_en_ident_node
|
137
139
|
end
|
138
|
-
self.
|
140
|
+
self.bel_en_ident_node = 1;
|
139
141
|
|
140
142
|
|
141
|
-
# end: ragel
|
143
|
+
# end: ragel
|
142
144
|
end
|
143
145
|
|
144
146
|
def each
|
145
|
-
@buffers
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
147
|
+
@buffers = {}
|
148
|
+
@incomplete = {}
|
149
|
+
data = @content.unpack('C*')
|
150
|
+
p = 0
|
151
|
+
id_start = 0
|
152
|
+
id_end = 0
|
153
|
+
pe = data.length
|
154
|
+
eof = data.length
|
155
|
+
|
156
|
+
identifier_started = false
|
157
|
+
# begin: ragel
|
152
158
|
|
153
159
|
begin
|
154
160
|
p ||= 0
|
@@ -193,41 +199,31 @@ begin
|
|
193
199
|
cs = _bel_trans_targs[_trans]
|
194
200
|
if _bel_trans_actions[_trans] != 0
|
195
201
|
case _bel_trans_actions[_trans]
|
196
|
-
when
|
197
|
-
begin
|
198
|
-
|
199
|
-
(@buffers[:ident] ||= []) << data[p].ord
|
200
|
-
end
|
201
|
-
when 2 then
|
202
|
+
when 1 then
|
202
203
|
begin
|
203
204
|
|
204
|
-
|
205
|
+
trace('IDENTIFIER start_identifier')
|
206
|
+
@identifier_started = true
|
207
|
+
id_start = p;
|
205
208
|
end
|
209
|
+
when 4 then
|
206
210
|
begin
|
207
211
|
|
208
|
-
(
|
212
|
+
trace('IDENTIFIER end_identifier')
|
213
|
+
id_end = p
|
214
|
+
chars = data[id_start...id_end]
|
215
|
+
completed = !chars.empty?
|
216
|
+
ast_node = identifier(utf8_string(chars), complete: completed)
|
217
|
+
@buffers[:ident] = ast_node
|
209
218
|
end
|
210
219
|
when 3 then
|
211
220
|
begin
|
212
221
|
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
yield
|
218
|
-
end
|
219
|
-
when 1 then
|
220
|
-
begin
|
221
|
-
|
222
|
-
unless @buffers[:ident].is_a?(::AST::Node)
|
223
|
-
@buffers[:ident] ||= []
|
224
|
-
@buffers[:ident] = identifier(utf8_string(@buffers[:ident]).sub(/\n$/, ''))
|
225
|
-
end
|
226
|
-
end
|
227
|
-
begin
|
228
|
-
|
229
|
-
@buffers[:ident] ||= []
|
230
|
-
yield @buffers[:ident]
|
222
|
+
trace('IDENTIFIER ident_node_err')
|
223
|
+
id_end = p
|
224
|
+
chars = data[id_start...id_end]
|
225
|
+
ast_node = identifier(utf8_string(chars), complete: false)
|
226
|
+
yield ast_node
|
231
227
|
end
|
232
228
|
end
|
233
229
|
end
|
@@ -246,17 +242,25 @@ begin
|
|
246
242
|
if _goto_level <= _test_eof
|
247
243
|
if p == eof
|
248
244
|
case _bel_eof_actions[cs]
|
249
|
-
when
|
245
|
+
when 5 then
|
250
246
|
begin
|
251
247
|
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
248
|
+
trace('IDENTIFIER yield_identifier')
|
249
|
+
yield @buffers[:ident]
|
250
|
+
end
|
251
|
+
when 2 then
|
252
|
+
begin
|
253
|
+
|
254
|
+
trace('IDENTIFIER end_identifier')
|
255
|
+
id_end = p
|
256
|
+
chars = data[id_start...id_end]
|
257
|
+
completed = !chars.empty?
|
258
|
+
ast_node = identifier(utf8_string(chars), complete: completed)
|
259
|
+
@buffers[:ident] = ast_node
|
256
260
|
end
|
257
261
|
begin
|
258
262
|
|
259
|
-
|
263
|
+
trace('IDENTIFIER yield_identifier')
|
260
264
|
yield @buffers[:ident]
|
261
265
|
end
|
262
266
|
end
|
@@ -269,7 +273,7 @@ begin
|
|
269
273
|
end
|
270
274
|
end
|
271
275
|
|
272
|
-
# end: ragel
|
276
|
+
# end: ragel
|
273
277
|
end
|
274
278
|
end
|
275
279
|
end
|