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.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/lib/bel_parser/ast_filter.rb +6 -2
  4. data/lib/bel_parser/parsers/ast/node.rb +113 -58
  5. data/lib/bel_parser/parsers/bel_script/define_annotation.rb +4175 -3097
  6. data/lib/bel_parser/parsers/bel_script/define_annotation.rl +142 -49
  7. data/lib/bel_parser/parsers/bel_script/define_namespace.rb +980 -461
  8. data/lib/bel_parser/parsers/bel_script/define_namespace.rl +79 -39
  9. data/lib/bel_parser/parsers/bel_script/set.rb +4878 -2743
  10. data/lib/bel_parser/parsers/bel_script/set.rl +114 -32
  11. data/lib/bel_parser/parsers/bel_script/set_document.rb +5839 -5292
  12. data/lib/bel_parser/parsers/bel_script/set_document.rl +130 -27
  13. data/lib/bel_parser/parsers/bel_script/unset.rb +321 -234
  14. data/lib/bel_parser/parsers/bel_script/unset.rl +49 -21
  15. data/lib/bel_parser/parsers/common/blank_line.rb +12 -11
  16. data/lib/bel_parser/parsers/common/blank_line.rl +12 -12
  17. data/lib/bel_parser/parsers/common/comment_line.rb +65 -40
  18. data/lib/bel_parser/parsers/common/comment_line.rl +26 -26
  19. data/lib/bel_parser/parsers/common/common.rl +60 -0
  20. data/lib/bel_parser/parsers/common/function.rb +319 -0
  21. data/lib/bel_parser/parsers/common/function.rl +149 -0
  22. data/lib/bel_parser/parsers/common/identifier.rb +72 -68
  23. data/lib/bel_parser/parsers/common/identifier.rl +73 -29
  24. data/lib/bel_parser/parsers/common/list.rb +1617 -1243
  25. data/lib/bel_parser/parsers/common/list.rl +120 -60
  26. data/lib/bel_parser/parsers/common/string.rb +114 -41
  27. data/lib/bel_parser/parsers/common/string.rl +91 -28
  28. data/lib/bel_parser/parsers/common.rb +1 -0
  29. data/lib/bel_parser/parsers/expression/comment.rb +70 -38
  30. data/lib/bel_parser/parsers/expression/comment.rl +37 -20
  31. data/lib/bel_parser/parsers/expression/nested_statement.rb +63116 -13958
  32. data/lib/bel_parser/parsers/expression/nested_statement.rl +53 -23
  33. data/lib/bel_parser/parsers/expression/observed_term.rb +32497 -5188
  34. data/lib/bel_parser/parsers/expression/observed_term.rl +25 -20
  35. data/lib/bel_parser/parsers/expression/parameter.rb +2861 -847
  36. data/lib/bel_parser/parsers/expression/parameter.rl +178 -21
  37. data/lib/bel_parser/parsers/expression/relationship.rb +73 -55
  38. data/lib/bel_parser/parsers/expression/relationship.rl +41 -23
  39. data/lib/bel_parser/parsers/expression/simple_statement.rb +42895 -7846
  40. data/lib/bel_parser/parsers/expression/simple_statement.rl +41 -24
  41. data/lib/bel_parser/parsers/expression/term.rb +16498 -2602
  42. data/lib/bel_parser/parsers/expression/term.rl +52 -35
  43. data/lib/bel_parser/parsers/line_parser.rb +1 -0
  44. data/lib/bel_parser/parsers/mixin/buffer.rb +4 -0
  45. data/lib/bel_parser/parsers/tracer.rb +19 -0
  46. data/lib/bel_parser/script/state/namespace_definition.rb +1 -0
  47. metadata +10 -7
@@ -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,17 +35,18 @@ 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
44
46
  private :_bel_trans_keys, :_bel_trans_keys=
45
47
  end
46
48
  self._bel_trans_keys = [
47
- 0, 0, 10, 47, 47, 47,
49
+ 0, 0, 47, 47, 47, 47,
48
50
  10, 10, 10, 10, 0,
49
51
  0, 0
50
52
  ]
@@ -54,7 +56,7 @@ class << self
54
56
  private :_bel_key_spans, :_bel_key_spans=
55
57
  end
56
58
  self._bel_key_spans = [
57
- 0, 38, 1, 1, 1, 0
59
+ 0, 1, 1, 1, 1, 0
58
60
  ]
59
61
 
60
62
  class << self
@@ -62,7 +64,7 @@ class << self
62
64
  private :_bel_index_offsets, :_bel_index_offsets=
63
65
  end
64
66
  self._bel_index_offsets = [
65
- 0, 0, 39, 41, 43, 45
67
+ 0, 0, 2, 4, 6, 8
66
68
  ]
67
69
 
68
70
  class << self
@@ -70,12 +72,8 @@ class << self
70
72
  private :_bel_indicies, :_bel_indicies=
71
73
  end
72
74
  self._bel_indicies = [
73
- 0, 1, 1, 1, 1, 1, 1, 1,
74
- 1, 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, 1, 1, 2, 1, 3,
78
- 1, 1, 4, 6, 5, 1, 0
75
+ 0, 1, 2, 1, 1, 3, 5, 4,
76
+ 1, 0
79
77
  ]
80
78
 
81
79
  class << self
@@ -83,7 +81,7 @@ class << self
83
81
  private :_bel_trans_targs, :_bel_trans_targs=
84
82
  end
85
83
  self._bel_trans_targs = [
86
- 5, 0, 2, 3, 4, 4, 5
84
+ 2, 0, 3, 4, 4, 5
87
85
  ]
88
86
 
89
87
  class << self
@@ -91,7 +89,15 @@ class << self
91
89
  private :_bel_trans_actions, :_bel_trans_actions=
92
90
  end
93
91
  self._bel_trans_actions = [
94
- 1, 0, 0, 0, 2, 3, 4
92
+ 0, 0, 0, 1, 0, 2
93
+ ]
94
+
95
+ class << self
96
+ attr_accessor :_bel_eof_actions
97
+ private :_bel_eof_actions, :_bel_eof_actions=
98
+ end
99
+ self._bel_eof_actions = [
100
+ 0, 0, 0, 0, 2, 0
95
101
  ]
96
102
 
97
103
  class << self
@@ -101,29 +107,33 @@ self.bel_start = 1;
101
107
  class << self
102
108
  attr_accessor :bel_first_final
103
109
  end
104
- self.bel_first_final = 5;
110
+ self.bel_first_final = 4;
105
111
  class << self
106
112
  attr_accessor :bel_error
107
113
  end
108
114
  self.bel_error = 0;
109
115
 
110
116
  class << self
111
- attr_accessor :bel_en_comment
117
+ attr_accessor :bel_en_comment_node
112
118
  end
113
- self.bel_en_comment = 1;
119
+ self.bel_en_comment_node = 1;
114
120
 
115
121
 
116
- # end: ragel
122
+ # end: ragel
117
123
  end
118
124
 
119
125
  def each
120
- @buffers = {}
121
- stack = []
122
- data = @content.unpack('C*')
123
- p = 0
124
- pe = data.length
125
-
126
- # begin: ragel
126
+ @buffers = {}
127
+ @incomplete = {}
128
+ stack = []
129
+ data = @content.unpack('C*')
130
+ p = 0
131
+ p_start = 0
132
+ p_end = 0
133
+ pe = data.length
134
+ eof = data.length
135
+
136
+ # begin: ragel
127
137
 
128
138
  begin
129
139
  p ||= 0
@@ -168,33 +178,30 @@ begin
168
178
  cs = _bel_trans_targs[_trans]
169
179
  if _bel_trans_actions[_trans] != 0
170
180
  case _bel_trans_actions[_trans]
171
- when 3 then
172
- begin
173
-
174
- @buffers[:comment] << data[p].ord
175
- end
176
181
  when 1 then
177
182
  begin
178
183
 
179
- yield @buffers[:comment] || comment(nil)
184
+ trace('COMMENT start_comment')
185
+ p_start = p;
180
186
  end
181
187
  when 2 then
182
188
  begin
183
189
 
184
- @buffers[:comment] = []
185
- end
186
- begin
187
-
188
- @buffers[:comment] << data[p].ord
190
+ trace('COMMENT stop_comment')
191
+ p_end = p;
189
192
  end
190
- when 4 then
191
193
  begin
192
194
 
193
- @buffers[:comment] = comment(
194
- utf8_string(@buffers[:comment]))
195
+ trace('COMMENT comment_end')
196
+ p_end = p
197
+ chars = data[p_start...p_end]
198
+ completed = !chars.empty?
199
+ ast_node = comment(utf8_string(chars), complete: completed)
200
+ @buffers[:comment] = ast_node
195
201
  end
196
202
  begin
197
203
 
204
+ trace('COMMENT yield_comment')
198
205
  yield @buffers[:comment] || comment(nil)
199
206
  end
200
207
  end
@@ -212,6 +219,31 @@ begin
212
219
  end
213
220
  end
214
221
  if _goto_level <= _test_eof
222
+ if p == eof
223
+ case _bel_eof_actions[cs]
224
+ when 2 then
225
+ begin
226
+
227
+ trace('COMMENT stop_comment')
228
+ p_end = p;
229
+ end
230
+ begin
231
+
232
+ trace('COMMENT comment_end')
233
+ p_end = p
234
+ chars = data[p_start...p_end]
235
+ completed = !chars.empty?
236
+ ast_node = comment(utf8_string(chars), complete: completed)
237
+ @buffers[:comment] = ast_node
238
+ end
239
+ begin
240
+
241
+ trace('COMMENT yield_comment')
242
+ yield @buffers[:comment] || comment(nil)
243
+ end
244
+ end
245
+ end
246
+
215
247
  end
216
248
  if _goto_level <= _out
217
249
  break
@@ -219,7 +251,7 @@ begin
219
251
  end
220
252
  end
221
253
 
222
- # end: ragel
254
+ # end: ragel
223
255
  end
224
256
  end
225
257
  end
@@ -6,27 +6,38 @@
6
6
  include 'common.rl';
7
7
 
8
8
  action start_comment {
9
- @buffers[:comment] = []
9
+ trace('COMMENT start_comment')
10
+ p_start = p;
10
11
  }
11
12
 
12
- action append_comment {
13
- @buffers[:comment] << fc
13
+ action stop_comment {
14
+ trace('COMMENT stop_comment')
15
+ p_end = p;
14
16
  }
15
17
 
16
- action finish_comment {
17
- @buffers[:comment] = comment(
18
- utf8_string(@buffers[:comment]))
18
+ action comment_end {
19
+ trace('COMMENT comment_end')
20
+ p_end = p
21
+ chars = data[p_start...p_end]
22
+ completed = !chars.empty?
23
+ ast_node = comment(utf8_string(chars), complete: completed)
24
+ @buffers[:comment] = ast_node
19
25
  }
20
26
 
21
27
  action yield_comment {
28
+ trace('COMMENT yield_comment')
22
29
  yield @buffers[:comment] || comment(nil)
23
30
  }
24
31
 
25
- COMMENT = '//' ^NL+ >start_comment $append_comment %finish_comment;
32
+ comment =
33
+ SS
34
+ ^NL+ >start_comment %stop_comment %comment_end
35
+ ;
26
36
 
27
- comment :=
28
- COMMENT? %yield_comment
29
- NL;
37
+ comment_node :=
38
+ comment %yield_comment
39
+ NL?
40
+ ;
30
41
  }%%
31
42
  =end
32
43
  # end: ragel
@@ -34,6 +45,7 @@
34
45
  require_relative '../ast/node'
35
46
  require_relative '../mixin/buffer'
36
47
  require_relative '../nonblocking_io_wrapper'
48
+ require_relative '../tracer'
37
49
 
38
50
  module BELParser
39
51
  module Parsers
@@ -59,25 +71,30 @@ module BELParser
59
71
  include Enumerable
60
72
  include BELParser::Parsers::Buffer
61
73
  include BELParser::Parsers::AST::Sexp
74
+ include BELParser::Parsers::Tracer
62
75
 
63
76
  def initialize(content)
64
77
  @content = content
65
- # begin: ragel
78
+ # begin: ragel
66
79
  %% write data;
67
- # end: ragel
80
+ # end: ragel
68
81
  end
69
82
 
70
83
  def each
71
- @buffers = {}
72
- stack = []
73
- data = @content.unpack('C*')
74
- p = 0
75
- pe = data.length
76
-
77
- # begin: ragel
84
+ @buffers = {}
85
+ @incomplete = {}
86
+ stack = []
87
+ data = @content.unpack('C*')
88
+ p = 0
89
+ p_start = 0
90
+ p_end = 0
91
+ pe = data.length
92
+ eof = data.length
93
+
94
+ # begin: ragel
78
95
  %% write init;
79
96
  %% write exec;
80
- # end: ragel
97
+ # end: ragel
81
98
  end
82
99
  end
83
100
  end