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
@@ -7,49 +7,86 @@
7
7
  include 'identifier.rl';
8
8
  include 'string.rl';
9
9
 
10
- DEFINE_KW = [dD][eE][fF][iI][nN][eE];
11
- NAMESPACE_KW = [nN][aA][mM][eE][sS][pP][aA][cC][eE];
12
- AS_KW = [aA][sS];
13
- URL_KW = [uU][rR][lL];
14
-
15
- action namespace_keyword {
16
- @buffers[:namespace_definition] = namespace_definition()
10
+ action add_name {
11
+ trace('DEFINE_NAMESPACE add_name')
12
+ name = @buffers.delete(:ident)
13
+ @buffers[:namespace_definition_name] = name
17
14
  }
18
15
 
19
- action keyword {
20
- @buffers[:namespace_definition] = @buffers[:namespace_definition] << keyword(@buffers[:ident])
16
+ action add_string_value {
17
+ trace('DEFINE_NAMESPACE add_string_value')
18
+ string_node = @buffers.delete(:string)
19
+ leaf = domain(url(string_node))
20
+ leaf.complete = string_node.complete
21
+ @buffers[:namespace_definition_domain] = leaf
21
22
  }
22
23
 
23
- action url_keyword {
24
- @buffers[:namespace_definition] = @buffers[:namespace_definition] << domain(url())
24
+ action add_url_domain {
25
+ trace('DEFINE_NAMESPACE add_url_domain')
26
+ @url_domain = true
25
27
  }
26
28
 
27
- action string {
28
- keyword, domain = @buffers[:namespace_definition].children
29
- domain = domain(
30
- domain.children[0] << @buffers[:string])
31
- @buffers[:namespace_definition] = namespace_definition(keyword, domain)
29
+ action define_namespace_end {
30
+ trace('DEFINE_NAMESPACE define_namespace_end')
31
+ namespace_definition_node = namespace_definition()
32
+
33
+ name = @buffers.delete(:namespace_definition_name)
34
+ namespace_definition_node <<= keyword(name)
35
+
36
+ domain = @buffers.delete(:namespace_definition_domain)
37
+ unless domain.nil?
38
+ namespace_definition_node <<= domain
39
+ namespace_definition_node.complete = domain.complete
40
+ end
41
+ @buffers[:namespace_definition] = namespace_definition_node
32
42
  }
33
43
 
34
- action yield_namespace_definition {
44
+ action yield_define_namespace {
45
+ trace('DEFINE_NAMESPACE yield_define_namespace')
35
46
  yield @buffers[:namespace_definition]
36
47
  }
37
48
 
38
- # Define FSM
39
- define_namespace :=
40
- DEFINE_KW
41
- SP+
42
- NAMESPACE_KW @namespace_keyword
49
+ action define_namespace_node_eof {
50
+ trace('DEFINE_NAMESPACE define_namespace_node_eof')
51
+ leaf = url()
52
+ string_node = @buffers.delete(:string)
53
+ unless string_node.nil?
54
+ leaf <<= string_node
55
+ leaf.complete = string_node.complete
56
+ end
57
+ domain_node = domain(leaf)
58
+ domain_node.complete = leaf.complete
59
+ namespace_definition_node = namespace_definition(domain_node)
60
+ namespace_definition_node.complete = domain_node.complete
61
+ yield namespace_definition_node
62
+ }
63
+
64
+ string_value =
65
+ a_string
66
+ %add_string_value
67
+ ;
68
+
69
+ url_domain =
70
+ KW_URL
71
+ %add_url_domain
72
+ ;
73
+
74
+ define_namespace_node :=
75
+ DEFINE_NAMESPACE
43
76
  SP+
44
- IDENT %keyword
77
+ an_ident
78
+ %add_name
45
79
  SP+
46
- AS_KW
80
+ KW_AS
47
81
  SP+
48
- URL_KW @url_keyword
82
+ url_domain
49
83
  SP+
50
- STRING %string
51
- SP*
52
- NL @yield_namespace_definition;
84
+ string_value
85
+ @eof(define_namespace_node_eof)
86
+ %define_namespace_end
87
+ %yield_define_namespace
88
+ NL
89
+ ;
53
90
  }%%
54
91
  =end
55
92
  # end: ragel
@@ -57,6 +94,7 @@
57
94
  require_relative '../ast/node'
58
95
  require_relative '../mixin/buffer'
59
96
  require_relative '../nonblocking_io_wrapper'
97
+ require_relative '../tracer'
60
98
 
61
99
  module BELParser
62
100
  module Parsers
@@ -82,26 +120,28 @@ module BELParser
82
120
  include Enumerable
83
121
  include BELParser::Parsers::Buffer
84
122
  include BELParser::Parsers::AST::Sexp
123
+ include BELParser::Parsers::Tracer
85
124
 
86
125
  def initialize(content)
87
126
  @content = content
88
- # begin: ragel
127
+ # begin: ragel
89
128
  %% write data;
90
- # end: ragel
129
+ # end: ragel
91
130
  end
92
131
 
93
132
  def each
94
- @buffers = {}
95
- stack = []
96
- data = @content.unpack('C*')
97
- p = 0
98
- pe = data.length
99
- eof = data.length
100
-
101
- # begin: ragel
133
+ @buffers = {}
134
+ @incomplete = {}
135
+ stack = []
136
+ data = @content.unpack('C*')
137
+ p = 0
138
+ pe = data.length
139
+ eof = data.length
140
+
141
+ # begin: ragel
102
142
  %% write init;
103
143
  %% write exec;
104
- # end: ragel
144
+ # end: ragel
105
145
  end
106
146
  end
107
147
  end