bel_parser 1.0.0.alpha.12 → 1.0.0.alpha.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gemspec +1 -1
- data/VERSION +1 -1
- data/bin/bel2_validator +35 -8
- data/lib/bel_parser/expression/validator.rb +3 -2
- data/lib/bel_parser/language/apply_namespace_encoding.rb +96 -0
- data/lib/bel_parser/language/base_specification.rb +82 -0
- data/lib/bel_parser/language/expression_validator.rb +6 -2
- data/lib/bel_parser/language/relationship.rb +1 -1
- data/lib/bel_parser/language/semantics/signature_mapping.rb +26 -32
- data/lib/bel_parser/language/semantics_ast.rb +285 -149
- data/lib/bel_parser/language/semantics_ast_warnings.rb +180 -0
- data/lib/bel_parser/language/semantics_result.rb +11 -2
- data/lib/bel_parser/language/semantics_type_warning.rb +22 -0
- data/lib/bel_parser/language/semantics_warning.rb +8 -0
- data/lib/bel_parser/language/specification.rb +38 -55
- data/lib/bel_parser/language/syntax/undefined_namespace_value.rb +43 -0
- data/lib/bel_parser/language/syntax_error.rb +8 -0
- data/lib/bel_parser/language/syntax_result.rb +8 -0
- data/lib/bel_parser/language/syntax_warning.rb +9 -4
- data/lib/bel_parser/language/version1_0/functions/abundance.rb +5 -6
- data/lib/bel_parser/language/version1_0/functions/biological_process.rb +5 -6
- data/lib/bel_parser/language/version1_0/functions/complex_abundance.rb +6 -7
- data/lib/bel_parser/language/version1_0/functions/fusion.rb +39 -60
- data/lib/bel_parser/language/version1_0/functions/gene_abundance.rb +9 -12
- data/lib/bel_parser/language/version1_0/functions/list.rb +5 -6
- data/lib/bel_parser/language/version1_0/functions/micro_rna_abundance.rb +5 -6
- data/lib/bel_parser/language/version1_0/functions/pathology.rb +5 -6
- data/lib/bel_parser/language/version1_0/functions/protein_abundance.rb +16 -30
- data/lib/bel_parser/language/version1_0/functions/protein_modification.rb +15 -27
- data/lib/bel_parser/language/version1_0/functions/rna_abundance.rb +8 -11
- data/lib/bel_parser/language/version1_0/functions/substitution.rb +6 -12
- data/lib/bel_parser/language/version1_0/functions/translocation.rb +9 -12
- data/lib/bel_parser/language/version1_0/functions/truncation.rb +2 -4
- data/lib/bel_parser/language/version1_0/value_encodings/abundance.rb +21 -0
- data/lib/bel_parser/language/version1_0/value_encodings/any.rb +74 -0
- data/lib/bel_parser/language/version1_0/value_encodings/biological_process.rb +21 -0
- data/lib/bel_parser/language/version1_0/value_encodings/complex_abundance.rb +21 -0
- data/lib/bel_parser/language/version1_0/value_encodings/gene_abundance.rb +21 -0
- data/lib/bel_parser/language/version1_0/value_encodings/micro_rna_abundance.rb +21 -0
- data/lib/bel_parser/language/version1_0/value_encodings/pathology.rb +21 -0
- data/lib/bel_parser/language/version1_0/value_encodings/protein_abundance.rb +21 -0
- data/lib/bel_parser/language/version1_0/value_encodings/rna_abundance.rb +21 -0
- data/lib/bel_parser/language/version1_0.rb +6 -87
- data/lib/bel_parser/language/version2_0/functions/abundance.rb +13 -18
- data/lib/bel_parser/language/version2_0/functions/biological_process.rb +5 -6
- data/lib/bel_parser/language/version2_0/functions/complex_abundance.rb +9 -12
- data/lib/bel_parser/language/version2_0/functions/fragment.rb +4 -9
- data/lib/bel_parser/language/version2_0/functions/from_location.rb +5 -6
- data/lib/bel_parser/language/version2_0/functions/fusion.rb +39 -66
- data/lib/bel_parser/language/version2_0/functions/gene_abundance.rb +13 -18
- data/lib/bel_parser/language/version2_0/functions/list.rb +5 -6
- data/lib/bel_parser/language/version2_0/functions/location.rb +5 -6
- data/lib/bel_parser/language/version2_0/functions/micro_rna_abundance.rb +13 -18
- data/lib/bel_parser/language/version2_0/functions/molecular_activity.rb +6 -5
- data/lib/bel_parser/language/version2_0/functions/pathology.rb +5 -6
- data/lib/bel_parser/language/version2_0/functions/protein_abundance.rb +21 -30
- data/lib/bel_parser/language/version2_0/functions/protein_modification.rb +11 -17
- data/lib/bel_parser/language/version2_0/functions/rna_abundance.rb +13 -18
- data/lib/bel_parser/language/version2_0/functions/to_location.rb +5 -6
- data/lib/bel_parser/language/version2_0/functions/variant.rb +1 -4
- data/lib/bel_parser/language/version2_0/value_encodings/abundance.rb +21 -0
- data/lib/bel_parser/language/version2_0/value_encodings/activity.rb +21 -0
- data/lib/bel_parser/language/version2_0/value_encodings/any.rb +74 -0
- data/lib/bel_parser/language/version2_0/value_encodings/biological_process.rb +21 -0
- data/lib/bel_parser/language/version2_0/value_encodings/complex_abundance.rb +21 -0
- data/lib/bel_parser/language/version2_0/value_encodings/gene_abundance.rb +21 -0
- data/lib/bel_parser/language/version2_0/value_encodings/location.rb +21 -0
- data/lib/bel_parser/language/version2_0/value_encodings/micro_rna_abundance.rb +21 -0
- data/lib/bel_parser/language/version2_0/value_encodings/pathology.rb +21 -0
- data/lib/bel_parser/language/version2_0/value_encodings/protein_abundance.rb +21 -0
- data/lib/bel_parser/language/version2_0/value_encodings/protein_modification.rb +21 -0
- data/lib/bel_parser/language/version2_0/value_encodings/rna_abundance.rb +21 -0
- data/lib/bel_parser/language/version2_0.rb +6 -60
- data/lib/bel_parser/language.rb +3 -4
- data/lib/bel_parser/parsers/ast/node.rb +14 -2
- data/lib/bel_parser/{language/quoting.rb → quoting.rb} +0 -56
- data/lib/bel_parser/resource/concept.rb +56 -0
- data/lib/bel_parser/resource/concept_scheme.rb +35 -0
- data/lib/bel_parser/resource/dataset.rb +34 -0
- data/lib/bel_parser/resource/eager_reader.rb +75 -0
- data/lib/bel_parser/resource/eager_sparql_reader.rb +51 -0
- data/lib/bel_parser/resource/http_cache.rb +71 -0
- data/lib/bel_parser/resource/jena_tdb_reader.rb +246 -0
- data/lib/bel_parser/resource/lru_cache.rb +111 -0
- data/lib/bel_parser/resource/lru_reader.rb +38 -0
- data/lib/bel_parser/resource/reader.rb +18 -0
- data/lib/bel_parser/resource/resource_file_reader.rb +134 -0
- data/lib/bel_parser/resource/sparql_reader.rb +178 -0
- data/lib/bel_parser/resource/value.rb +31 -0
- metadata +42 -4
- data/lib/bel_parser/language/version1_0/syntax/function.rb +0 -28
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
require 'bel_parser/quoting'
|
|
1
2
|
require_relative 'semantics_match'
|
|
2
|
-
require_relative '
|
|
3
|
+
require_relative 'semantics_result'
|
|
4
|
+
require_relative 'semantics_ast_warnings'
|
|
3
5
|
require_relative '../parsers/ast/node'
|
|
4
6
|
|
|
5
7
|
module BELParser
|
|
@@ -109,16 +111,12 @@ module BELParser
|
|
|
109
111
|
SemanticIdentifier.new(value_patterns, **properties)
|
|
110
112
|
end
|
|
111
113
|
|
|
112
|
-
def prefix(
|
|
113
|
-
SemanticPrefix.new(
|
|
114
|
+
def prefix(*prefix_patterns, **properties)
|
|
115
|
+
SemanticPrefix.new(prefix_patterns, **properties)
|
|
114
116
|
end
|
|
115
117
|
|
|
116
|
-
def value(
|
|
117
|
-
SemanticValue.new(
|
|
118
|
-
end
|
|
119
|
-
|
|
120
|
-
def value_type(*value_patterns, **properties)
|
|
121
|
-
SemanticValueType.new(value_patterns, **properties)
|
|
118
|
+
def value(*value_patterns, **properties)
|
|
119
|
+
SemanticValue.new(value_patterns, **properties)
|
|
122
120
|
end
|
|
123
121
|
|
|
124
122
|
def any(**properties)
|
|
@@ -199,12 +197,64 @@ module BELParser
|
|
|
199
197
|
end
|
|
200
198
|
end
|
|
201
199
|
|
|
202
|
-
def success(node)
|
|
203
|
-
[
|
|
200
|
+
def success(node, spec)
|
|
201
|
+
[SemanticsResult.new(node, spec)]
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
def nil_node_warning(node, spec, expected)
|
|
205
|
+
[SemanticsNilNodeWarning.new(node, spec, expected)]
|
|
206
|
+
end
|
|
207
|
+
|
|
208
|
+
def not_nil_node_warning(node, spec)
|
|
209
|
+
[SemanticsNotNilNodeWarning.new(node, spec)]
|
|
210
|
+
end
|
|
211
|
+
|
|
212
|
+
def type_warning(node, spec, expected, actual)
|
|
213
|
+
[SemanticsTypeWarning.new(node, spec, expected, actual)]
|
|
214
|
+
end
|
|
215
|
+
|
|
216
|
+
def argument_length_warning(node, spec, expected, actual)
|
|
217
|
+
[SemanticsArgumentLengthWarning.new(node, spec, expected, actual)]
|
|
218
|
+
end
|
|
219
|
+
|
|
220
|
+
def missing_namespace_warning(node, spec)
|
|
221
|
+
[SemanticsMissingNamespaceWarning.new(node, spec)]
|
|
222
|
+
end
|
|
223
|
+
|
|
224
|
+
def invalid_namespace(node, spec, expected)
|
|
225
|
+
[SemanticsInvalidNamespaceWarning.new(node, spec, expected)]
|
|
226
|
+
end
|
|
227
|
+
|
|
228
|
+
def missing_encoding_warning(node, spec)
|
|
229
|
+
[SemanticsMissingEncodingWarning.new(node, spec)]
|
|
230
|
+
end
|
|
231
|
+
|
|
232
|
+
def invalid_encoding_warning(node, spec, expected)
|
|
233
|
+
[SemanticsInvalidEncodingWarning.new(node, spec, expected)]
|
|
234
|
+
end
|
|
235
|
+
|
|
236
|
+
def invalid_function_warning(node, spec, expected)
|
|
237
|
+
[SemanticsInvalidFunctionWarning.new(node, spec, expected)]
|
|
238
|
+
end
|
|
239
|
+
|
|
240
|
+
def invalid_return_type_warning(node, spec, expected)
|
|
241
|
+
[SemanticsInvalidReturnTypeWarning.new(node, spec, expected)]
|
|
242
|
+
end
|
|
243
|
+
|
|
244
|
+
def invalid_protein_modification_warning(node, spec, expected)
|
|
245
|
+
[SemanticsInvalidProteinModificationWarning.new(node, spec, expected)]
|
|
246
|
+
end
|
|
247
|
+
|
|
248
|
+
def invalid_amino_acid_warning(node, spec, expected)
|
|
249
|
+
[SemanticsInvalidAminoAcidWarning.new(node, spec, expected)]
|
|
250
|
+
end
|
|
251
|
+
|
|
252
|
+
def invalid_amino_acid_range_warning(node, spec)
|
|
253
|
+
[SemanticsInvalidAminoAcidRangeWarning.new(node, spec)]
|
|
204
254
|
end
|
|
205
255
|
|
|
206
|
-
def
|
|
207
|
-
[
|
|
256
|
+
def invalid_sequence_position_warning(node, spec)
|
|
257
|
+
[SemanticsInvalidSequencePositionWarning.new(node, spec)]
|
|
208
258
|
end
|
|
209
259
|
end
|
|
210
260
|
|
|
@@ -226,18 +276,29 @@ module BELParser
|
|
|
226
276
|
children[1..-1]
|
|
227
277
|
end
|
|
228
278
|
|
|
229
|
-
def match(parse_node,
|
|
230
|
-
return
|
|
231
|
-
|
|
279
|
+
def match(parse_node, spec)
|
|
280
|
+
return nil_node_warning(
|
|
281
|
+
parse_node,
|
|
282
|
+
spec,
|
|
283
|
+
BELParser::Parsers::AST::Term) if parse_node.nil?
|
|
284
|
+
return type_warning(
|
|
285
|
+
parse_node,
|
|
286
|
+
spec,
|
|
287
|
+
BELParser::Parsers::AST::Term,
|
|
288
|
+
parse_node) if parse_node.type != type
|
|
232
289
|
|
|
233
290
|
# Return success if semantic AST does not supply argument patterns.
|
|
234
291
|
if arguments.empty? || variadic_arguments?
|
|
235
|
-
success(parse_node)
|
|
292
|
+
success(parse_node, spec)
|
|
236
293
|
# Or, check argument length.
|
|
237
294
|
elsif arguments.length == parse_node.arguments.length
|
|
238
|
-
success(parse_node)
|
|
295
|
+
success(parse_node, spec)
|
|
239
296
|
else
|
|
240
|
-
|
|
297
|
+
argument_length_warning(
|
|
298
|
+
parse_node,
|
|
299
|
+
spec,
|
|
300
|
+
self,
|
|
301
|
+
parse_node)
|
|
241
302
|
end
|
|
242
303
|
end
|
|
243
304
|
end
|
|
@@ -248,8 +309,21 @@ module BELParser
|
|
|
248
309
|
super(:statement, children, properties)
|
|
249
310
|
end
|
|
250
311
|
|
|
251
|
-
def match(parse_node,
|
|
252
|
-
|
|
312
|
+
def match(parse_node, spec)
|
|
313
|
+
return nil_node_warning(
|
|
314
|
+
parse_node,
|
|
315
|
+
spec,
|
|
316
|
+
BELParser::Parsers::AST::Statement) if parse_node.nil?
|
|
317
|
+
|
|
318
|
+
if parse_node.type == type
|
|
319
|
+
success(parse_node, spec)
|
|
320
|
+
else
|
|
321
|
+
type_warning(
|
|
322
|
+
parse_node,
|
|
323
|
+
spec,
|
|
324
|
+
BELParser::Parsers::AST::Statement,
|
|
325
|
+
parse_node)
|
|
326
|
+
end
|
|
253
327
|
end
|
|
254
328
|
end
|
|
255
329
|
|
|
@@ -259,8 +333,21 @@ module BELParser
|
|
|
259
333
|
super(:parameter, children, properties)
|
|
260
334
|
end
|
|
261
335
|
|
|
262
|
-
def match(parse_node,
|
|
263
|
-
|
|
336
|
+
def match(parse_node, spec)
|
|
337
|
+
return nil_node_warning(
|
|
338
|
+
parse_node,
|
|
339
|
+
spec,
|
|
340
|
+
BELParser::Parsers::AST::Parameter) if parse_node.nil?
|
|
341
|
+
|
|
342
|
+
if parse_node.type == type
|
|
343
|
+
success(parse_node, spec)
|
|
344
|
+
else
|
|
345
|
+
type_warning(
|
|
346
|
+
parse_node,
|
|
347
|
+
spec,
|
|
348
|
+
BELParser::Parsers::AST::Parameter,
|
|
349
|
+
parse_node)
|
|
350
|
+
end
|
|
264
351
|
end
|
|
265
352
|
end
|
|
266
353
|
|
|
@@ -270,8 +357,21 @@ module BELParser
|
|
|
270
357
|
super(:function, children, properties)
|
|
271
358
|
end
|
|
272
359
|
|
|
273
|
-
def match(parse_node,
|
|
274
|
-
|
|
360
|
+
def match(parse_node, spec)
|
|
361
|
+
return nil_node_warning(
|
|
362
|
+
parse_node,
|
|
363
|
+
spec,
|
|
364
|
+
BELParser::Parsers::AST::Function) if parse_node.nil?
|
|
365
|
+
|
|
366
|
+
if parse_node.type == type
|
|
367
|
+
success(parse_node, spec)
|
|
368
|
+
else
|
|
369
|
+
type_warning(
|
|
370
|
+
parse_node,
|
|
371
|
+
spec,
|
|
372
|
+
BELParser::Parsers::AST::Function,
|
|
373
|
+
parse_node)
|
|
374
|
+
end
|
|
275
375
|
end
|
|
276
376
|
end
|
|
277
377
|
|
|
@@ -281,9 +381,21 @@ module BELParser
|
|
|
281
381
|
super(:argument, children, properties)
|
|
282
382
|
end
|
|
283
383
|
|
|
284
|
-
def match(parse_node,
|
|
285
|
-
return
|
|
286
|
-
|
|
384
|
+
def match(parse_node, spec)
|
|
385
|
+
return nil_node_warning(
|
|
386
|
+
parse_node,
|
|
387
|
+
spec,
|
|
388
|
+
BELParser::Parsers::AST::Argument) if parse_node.nil?
|
|
389
|
+
|
|
390
|
+
if parse_node.type == type
|
|
391
|
+
success(parse_node, spec)
|
|
392
|
+
else
|
|
393
|
+
type_warning(
|
|
394
|
+
parse_node,
|
|
395
|
+
spec,
|
|
396
|
+
BELParser::Parsers::AST::Argument,
|
|
397
|
+
parse_node)
|
|
398
|
+
end
|
|
287
399
|
end
|
|
288
400
|
end
|
|
289
401
|
|
|
@@ -293,11 +405,20 @@ module BELParser
|
|
|
293
405
|
super(:variadic_arguments, children, properties)
|
|
294
406
|
end
|
|
295
407
|
|
|
296
|
-
def match(parse_node,
|
|
408
|
+
def match(parse_node, spec)
|
|
409
|
+
return nil_node_warning(
|
|
410
|
+
parse_node,
|
|
411
|
+
spec,
|
|
412
|
+
BELParser::Parsers::AST::Argument) if parse_node.nil?
|
|
413
|
+
|
|
297
414
|
if parse_node.type == BELParser::Parsers::AST::Argument.ast_type
|
|
298
|
-
success(parse_node)
|
|
415
|
+
success(parse_node, spec)
|
|
299
416
|
else
|
|
300
|
-
|
|
417
|
+
type_warning(
|
|
418
|
+
parse_node,
|
|
419
|
+
spec,
|
|
420
|
+
BELParser::Parsers::AST::Argument,
|
|
421
|
+
parse_node)
|
|
301
422
|
end
|
|
302
423
|
end
|
|
303
424
|
end
|
|
@@ -308,8 +429,31 @@ module BELParser
|
|
|
308
429
|
super(:prefix, children, properties)
|
|
309
430
|
end
|
|
310
431
|
|
|
311
|
-
def
|
|
312
|
-
|
|
432
|
+
def terminal?
|
|
433
|
+
true
|
|
434
|
+
end
|
|
435
|
+
|
|
436
|
+
def prefix_patterns
|
|
437
|
+
children
|
|
438
|
+
end
|
|
439
|
+
|
|
440
|
+
def match(parse_node, spec)
|
|
441
|
+
return nil_node_warning(
|
|
442
|
+
parse_node,
|
|
443
|
+
spec,
|
|
444
|
+
BELParser::Parsers::AST::Prefix) if parse_node.nil?
|
|
445
|
+
|
|
446
|
+
if parse_node.type != BELParser::Parsers::AST::Prefix.ast_type
|
|
447
|
+
return type_warning(
|
|
448
|
+
parse_node,
|
|
449
|
+
spec,
|
|
450
|
+
BELParser::Parsers::AST::Prefix,
|
|
451
|
+
parse_node)
|
|
452
|
+
end
|
|
453
|
+
|
|
454
|
+
prefix_patterns.map do |pattern|
|
|
455
|
+
pattern.match(parse_node, spec)
|
|
456
|
+
end
|
|
313
457
|
end
|
|
314
458
|
end
|
|
315
459
|
|
|
@@ -319,8 +463,31 @@ module BELParser
|
|
|
319
463
|
super(:value, children, properties)
|
|
320
464
|
end
|
|
321
465
|
|
|
322
|
-
def
|
|
323
|
-
|
|
466
|
+
def terminal?
|
|
467
|
+
true
|
|
468
|
+
end
|
|
469
|
+
|
|
470
|
+
def value_patterns
|
|
471
|
+
children
|
|
472
|
+
end
|
|
473
|
+
|
|
474
|
+
def match(parse_node, spec)
|
|
475
|
+
return nil_node_warning(
|
|
476
|
+
parse_node,
|
|
477
|
+
spec,
|
|
478
|
+
BELParser::Parsers::AST::Value) if parse_node.nil?
|
|
479
|
+
|
|
480
|
+
if parse_node.type != BELParser::Parsers::AST::Value.ast_type
|
|
481
|
+
return type_warning(
|
|
482
|
+
parse_node,
|
|
483
|
+
spec,
|
|
484
|
+
BELParser::Parsers::AST::Value,
|
|
485
|
+
parse_node)
|
|
486
|
+
end
|
|
487
|
+
|
|
488
|
+
value_patterns.map do |pattern|
|
|
489
|
+
pattern.match(parse_node, spec)
|
|
490
|
+
end
|
|
324
491
|
end
|
|
325
492
|
end
|
|
326
493
|
|
|
@@ -334,8 +501,12 @@ module BELParser
|
|
|
334
501
|
true
|
|
335
502
|
end
|
|
336
503
|
|
|
337
|
-
def match(parse_node,
|
|
338
|
-
parse_node.nil?
|
|
504
|
+
def match(parse_node, spec)
|
|
505
|
+
if parse_node.nil?
|
|
506
|
+
success(parse_node, spec)
|
|
507
|
+
else
|
|
508
|
+
not_nil_node_warning(parse_node, spec)
|
|
509
|
+
end
|
|
339
510
|
end
|
|
340
511
|
end
|
|
341
512
|
|
|
@@ -354,22 +525,19 @@ module BELParser
|
|
|
354
525
|
end
|
|
355
526
|
|
|
356
527
|
def match(identifier, spec)
|
|
357
|
-
return
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
528
|
+
return nil_node_warning(
|
|
529
|
+
identifier,
|
|
530
|
+
spec,
|
|
531
|
+
BELParser::Parsers::AST::Identifier) if identifier.nil?
|
|
532
|
+
|
|
533
|
+
if identifier.type != BELParser::Parsers::AST::Identifier.ast_type
|
|
534
|
+
return type_warning(
|
|
535
|
+
identifier,
|
|
536
|
+
spec,
|
|
537
|
+
BELParser::Parsers::AST::Identifier,
|
|
538
|
+
identifier)
|
|
367
539
|
end
|
|
368
|
-
end
|
|
369
|
-
|
|
370
|
-
private
|
|
371
540
|
|
|
372
|
-
def match_value_patterns(identifier, spec)
|
|
373
541
|
value_patterns.map { |pattern| pattern.match(identifier, spec) }
|
|
374
542
|
end
|
|
375
543
|
end
|
|
@@ -380,8 +548,8 @@ module BELParser
|
|
|
380
548
|
super(:any, [], properties)
|
|
381
549
|
end
|
|
382
550
|
|
|
383
|
-
def match(parse_node,
|
|
384
|
-
success(parse_node)
|
|
551
|
+
def match(parse_node, spec)
|
|
552
|
+
success(parse_node, spec)
|
|
385
553
|
end
|
|
386
554
|
end
|
|
387
555
|
|
|
@@ -391,13 +559,11 @@ module BELParser
|
|
|
391
559
|
super(:has_namespace, [], properties)
|
|
392
560
|
end
|
|
393
561
|
|
|
394
|
-
def match(
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
if identifier.respond_to?(:namespace)
|
|
398
|
-
success(identifier)
|
|
562
|
+
def match(prefix, spec)
|
|
563
|
+
if prefix.respond_to?(:namespace) && prefix.namespace
|
|
564
|
+
success(prefix, spec)
|
|
399
565
|
else
|
|
400
|
-
|
|
566
|
+
missing_namespace_warning(prefix, spec)
|
|
401
567
|
end
|
|
402
568
|
end
|
|
403
569
|
end
|
|
@@ -408,18 +574,19 @@ module BELParser
|
|
|
408
574
|
super(:namespace_of, namespaces, properties)
|
|
409
575
|
end
|
|
410
576
|
|
|
411
|
-
def
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
return failure(identifier) unless identifier.respond_to?(:namespace)
|
|
415
|
-
input_namespace = identifier.namespace
|
|
416
|
-
return failure(identifier) if input_namespace.nil?
|
|
577
|
+
def namespaces
|
|
578
|
+
children
|
|
579
|
+
end
|
|
417
580
|
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
581
|
+
def match(prefix_node, spec)
|
|
582
|
+
unless prefix_node.respond_to?(:namespace) && prefix_node.namespace
|
|
583
|
+
return invalid_namespace(prefix_node, spec, namespaces)
|
|
584
|
+
end
|
|
585
|
+
|
|
586
|
+
if namespaces.any? { |i| i == :* || i == input_namespace }
|
|
587
|
+
success(prefix_node, spec)
|
|
421
588
|
else
|
|
422
|
-
|
|
589
|
+
invalid_namespace(prefix_node, spec, namespaces)
|
|
423
590
|
end
|
|
424
591
|
end
|
|
425
592
|
end
|
|
@@ -430,13 +597,11 @@ module BELParser
|
|
|
430
597
|
super(:has_encoding, [], properties)
|
|
431
598
|
end
|
|
432
599
|
|
|
433
|
-
def match(
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
if value_type.respond_to?(:encoding)
|
|
437
|
-
success(value_type)
|
|
600
|
+
def match(value_node, spec)
|
|
601
|
+
if value_node.respond_to?(:encoding) && value_node.encoding
|
|
602
|
+
success(value_node, spec)
|
|
438
603
|
else
|
|
439
|
-
|
|
604
|
+
missing_encoding_warning(value_node, spec)
|
|
440
605
|
end
|
|
441
606
|
end
|
|
442
607
|
end
|
|
@@ -447,21 +612,25 @@ module BELParser
|
|
|
447
612
|
super(:encoding_of, encodings, properties)
|
|
448
613
|
end
|
|
449
614
|
|
|
450
|
-
def
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
encoding_set = children
|
|
454
|
-
return success(value_type) if encoding_set.include?(:*)
|
|
615
|
+
def match_encoding
|
|
616
|
+
children
|
|
617
|
+
end
|
|
455
618
|
|
|
456
|
-
|
|
619
|
+
def match(value_node, spec)
|
|
620
|
+
unless value_node.respond_to?(:encoding) && value_node.encoding
|
|
621
|
+
return invalid_encoding_warning(value_node, spec, match_encoding)
|
|
622
|
+
end
|
|
457
623
|
|
|
458
|
-
|
|
459
|
-
|
|
624
|
+
input = value_node.encoding
|
|
625
|
+
match = match_encoding
|
|
626
|
+
enc_match = input.product(match).any? do |(value_enc, match_enc)|
|
|
627
|
+
value_enc.subtype_of?(match_enc)
|
|
628
|
+
end
|
|
460
629
|
|
|
461
|
-
if
|
|
462
|
-
success(
|
|
630
|
+
if enc_match
|
|
631
|
+
success(value_node, spec)
|
|
463
632
|
else
|
|
464
|
-
|
|
633
|
+
invalid_encoding_warning(value_node, spec, match_encoding)
|
|
465
634
|
end
|
|
466
635
|
end
|
|
467
636
|
end
|
|
@@ -477,13 +646,13 @@ module BELParser
|
|
|
477
646
|
end
|
|
478
647
|
|
|
479
648
|
def match(identifier, spec)
|
|
480
|
-
return success(identifier) if functions.include?(:*)
|
|
649
|
+
return success(identifier, spec) if functions.include?(:*)
|
|
481
650
|
|
|
482
|
-
function = spec.function(identifier.
|
|
651
|
+
function = spec.function(identifier.string_literal.to_sym)
|
|
483
652
|
if functions.include?(function)
|
|
484
|
-
success(identifier)
|
|
653
|
+
success(identifier, spec)
|
|
485
654
|
else
|
|
486
|
-
|
|
655
|
+
invalid_function_warning(identifier, spec, functions)
|
|
487
656
|
end
|
|
488
657
|
end
|
|
489
658
|
end
|
|
@@ -499,49 +668,13 @@ module BELParser
|
|
|
499
668
|
end
|
|
500
669
|
|
|
501
670
|
def match(identifier, spec)
|
|
502
|
-
return success(identifier) if return_types.include?(:*)
|
|
503
|
-
|
|
504
|
-
fx_return = spec.function(identifier.children[0].to_sym).return_type
|
|
505
|
-
if return_types.any? { |rt| fx_return <= rt }
|
|
506
|
-
success(identifier)
|
|
507
|
-
else
|
|
508
|
-
failure(identifier)
|
|
509
|
-
end
|
|
510
|
-
end
|
|
511
|
-
end
|
|
512
|
-
|
|
513
|
-
# AST node for ValueType is a semantic AST.
|
|
514
|
-
class SemanticValueType < SemanticASTNode
|
|
515
|
-
TYPES = [
|
|
516
|
-
BELParser::Parsers::AST::Identifier.ast_type,
|
|
517
|
-
BELParser::Parsers::AST::String.ast_type
|
|
518
|
-
].freeze
|
|
519
|
-
|
|
520
|
-
def initialize(children = [], **properties)
|
|
521
|
-
super(:value_type, children, properties)
|
|
522
|
-
end
|
|
523
|
-
|
|
524
|
-
def terminal?
|
|
525
|
-
true
|
|
526
|
-
end
|
|
527
|
-
|
|
528
|
-
def value_patterns
|
|
529
|
-
children
|
|
530
|
-
end
|
|
531
|
-
|
|
532
|
-
def match(value_type, spec)
|
|
533
|
-
return failure(value_type) unless TYPES.include?(value_type.type)
|
|
534
|
-
|
|
535
|
-
value_results = value_patterns.map do |pattern|
|
|
536
|
-
pattern.match(value_type, spec)
|
|
537
|
-
end
|
|
538
|
-
|
|
539
|
-
failure_result = value_results.flatten.find(&:failure?)
|
|
671
|
+
return success(identifier, spec) if return_types.include?(:*)
|
|
540
672
|
|
|
541
|
-
|
|
542
|
-
|
|
673
|
+
fxret = spec.function(identifier.string_literal.to_sym).return_type
|
|
674
|
+
if return_types.any? { |rt| fxret <= rt }
|
|
675
|
+
success(identifier, spec)
|
|
543
676
|
else
|
|
544
|
-
|
|
677
|
+
invalid_return_type_warning(identifier, spec, return_types)
|
|
545
678
|
end
|
|
546
679
|
end
|
|
547
680
|
end
|
|
@@ -557,14 +690,17 @@ module BELParser
|
|
|
557
690
|
children
|
|
558
691
|
end
|
|
559
692
|
|
|
560
|
-
def match(
|
|
561
|
-
string_literal_sym =
|
|
562
|
-
return success(
|
|
693
|
+
def match(value_node, spec)
|
|
694
|
+
string_literal_sym = value_node.children[0].string_literal.to_sym
|
|
695
|
+
return success(value_node, spec) if @hashed[:*]
|
|
563
696
|
|
|
564
697
|
if @hashed.key?(string_literal_sym)
|
|
565
|
-
success(
|
|
698
|
+
success(value_node, spec)
|
|
566
699
|
else
|
|
567
|
-
|
|
700
|
+
invalid_protein_modification_warning(
|
|
701
|
+
value_node,
|
|
702
|
+
spec,
|
|
703
|
+
@hashed.keys)
|
|
568
704
|
end
|
|
569
705
|
end
|
|
570
706
|
end
|
|
@@ -580,14 +716,14 @@ module BELParser
|
|
|
580
716
|
children
|
|
581
717
|
end
|
|
582
718
|
|
|
583
|
-
def match(
|
|
584
|
-
string_literal_sym =
|
|
585
|
-
return success(
|
|
719
|
+
def match(value_node, spec)
|
|
720
|
+
string_literal_sym = value_node.children[0].to_sym
|
|
721
|
+
return success(value_node, spec) if @hashed[:*]
|
|
586
722
|
|
|
587
723
|
if @hashed.key?(string_literal_sym)
|
|
588
|
-
success(
|
|
724
|
+
success(value_node, spec)
|
|
589
725
|
else
|
|
590
|
-
|
|
726
|
+
invalid_amino_acid_warning(value_node, spec, @hashed.keys)
|
|
591
727
|
end
|
|
592
728
|
end
|
|
593
729
|
end
|
|
@@ -604,13 +740,13 @@ module BELParser
|
|
|
604
740
|
super(:is_amino_acid_range, [], properties)
|
|
605
741
|
end
|
|
606
742
|
|
|
607
|
-
def match(
|
|
608
|
-
string_literal = unquote(
|
|
743
|
+
def match(value_node, spec)
|
|
744
|
+
string_literal = unquote(value_node.children[0])
|
|
609
745
|
case string_literal
|
|
610
746
|
when START_STOP, UNDETERMINED, UNKNOWN_START_STOP
|
|
611
|
-
success(
|
|
747
|
+
success(value_node, spec)
|
|
612
748
|
else
|
|
613
|
-
|
|
749
|
+
invalid_amino_acid_range_warning(value_node, spec)
|
|
614
750
|
end
|
|
615
751
|
end
|
|
616
752
|
end
|
|
@@ -623,8 +759,8 @@ module BELParser
|
|
|
623
759
|
super(:is_sequence_position, [], properties)
|
|
624
760
|
end
|
|
625
761
|
|
|
626
|
-
def match(
|
|
627
|
-
string_literal = unquote(
|
|
762
|
+
def match(value_node, spec)
|
|
763
|
+
string_literal = unquote(value_node.string_literal)
|
|
628
764
|
integer_position =
|
|
629
765
|
begin
|
|
630
766
|
Integer(string_literal)
|
|
@@ -632,9 +768,9 @@ module BELParser
|
|
|
632
768
|
nil
|
|
633
769
|
end
|
|
634
770
|
if integer_position && integer_position > 0
|
|
635
|
-
success(
|
|
771
|
+
success(value_node, spec)
|
|
636
772
|
else
|
|
637
|
-
|
|
773
|
+
invalid_sequence_position_warning(value_node, spec)
|
|
638
774
|
end
|
|
639
775
|
end
|
|
640
776
|
end
|