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,89 +3,104 @@
3
3
  %%{
4
4
  machine bel;
5
5
 
6
+ include 'function.rl';
6
7
  include 'parameter.rl';
7
8
 
8
- action start_function {
9
- @buffers[:function] = []
10
- }
11
-
12
- action append_function {
13
- @buffers[:function] << fc
14
- }
15
-
16
- action finish_function {
17
- @buffers[:function] = identifier(utf8_string(@buffers[:function]))
18
- }
19
-
20
9
  action term_init {
10
+ trace('TERM term_init')
21
11
  @buffers[:term_stack] = [ term() ]
22
12
  }
23
13
 
24
14
  action inner_term_init {
15
+ trace('TERM inner_term_init')
25
16
  @buffers[:term_stack] << term()
26
17
  }
27
18
 
28
19
  action term_fx {
29
- fx = @buffers[:function]
30
- @buffers[:term_stack][-1] = @buffers[:term_stack][-1] << function(fx)
20
+ trace('TERM term_fx')
21
+ new_term = @buffers[:term_stack][-1] << @buffers[:function]
22
+ @buffers[:term_stack][-1] = new_term
31
23
  }
32
24
 
33
25
  action term_argument {
34
- @buffers[:term_stack][-1] = @buffers[:term_stack][-1] << argument(@buffers[:parameter])
35
- @buffers[:parameter] = nil
26
+ trace('TERM term_argument')
27
+ arg_node = argument(@buffers[:parameter])
28
+ new_term = @buffers[:term_stack][-1] << arg_node
29
+ @buffers[:term_stack][-1] = new_term
30
+ @buffers[:parameter] = nil
36
31
  }
37
32
 
38
33
  action fxbt {
39
- fpc -= @buffers[:function].length + 1
34
+ trace('TERM fxbt')
35
+ function_string = @buffers[:function].identifier.string_literal
36
+ fpc -= function_string.length + 1
40
37
  fcall inner_term;
41
38
  }
42
39
 
43
40
  action fxret {
41
+ trace('TERM fxret')
44
42
  inner_term = @buffers[:term_stack].pop
45
- @buffers[:term_stack][-1] = @buffers[:term_stack][-1] << argument(inner_term)
43
+ arg_node = argument(inner_term)
44
+ new_term = @buffers[:term_stack][-1] << arg_node
45
+ @buffers[:term_stack][-1] = new_term
46
46
  fret;
47
47
  }
48
48
 
49
+ action outer_term_end {
50
+ trace('TERM outer_term_end')
51
+ term_stack = @buffers[:term_stack]
52
+ term_stack.each { |term| term.complete = true }
53
+ }
54
+
55
+ action eof_parameter_argument {
56
+ trace('TERM eof_parameter_argument')
57
+ @buffers[:term_stack][-1].complete = false
58
+ yield @buffers[:term_stack][-1]
59
+ }
60
+
49
61
  action yield_term_ast {
50
62
  yield @buffers[:term_stack][-1]
51
63
  }
52
64
 
53
65
  inner_term :=
54
- IDENT >inner_term_init >start_function $append_function %finish_function
66
+ a_function >inner_term_init
55
67
  SP*
56
68
  '(' @term_fx
57
69
  (
58
- BEL_PARAMETER %term_argument |
59
- IDENT >start_function $append_function '(' @fxbt
70
+ a_parameter %term_argument |
71
+ a_function '(' @fxbt
60
72
  )
61
73
  (
62
- SP* ',' SP*
74
+ COMMA_DELIM
63
75
  (
64
- BEL_PARAMETER %term_argument |
65
- IDENT >start_function $append_function '(' @fxbt
76
+ a_parameter %term_argument |
77
+ a_function '(' @fxbt
66
78
  )
67
79
  )*
68
80
  ')' @fxret;
69
81
 
70
82
  outer_term =
71
- IDENT >term_init >start_function $append_function %finish_function
83
+ a_function >term_init
72
84
  SP*
73
85
  '(' @term_fx
74
86
  (
75
- BEL_PARAMETER %term_argument |
76
- IDENT >start_function $append_function '(' @fxbt
87
+ a_parameter %term_argument $eof(eof_parameter_argument) |
88
+ a_function '(' @fxbt
77
89
  )
78
90
  (
79
- SP* ',' SP*
91
+ COMMA_DELIM
80
92
  (
81
- BEL_PARAMETER %term_argument |
82
- IDENT >start_function $append_function '(' @fxbt
93
+ a_parameter %term_argument $eof(eof_parameter_argument) |
94
+ a_function '(' @fxbt
83
95
  )
84
96
  )*
85
97
  ')';
86
98
 
87
99
  term :=
88
- outer_term %yield_term_ast NL;
100
+ outer_term
101
+ %outer_term_end
102
+ %yield_term_ast
103
+ NL?;
89
104
  }%%
90
105
  =end
91
106
  # end: ragel
@@ -93,6 +108,7 @@
93
108
  require_relative '../ast/node'
94
109
  require_relative '../mixin/buffer'
95
110
  require_relative '../nonblocking_io_wrapper'
111
+ require_relative '../tracer'
96
112
 
97
113
  module BELParser
98
114
  module Parsers
@@ -118,12 +134,13 @@ module BELParser
118
134
  include Enumerable
119
135
  include BELParser::Parsers::Buffer
120
136
  include BELParser::Parsers::AST::Sexp
137
+ include BELParser::Parsers::Tracer
121
138
 
122
139
  def initialize(content)
123
140
  @content = content
124
- # begin: ragel
141
+ # begin: ragel
125
142
  %% write data;
126
- # end: ragel
143
+ # end: ragel
127
144
  end
128
145
 
129
146
  def each
@@ -134,10 +151,10 @@ module BELParser
134
151
  pe = data.length
135
152
  eof = data.length
136
153
 
137
- # begin: ragel
154
+ # begin: ragel
138
155
  %% write init;
139
156
  %% write exec;
140
- # end: ragel
157
+ # end: ragel
141
158
  end
142
159
  end
143
160
  end
@@ -14,6 +14,7 @@ module LINE
14
14
  BELParser::Parsers::Common::Identifier,
15
15
  BELParser::Parsers::Common::String,
16
16
  BELParser::Parsers::Common::List,
17
+ BELParser::Parsers::Common::Function,
17
18
  BELParser::Parsers::Expression::Parameter,
18
19
  BELParser::Parsers::Expression::Term,
19
20
  BELParser::Parsers::Expression::Relationship,
@@ -5,6 +5,10 @@ module BELParser
5
5
  def utf8_string(buffer)
6
6
  buffer.pack('C*').force_encoding('utf-8')
7
7
  end
8
+
9
+ def ord_to_str(enumerable)
10
+ (enumerable.map { |x| x.chr }).join()
11
+ end
8
12
  end
9
13
  end
10
14
  end
@@ -0,0 +1,19 @@
1
+ module BELParser
2
+ module Parsers
3
+ # Tracer provides a facility to trace ragel finite state machines.
4
+ # Tracing is enabled with using +$DEBUG+ or the environment variable
5
+ # +BELPARSER_PARSER_TRACE+
6
+ module Tracer
7
+ # Defines trace on require based on environment.
8
+ if $DEBUG || (ENV['BELPARSER_PARSER_TRACE'] =~ /^(1|yes|on|true)$/)
9
+ def trace(msg)
10
+ $stderr.puts msg
11
+ end
12
+ else
13
+ def trace(_)
14
+ # no-operation
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -18,6 +18,7 @@ module BELParser
18
18
  resource_reader = script_context[:resource_reader]
19
19
 
20
20
  keyword, domain = ast_node.children
21
+ require 'pry'; binding.pry unless domain
21
22
  if domain.url?
22
23
  prefix = keyword.identifier.string_literal
23
24
  url = unquote(domain.child.string.string_literal)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bel_parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.alpha.38
4
+ version: 1.0.0.alpha.39
5
5
  platform: java
6
6
  authors:
7
7
  - Anthony Bargnesi
@@ -12,33 +12,33 @@ cert_chain: []
12
12
  date: 2016-05-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
+ name: sparql-client
15
16
  requirement: !ruby/object:Gem::Requirement
16
17
  requirements:
17
18
  - - "~>"
18
19
  - !ruby/object:Gem::Version
19
20
  version: 2.0.0
20
- name: sparql-client
21
- prerelease: false
22
- type: :runtime
23
21
  version_requirements: !ruby/object:Gem::Requirement
24
22
  requirements:
25
23
  - - "~>"
26
24
  - !ruby/object:Gem::Version
27
25
  version: 2.0.0
26
+ prerelease: false
27
+ type: :runtime
28
28
  - !ruby/object:Gem::Dependency
29
+ name: dbm-mapdb3
29
30
  requirement: !ruby/object:Gem::Requirement
30
31
  requirements:
31
32
  - - "~>"
32
33
  - !ruby/object:Gem::Version
33
34
  version: 0.6.0.beta
34
- name: dbm-mapdb3
35
- prerelease: false
36
- type: :runtime
37
35
  version_requirements: !ruby/object:Gem::Requirement
38
36
  requirements:
39
37
  - - "~>"
40
38
  - !ruby/object:Gem::Version
41
39
  version: 0.6.0.beta
40
+ prerelease: false
41
+ type: :runtime
42
42
  description: Implements language versions 1.0 and 2.0.
43
43
  email: abargnesi@selventa.com
44
44
  executables:
@@ -317,6 +317,8 @@ files:
317
317
  - lib/bel_parser/parsers/common/comment_line.rl
318
318
  - lib/bel_parser/parsers/common/common.rb
319
319
  - lib/bel_parser/parsers/common/common.rl
320
+ - lib/bel_parser/parsers/common/function.rb
321
+ - lib/bel_parser/parsers/common/function.rl
320
322
  - lib/bel_parser/parsers/common/identifier.rb
321
323
  - lib/bel_parser/parsers/common/identifier.rl
322
324
  - lib/bel_parser/parsers/common/list.rb
@@ -342,6 +344,7 @@ files:
342
344
  - lib/bel_parser/parsers/mixin/buffer.rb
343
345
  - lib/bel_parser/parsers/nonblocking_io_wrapper.rb
344
346
  - lib/bel_parser/parsers/serializer.rb
347
+ - lib/bel_parser/parsers/tracer.rb
345
348
  - lib/bel_parser/quoting.rb
346
349
  - lib/bel_parser/resource.rb
347
350
  - lib/bel_parser/resource/concept.rb