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
@@ -3,30 +3,128 @@
3
3
  %%{
4
4
  machine bel;
5
5
 
6
- include 'set.rl';
6
+ include 'common.rl';
7
+ include 'identifier.rl';
8
+ include 'string.rl';
9
+ include 'list.rl';
10
+
11
+ action add_property {
12
+ trace('SET_DOCUMENT add_property')
13
+ key = @buffers.delete(:ident)
14
+ @buffers[:set_document_name] = key
15
+ }
7
16
 
8
- DOCUMENT_KW = [dD][oO][cC][uU][mM][eE][nN][tT];
17
+ action add_ident_value {
18
+ trace('SET_DOCUMENT add_ident_value')
19
+ ident = @buffers.delete(:ident)
20
+ @buffers[:set_document_value] = ident
21
+ }
9
22
 
10
- action yield_document_property {
11
- yield(
12
- document_property(
13
- *@buffers[:set].children))
23
+ action add_string_value {
24
+ trace('SET_DOCUMENT add_string_value')
25
+ string = @buffers.delete(:string)
26
+ @buffers[:set_document_value] = string
14
27
  }
15
28
 
16
- set_document :=
17
- SET_KW %set_keyword
18
- SP+
19
- DOCUMENT_KW
29
+ action add_list_value {
30
+ trace('SET_DOCUMENT add_list_value')
31
+ list = @buffers.delete(:list)
32
+ @buffers[:set_document_value] = list
33
+ }
34
+
35
+ action set_document_end {
36
+ trace('SET_DOCUMENT set_document_end')
37
+ set_document_node = document_property()
38
+ completed = true
39
+
40
+ name = @buffers.delete(:set_document_name)
41
+ unless name.nil?
42
+ set_document_node <<= name
43
+ end
44
+
45
+ value = @buffers.delete(:set_document_value)
46
+ unless value.nil?
47
+ set_document_node <<= value
48
+ end
49
+
50
+ completed = false
51
+ unless name.nil? || value.nil?
52
+ completed = name.complete && value.complete
53
+ end
54
+
55
+ set_document_node.complete = completed
56
+ @buffers[:set_document] = set_document_node
57
+ }
58
+
59
+ action yield_set_document {
60
+ trace('SET_DOCUMENT yield_set')
61
+ yield @buffers[:set_document]
62
+ }
63
+
64
+ action set_document_node_eof {
65
+ trace('SET_DOCUMENT set_document_node_eof')
66
+ name = @buffers.delete(:set_document_name)
67
+ set_document_node = set(name)
68
+ completed = name.complete
69
+ if @buffers.key?(:string)
70
+ value = @buffers.delete(:string)
71
+ set_document_node <<= value
72
+ completed = completed && value.complete
73
+ elsif @buffers.key?(:ident)
74
+ value = @buffers.delete(:ident)
75
+ set_document_node <<= value
76
+ completed = completed && value.complete
77
+ elsif @buffers.key?(:list)
78
+ value = @buffers.delete(:list)
79
+ set_document_node <<= value
80
+ completed = completed && value.complete
81
+ end
82
+ set_document_node.complete = completed
83
+ yield set_document_node
84
+ }
85
+
86
+ document_property =
87
+ an_ident &
88
+ DOCUMENT_PROPERTY
89
+ ;
90
+
91
+ ident_value =
92
+ an_ident
93
+ %add_ident_value
94
+ ;
95
+
96
+ string_value =
97
+ a_string
98
+ %add_string_value
99
+ ;
100
+
101
+ list_value =
102
+ a_list
103
+ %add_list_value
104
+ ;
105
+
106
+ value =
107
+ ident_value |
108
+ string_value |
109
+ list_value
110
+ ;
111
+
112
+ set_document_node :=
113
+ KW_SET
20
114
  SP+
21
- IDENT %name
115
+ KW_DOCUMENT
22
116
  SP+
23
- EQL
117
+ document_property
118
+ %add_property
119
+ @eof(set_document_node_eof)
24
120
  SP+
25
- (
26
- STRING %string_value |
27
- LIST %list_value |
28
- IDENT %ident_value
29
- ) NL @yield_document_property;
121
+ EQL?
122
+ SP+?
123
+ value?
124
+ @eof(set_document_node_eof)
125
+ %set_document_end
126
+ %yield_set_document
127
+ ;
30
128
  }%%
31
129
  =end
32
130
  # end: ragel
@@ -34,6 +132,7 @@
34
132
  require_relative '../ast/node'
35
133
  require_relative '../mixin/buffer'
36
134
  require_relative '../nonblocking_io_wrapper'
135
+ require_relative '../tracer'
37
136
 
38
137
  module BELParser
39
138
  module Parsers
@@ -59,25 +158,29 @@ module BELParser
59
158
  include Enumerable
60
159
  include BELParser::Parsers::Buffer
61
160
  include BELParser::Parsers::AST::Sexp
161
+ include BELParser::Parsers::Tracer
62
162
 
63
163
  def initialize(content)
64
164
  @content = content
65
- # begin: ragel
165
+ # begin: ragel
66
166
  %% write data;
67
- # end: ragel
167
+ # end: ragel
68
168
  end
69
169
 
70
170
  def each
71
- @buffers = {}
72
- data = @content.unpack('C*')
73
- p = 0
74
- pe = data.length
75
- eof = data.length
76
-
77
- # begin: ragel
171
+ @buffers = {}
172
+ @incomplete = {}
173
+ data = @content.unpack('C*')
174
+ p = 0
175
+ pe = data.length
176
+ eof = data.length
177
+ id_start = 0
178
+ id_end = 0
179
+
180
+ # begin: ragel
78
181
  %% write init;
79
182
  %% write exec;
80
- # end: ragel
183
+ # end: ragel
81
184
  end
82
185
  end
83
186
  end