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
@@ -5,37 +5,75 @@
5
5
 
6
6
  include 'common.rl';
7
7
 
8
- action start_ident {
9
- @buffers[:ident] = []
8
+ action start_identifier {
9
+ trace('IDENTIFIER start_identifier')
10
+ @identifier_started = true
11
+ id_start = p;
10
12
  }
11
13
 
12
- action append_ident {
13
- (@buffers[:ident] ||= []) << fc
14
+ action end_identifier {
15
+ trace('IDENTIFIER end_identifier')
16
+ id_end = p
17
+ chars = data[id_start...id_end]
18
+ completed = !chars.empty?
19
+ ast_node = identifier(utf8_string(chars), complete: completed)
20
+ @buffers[:ident] = ast_node
14
21
  }
15
22
 
16
- action finish_ident {
17
- @buffers[:ident] = identifier(utf8_string(@buffers[:ident]))
23
+ action an_ident_err {
24
+ trace('IDENTIFIER an_ident_err')
25
+ id_end = p
26
+ chars = data[id_start...id_end]
27
+ ast_node = identifier(utf8_string(chars), complete: false)
28
+ @buffers[:ident] = ast_node
18
29
  }
19
30
 
20
- action yield_complete_ident {
21
- yield @buffers[:ident]
22
- }
23
-
24
- action error_ident {
25
- unless @buffers[:ident].is_a?(::AST::Node)
26
- @buffers[:ident] ||= []
27
- @buffers[:ident] = identifier(utf8_string(@buffers[:ident]).sub(/\n$/, ''))
28
- end
31
+ action ident_node_err {
32
+ trace('IDENTIFIER ident_node_err')
33
+ id_end = p
34
+ chars = data[id_start...id_end]
35
+ ast_node = identifier(utf8_string(chars), complete: false)
36
+ yield ast_node
29
37
  }
30
38
 
31
- action yield_error_ident {
32
- @buffers[:ident] ||= []
39
+ action yield_identifier {
40
+ trace('IDENTIFIER yield_identifier')
33
41
  yield @buffers[:ident]
34
42
  }
35
43
 
36
- IDENT = [a-zA-Z0-9_]+ >start_ident $append_ident %finish_ident $err(error_ident);
44
+ action an_ident_eof {
45
+ trace('IDENTIFIER an_ident_eof')
46
+ if @identifier_started
47
+ id_end = p
48
+ chars = data[id_start...id_end]
49
+ completed = !chars.empty?
50
+ ast_node = identifier(utf8_string(chars), complete: completed)
51
+ @buffers[:ident] = ast_node
52
+ end
53
+ }
37
54
 
38
- ident := IDENT $err(yield_error_ident) %yield_complete_ident NL;
55
+ ident =
56
+ ID_CHARS
57
+ >start_identifier
58
+ %end_identifier
59
+ ;
60
+
61
+ maybe_ident =
62
+ ident?
63
+ ;
64
+
65
+ an_ident =
66
+ ident
67
+ $eof(an_ident_eof)
68
+ $err(an_ident_err)
69
+ ;
70
+
71
+ ident_node :=
72
+ ident
73
+ NL?
74
+ $err(ident_node_err)
75
+ %yield_identifier
76
+ ;
39
77
  }%%
40
78
  =end
41
79
  # end: ragel
@@ -43,6 +81,7 @@
43
81
  require_relative '../ast/node'
44
82
  require_relative '../mixin/buffer'
45
83
  require_relative '../nonblocking_io_wrapper'
84
+ require_relative '../tracer'
46
85
 
47
86
  module BELParser
48
87
  module Parsers
@@ -68,25 +107,30 @@ module BELParser
68
107
  include Enumerable
69
108
  include BELParser::Parsers::Buffer
70
109
  include BELParser::Parsers::AST::Sexp
110
+ include BELParser::Parsers::Tracer
71
111
 
72
112
  def initialize(content)
73
113
  @content = content
74
- # begin: ragel
114
+ # begin: ragel
75
115
  %% write data;
76
- # end: ragel
116
+ # end: ragel
77
117
  end
78
118
 
79
119
  def each
80
- @buffers = {}
81
- data = @content.unpack('C*')
82
- p = 0
83
- pe = data.length
84
- eof = data.length
85
-
86
- # begin: ragel
120
+ @buffers = {}
121
+ @incomplete = {}
122
+ data = @content.unpack('C*')
123
+ p = 0
124
+ id_start = 0
125
+ id_end = 0
126
+ pe = data.length
127
+ eof = data.length
128
+
129
+ identifier_started = false
130
+ # begin: ragel
87
131
  %% write init;
88
132
  %% write exec;
89
- # end: ragel
133
+ # end: ragel
90
134
  end
91
135
  end
92
136
  end