bel_parser 1.0.8 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (112) hide show
  1. checksums.yaml +4 -4
  2. data/.gemspec +12 -2
  3. data/VERSION +1 -1
  4. data/bin/bel2_compatibility +12 -9
  5. data/bin/bel2_upgrade +18 -6
  6. data/bin/bel2_validator +6 -3
  7. data/bin/bel_script_reader +1 -0
  8. data/lib/bel_parser/completion.rb +984 -0
  9. data/lib/bel_parser/language/apply_namespace_encoding.rb +14 -3
  10. data/lib/bel_parser/language/expression_validator.rb +1 -2
  11. data/lib/bel_parser/language/function.rb +4 -0
  12. data/lib/bel_parser/language/relationship.rb +4 -0
  13. data/lib/bel_parser/language/semantics/function_deprecation.rb +1 -0
  14. data/lib/bel_parser/language/semantics/list_function_subject.rb +2 -0
  15. data/lib/bel_parser/language/semantics/multiple_subject_object.rb +4 -1
  16. data/lib/bel_parser/language/semantics/nested_statement_without_object.rb +43 -0
  17. data/lib/bel_parser/language/semantics/non_object_list.rb +3 -0
  18. data/lib/bel_parser/language/semantics/relationship_not_listable.rb +2 -0
  19. data/lib/bel_parser/language/semantics/signature_mapping.rb +2 -0
  20. data/lib/bel_parser/language/semantics_ast.rb +0 -7
  21. data/lib/bel_parser/language/syntax/invalid_function.rb +6 -1
  22. data/lib/bel_parser/language/syntax/invalid_relationship.rb +1 -0
  23. data/lib/bel_parser/language/version1_0/relationships/acts_in.rb +9 -9
  24. data/lib/bel_parser/language/version1_0/relationships/analogous.rb +6 -4
  25. data/lib/bel_parser/language/version1_0/relationships/association.rb +8 -7
  26. data/lib/bel_parser/language/version1_0/relationships/biomarker_for.rb +6 -5
  27. data/lib/bel_parser/language/version1_0/relationships/causes_no_change.rb +8 -7
  28. data/lib/bel_parser/language/version1_0/relationships/decreases.rb +13 -12
  29. data/lib/bel_parser/language/version1_0/relationships/directly_decreases.rb +8 -6
  30. data/lib/bel_parser/language/version1_0/relationships/directly_increases.rb +8 -6
  31. data/lib/bel_parser/language/version1_0/relationships/has_component.rb +14 -14
  32. data/lib/bel_parser/language/version1_0/relationships/has_components.rb +12 -11
  33. data/lib/bel_parser/language/version1_0/relationships/has_member.rb +10 -8
  34. data/lib/bel_parser/language/version1_0/relationships/has_members.rb +12 -11
  35. data/lib/bel_parser/language/version1_0/relationships/has_modification.rb +9 -7
  36. data/lib/bel_parser/language/version1_0/relationships/has_product.rb +10 -8
  37. data/lib/bel_parser/language/version1_0/relationships/has_variant.rb +9 -7
  38. data/lib/bel_parser/language/version1_0/relationships/includes.rb +11 -10
  39. data/lib/bel_parser/language/version1_0/relationships/increases.rb +12 -13
  40. data/lib/bel_parser/language/version1_0/relationships/is_a.rb +10 -8
  41. data/lib/bel_parser/language/version1_0/relationships/negative_correlation.rb +9 -7
  42. data/lib/bel_parser/language/version1_0/relationships/orthologous.rb +9 -8
  43. data/lib/bel_parser/language/version1_0/relationships/positive_correlation.rb +8 -5
  44. data/lib/bel_parser/language/version1_0/relationships/prognostic_biomarker_for.rb +8 -6
  45. data/lib/bel_parser/language/version1_0/relationships/rate_limiting_step_of.rb +10 -9
  46. data/lib/bel_parser/language/version1_0/relationships/reactant_in.rb +10 -8
  47. data/lib/bel_parser/language/version1_0/relationships/sub_process_of.rb +13 -12
  48. data/lib/bel_parser/language/version1_0/relationships/transcribed_to.rb +8 -7
  49. data/lib/bel_parser/language/version1_0/relationships/translated_to.rb +9 -7
  50. data/lib/bel_parser/language/version1_0/relationships/translocates.rb +10 -9
  51. data/lib/bel_parser/language/version2_0/functions/protein_modification.rb +1 -2
  52. data/lib/bel_parser/language/version2_0/functions/translocation.rb +1 -2
  53. data/lib/bel_parser/language/version2_0/functions/variant.rb +1 -2
  54. data/lib/bel_parser/language/version2_0/relationships/acts_in.rb +10 -9
  55. data/lib/bel_parser/language/version2_0/relationships/biomarker_for.rb +7 -5
  56. data/lib/bel_parser/language/version2_0/relationships/causes_no_change.rb +9 -7
  57. data/lib/bel_parser/language/version2_0/relationships/decreases.rb +13 -12
  58. data/lib/bel_parser/language/version2_0/relationships/directly_decreases.rb +8 -6
  59. data/lib/bel_parser/language/version2_0/relationships/directly_increases.rb +8 -6
  60. data/lib/bel_parser/language/version2_0/relationships/has_component.rb +15 -14
  61. data/lib/bel_parser/language/version2_0/relationships/has_components.rb +12 -11
  62. data/lib/bel_parser/language/version2_0/relationships/has_member.rb +9 -8
  63. data/lib/bel_parser/language/version2_0/relationships/has_members.rb +12 -11
  64. data/lib/bel_parser/language/version2_0/relationships/has_modification.rb +9 -7
  65. data/lib/bel_parser/language/version2_0/relationships/has_product.rb +10 -8
  66. data/lib/bel_parser/language/version2_0/relationships/has_variant.rb +9 -7
  67. data/lib/bel_parser/language/version2_0/relationships/includes.rb +11 -10
  68. data/lib/bel_parser/language/version2_0/relationships/increases.rb +13 -12
  69. data/lib/bel_parser/language/version2_0/relationships/is_a.rb +10 -8
  70. data/lib/bel_parser/language/version2_0/relationships/negative_correlation.rb +9 -7
  71. data/lib/bel_parser/language/version2_0/relationships/orthologous.rb +10 -8
  72. data/lib/bel_parser/language/version2_0/relationships/positive_correlation.rb +7 -5
  73. data/lib/bel_parser/language/version2_0/relationships/prognostic_biomarker_for.rb +8 -6
  74. data/lib/bel_parser/language/version2_0/relationships/rate_limiting_step_of.rb +10 -9
  75. data/lib/bel_parser/language/version2_0/relationships/reactant_in.rb +10 -8
  76. data/lib/bel_parser/language/version2_0/relationships/regulates.rb +9 -8
  77. data/lib/bel_parser/language/version2_0/relationships/sub_process_of.rb +13 -12
  78. data/lib/bel_parser/language/version2_0/relationships/transcribed_to.rb +8 -7
  79. data/lib/bel_parser/language/version2_0/relationships/translated_to.rb +9 -7
  80. data/lib/bel_parser/language/version2_0/relationships/translocates.rb +10 -9
  81. data/lib/bel_parser/mixin/levenshtein.rb +20 -0
  82. data/lib/bel_parser/parsers/ast/node.rb +49 -2
  83. data/lib/bel_parser/parsers/bel_script/define_annotation.rb +156 -156
  84. data/lib/bel_parser/parsers/bel_script/define_namespace.rb +60 -60
  85. data/lib/bel_parser/parsers/bel_script/set.rb +200 -200
  86. data/lib/bel_parser/parsers/bel_script/set_document.rb +188 -188
  87. data/lib/bel_parser/parsers/bel_script/unset.rb +14 -14
  88. data/lib/bel_parser/parsers/common/common.rl +1 -0
  89. data/lib/bel_parser/parsers/common/function.rb +8 -8
  90. data/lib/bel_parser/parsers/common/function.rl +6 -6
  91. data/lib/bel_parser/parsers/common/identifier.rb +3 -3
  92. data/lib/bel_parser/parsers/common/identifier.rl +4 -4
  93. data/lib/bel_parser/parsers/common/list.rb +78 -78
  94. data/lib/bel_parser/parsers/common/multi_identifier.rb +275 -0
  95. data/lib/bel_parser/parsers/common/multi_identifier.rl +141 -0
  96. data/lib/bel_parser/parsers/common/string.rb +6 -6
  97. data/lib/bel_parser/parsers/common/string.rl +4 -4
  98. data/lib/bel_parser/parsers/common.rb +1 -0
  99. data/lib/bel_parser/parsers/expression/nested_statement.rb +30180 -29055
  100. data/lib/bel_parser/parsers/expression/observed_term.rb +1456 -1099
  101. data/lib/bel_parser/parsers/expression/parameter.rb +192 -111
  102. data/lib/bel_parser/parsers/expression/parameter.rl +6 -3
  103. data/lib/bel_parser/parsers/expression/relationship.rb +43 -19
  104. data/lib/bel_parser/parsers/expression/relationship.rl +1 -0
  105. data/lib/bel_parser/parsers/expression/simple_statement.rb +17805 -17093
  106. data/lib/bel_parser/parsers/expression/statement_autocomplete.rb +1035 -0
  107. data/lib/bel_parser/parsers/expression/statement_autocomplete.rl +736 -0
  108. data/lib/bel_parser/parsers/expression/term.rb +960 -705
  109. data/lib/bel_parser/parsers/serializer.rb +8 -4
  110. data/lib/bel_parser/version.rb +33 -0
  111. data/lib/bel_parser.rb +3 -0
  112. metadata +25 -3
@@ -215,7 +215,7 @@ begin
215
215
  id_end = p
216
216
  chars = data[id_start...id_end]
217
217
  completed = !chars.empty?
218
- ast_node = identifier(utf8_string(chars), complete: completed)
218
+ ast_node = identifier(utf8_string(chars), complete: completed, character_range: [id_start, id_end])
219
219
  @buffers[:ident] = ast_node
220
220
  end
221
221
  when 3 then
@@ -224,7 +224,7 @@ begin
224
224
  trace('IDENTIFIER an_ident_err')
225
225
  id_end = p
226
226
  chars = data[id_start...id_end]
227
- ast_node = identifier(utf8_string(chars), complete: false)
227
+ ast_node = identifier(utf8_string(chars), complete: false, character_range: [id_start, id_end])
228
228
  @buffers[:ident] = ast_node
229
229
  end
230
230
  when 6 then
@@ -233,7 +233,7 @@ begin
233
233
  trace('IDENTIFIER ident_node_err')
234
234
  id_end = p
235
235
  chars = data[id_start...id_end]
236
- ast_node = identifier(utf8_string(chars), complete: false)
236
+ ast_node = identifier(utf8_string(chars), complete: false, character_range: [id_start, id_end])
237
237
  yield ast_node
238
238
  end
239
239
  end
@@ -266,7 +266,7 @@ begin
266
266
  id_end = p
267
267
  chars = data[id_start...id_end]
268
268
  completed = !chars.empty?
269
- ast_node = identifier(utf8_string(chars), complete: completed)
269
+ ast_node = identifier(utf8_string(chars), complete: completed, character_range: [id_start, id_end])
270
270
  @buffers[:ident] = ast_node
271
271
  end
272
272
  begin
@@ -282,7 +282,7 @@ begin
282
282
  id_end = p
283
283
  chars = data[id_start...id_end]
284
284
  completed = !chars.empty?
285
- ast_node = identifier(utf8_string(chars), complete: completed)
285
+ ast_node = identifier(utf8_string(chars), complete: completed, character_range: [id_start, id_end])
286
286
  @buffers[:ident] = ast_node
287
287
  end
288
288
  end
@@ -315,7 +315,7 @@ begin
315
315
  id_end = p
316
316
  chars = data[id_start...id_end]
317
317
  completed = !chars.empty?
318
- ast_node = identifier(utf8_string(chars), complete: completed)
318
+ ast_node = identifier(utf8_string(chars), complete: completed, character_range: [id_start, id_end])
319
319
  @buffers[:ident] = ast_node
320
320
  end
321
321
  begin
@@ -325,7 +325,7 @@ begin
325
325
  id_end = p
326
326
  chars = data[id_start...id_end]
327
327
  completed = !chars.empty?
328
- ast_node = identifier(utf8_string(chars), complete: completed)
328
+ ast_node = identifier(utf8_string(chars), complete: completed, character_range: [id_start, id_end])
329
329
  @buffers[:ident] = ast_node
330
330
  end
331
331
  end
@@ -627,7 +627,7 @@ begin
627
627
  id_end = p
628
628
  chars = data[id_start...id_end]
629
629
  completed = !chars.empty?
630
- ast_node = identifier(utf8_string(chars), complete: completed)
630
+ ast_node = identifier(utf8_string(chars), complete: completed, character_range: [id_start, id_end])
631
631
  @buffers[:ident] = ast_node
632
632
  end
633
633
  when 3 then
@@ -636,7 +636,7 @@ begin
636
636
  trace('IDENTIFIER an_ident_err')
637
637
  id_end = p
638
638
  chars = data[id_start...id_end]
639
- ast_node = identifier(utf8_string(chars), complete: false)
639
+ ast_node = identifier(utf8_string(chars), complete: false, character_range: [id_start, id_end])
640
640
  @buffers[:ident] = ast_node
641
641
  end
642
642
  when 6 then
@@ -645,7 +645,7 @@ begin
645
645
  trace('IDENTIFIER ident_node_err')
646
646
  id_end = p
647
647
  chars = data[id_start...id_end]
648
- ast_node = identifier(utf8_string(chars), complete: false)
648
+ ast_node = identifier(utf8_string(chars), complete: false, character_range: [id_start, id_end])
649
649
  yield ast_node
650
650
  end
651
651
  end
@@ -678,7 +678,7 @@ begin
678
678
  id_end = p
679
679
  chars = data[id_start...id_end]
680
680
  completed = !chars.empty?
681
- ast_node = identifier(utf8_string(chars), complete: completed)
681
+ ast_node = identifier(utf8_string(chars), complete: completed, character_range: [id_start, id_end])
682
682
  @buffers[:ident] = ast_node
683
683
  end
684
684
  begin
@@ -694,7 +694,7 @@ begin
694
694
  id_end = p
695
695
  chars = data[id_start...id_end]
696
696
  completed = !chars.empty?
697
- ast_node = identifier(utf8_string(chars), complete: completed)
697
+ ast_node = identifier(utf8_string(chars), complete: completed, character_range: [id_start, id_end])
698
698
  @buffers[:ident] = ast_node
699
699
  end
700
700
  end
@@ -727,7 +727,7 @@ begin
727
727
  id_end = p
728
728
  chars = data[id_start...id_end]
729
729
  completed = !chars.empty?
730
- ast_node = identifier(utf8_string(chars), complete: completed)
730
+ ast_node = identifier(utf8_string(chars), complete: completed, character_range: [id_start, id_end])
731
731
  @buffers[:ident] = ast_node
732
732
  end
733
733
  begin
@@ -737,7 +737,7 @@ begin
737
737
  id_end = p
738
738
  chars = data[id_start...id_end]
739
739
  completed = !chars.empty?
740
- ast_node = identifier(utf8_string(chars), complete: completed)
740
+ ast_node = identifier(utf8_string(chars), complete: completed, character_range: [id_start, id_end])
741
741
  @buffers[:ident] = ast_node
742
742
  end
743
743
  end
@@ -3,6 +3,7 @@
3
3
  machine bel;
4
4
 
5
5
  NL = '\n';
6
+ ALL_BUT_NL = [^NL]+;
6
7
  SP = ' ' | '\t';
7
8
  WS = space;
8
9
  EQL = '=';
@@ -216,8 +216,8 @@ begin
216
216
  p_end = p
217
217
  chars = data[p_start...p_end]
218
218
  completed = !chars.empty?
219
- ident_node = identifier(utf8_string(chars), complete: completed)
220
- fx_node = function(ident_node, complete: ident_node.complete)
219
+ ident_node = identifier(utf8_string(chars), complete: completed, character_range: [p_start, p_end])
220
+ fx_node = function(ident_node, complete: ident_node.complete, character_range: ident_node.character_range)
221
221
  @buffers[:function] = fx_node
222
222
  end
223
223
  when 1 then
@@ -229,8 +229,8 @@ begin
229
229
  p_end = p + 1
230
230
  chars = data[p_start...p_end]
231
231
  completed = !chars.empty?
232
- ident_node = identifier(utf8_string(chars), complete: completed)
233
- fx_node = function(ident_node, complete: false)
232
+ ident_node = identifier(utf8_string(chars), complete: completed, character_range: [p_start, p_end])
233
+ fx_node = function(ident_node, complete: false, character_range: ident_node.character_range)
234
234
  @buffers[:function] = fx_node
235
235
  yield @buffers[:function]
236
236
  end
@@ -261,8 +261,8 @@ begin
261
261
  p_end = p + 1
262
262
  chars = data[p_start...p_end]
263
263
  completed = !chars.empty?
264
- ident_node = identifier(utf8_string(chars), complete: completed)
265
- fx_node = function(ident_node, complete: false)
264
+ ident_node = identifier(utf8_string(chars), complete: completed, character_range: [p_start, p_end])
265
+ fx_node = function(ident_node, complete: false, character_range: ident_node.character_range)
266
266
  @buffers[:function] = fx_node
267
267
  yield @buffers[:function]
268
268
  end
@@ -280,8 +280,8 @@ begin
280
280
  p_end = p
281
281
  chars = data[p_start...p_end]
282
282
  completed = !chars.empty?
283
- ident_node = identifier(utf8_string(chars), complete: completed)
284
- fx_node = function(ident_node, complete: ident_node.complete)
283
+ ident_node = identifier(utf8_string(chars), complete: completed, character_range: [p_start, p_end])
284
+ fx_node = function(ident_node, complete: ident_node.complete, character_range: ident_node.character_range)
285
285
  @buffers[:function] = fx_node
286
286
  end
287
287
  begin
@@ -16,8 +16,8 @@
16
16
  p_end = p
17
17
  chars = data[p_start...p_end]
18
18
  completed = !chars.empty?
19
- ident_node = identifier(utf8_string(chars), complete: completed)
20
- fx_node = function(ident_node, complete: ident_node.complete)
19
+ ident_node = identifier(utf8_string(chars), complete: completed, character_range: [p_start, p_end])
20
+ fx_node = function(ident_node, complete: ident_node.complete, character_range: ident_node.character_range)
21
21
  @buffers[:function] = fx_node
22
22
  }
23
23
 
@@ -27,8 +27,8 @@
27
27
  p_end = p
28
28
  chars = data[p_start...p_end]
29
29
  completed = !chars.empty?
30
- ident_node = identifier(utf8_string(chars), complete: completed)
31
- fx_node = function(ident_node, complete: ident_node.complete)
30
+ ident_node = identifier(utf8_string(chars), complete: completed, character_range: [p_start, p_end])
31
+ fx_node = function(ident_node, complete: ident_node.complete, character_range: ident_node.character_range)
32
32
  @buffers[:function] = fx_node
33
33
  end
34
34
  }
@@ -40,8 +40,8 @@
40
40
  p_end = p + 1
41
41
  chars = data[p_start...p_end]
42
42
  completed = !chars.empty?
43
- ident_node = identifier(utf8_string(chars), complete: completed)
44
- fx_node = function(ident_node, complete: false)
43
+ ident_node = identifier(utf8_string(chars), complete: completed, character_range: [p_start, p_end])
44
+ fx_node = function(ident_node, complete: false, character_range: ident_node.character_range)
45
45
  @buffers[:function] = fx_node
46
46
  yield @buffers[:function]
47
47
  end
@@ -213,7 +213,7 @@ begin
213
213
  id_end = p
214
214
  chars = data[id_start...id_end]
215
215
  completed = !chars.empty?
216
- ast_node = identifier(utf8_string(chars), complete: completed)
216
+ ast_node = identifier(utf8_string(chars), complete: completed, character_range: [id_start, id_end])
217
217
  @buffers[:ident] = ast_node
218
218
  end
219
219
  when 3 then
@@ -222,7 +222,7 @@ begin
222
222
  trace('IDENTIFIER ident_node_err')
223
223
  id_end = p
224
224
  chars = data[id_start...id_end]
225
- ast_node = identifier(utf8_string(chars), complete: false)
225
+ ast_node = identifier(utf8_string(chars), complete: false, character_range: [id_start, id_end])
226
226
  yield ast_node
227
227
  end
228
228
  end
@@ -255,7 +255,7 @@ begin
255
255
  id_end = p
256
256
  chars = data[id_start...id_end]
257
257
  completed = !chars.empty?
258
- ast_node = identifier(utf8_string(chars), complete: completed)
258
+ ast_node = identifier(utf8_string(chars), complete: completed, character_range: [id_start, id_end])
259
259
  @buffers[:ident] = ast_node
260
260
  end
261
261
  begin
@@ -16,7 +16,7 @@
16
16
  id_end = p
17
17
  chars = data[id_start...id_end]
18
18
  completed = !chars.empty?
19
- ast_node = identifier(utf8_string(chars), complete: completed)
19
+ ast_node = identifier(utf8_string(chars), complete: completed, character_range: [id_start, id_end])
20
20
  @buffers[:ident] = ast_node
21
21
  }
22
22
 
@@ -24,7 +24,7 @@
24
24
  trace('IDENTIFIER an_ident_err')
25
25
  id_end = p
26
26
  chars = data[id_start...id_end]
27
- ast_node = identifier(utf8_string(chars), complete: false)
27
+ ast_node = identifier(utf8_string(chars), complete: false, character_range: [id_start, id_end])
28
28
  @buffers[:ident] = ast_node
29
29
  }
30
30
 
@@ -32,7 +32,7 @@
32
32
  trace('IDENTIFIER ident_node_err')
33
33
  id_end = p
34
34
  chars = data[id_start...id_end]
35
- ast_node = identifier(utf8_string(chars), complete: false)
35
+ ast_node = identifier(utf8_string(chars), complete: false, character_range: [id_start, id_end])
36
36
  yield ast_node
37
37
  }
38
38
 
@@ -47,7 +47,7 @@
47
47
  id_end = p
48
48
  chars = data[id_start...id_end]
49
49
  completed = !chars.empty?
50
- ast_node = identifier(utf8_string(chars), complete: completed)
50
+ ast_node = identifier(utf8_string(chars), complete: completed, character_range: [id_start, id_end])
51
51
  @buffers[:ident] = ast_node
52
52
  end
53
53
  }