bel_parser 1.0.0.alpha.10 → 1.0.0.alpha.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/bin/bel2_validator +9 -2
- data/lib/bel_parser/ast_generator.rb +1 -1
- data/lib/bel_parser/expression/validator.rb +19 -8
- data/lib/bel_parser/language/amino_acid.rb +2 -2
- data/lib/bel_parser/language/semantics/multiple_subject_object.rb +2 -2
- data/lib/bel_parser/language/semantics/non_object_list.rb +1 -1
- data/lib/bel_parser/language/semantics/relationship_deprecation.rb +1 -0
- data/lib/bel_parser/language/semantics_ast.rb +32 -6
- data/lib/bel_parser/language/version1_0/functions/fusion.rb +6 -6
- data/lib/bel_parser/language/version1_0/functions/protein_modification.rb +1 -1
- data/lib/bel_parser/language/version1_0/functions/substitution.rb +1 -1
- data/lib/bel_parser/language/version1_0/functions/truncation.rb +1 -1
- data/lib/bel_parser/language/version2_0/functions/protein_modification.rb +1 -1
- data/lib/bel_parser/parsers/ast/node.rb +4 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 102eb6c434bb351a77b6c48cb79819b4bbd6c02d
|
4
|
+
data.tar.gz: a018453c3f5a83b1ec952460c58462f9086b05c5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fe0528010d3ad24d9afa719bf8509965b5f9ee447049d67a27ca412b96d5781a8ba54de98d100a710648e60120a3195e2d7531ac0d332f7aa7d0a6d2d8d3b658
|
7
|
+
data.tar.gz: d85096c8ffacc3b2887b43907949c36c155d26a925f7fa41e0ccee3138c902858be4898e9689d67c4db3c18e2e4d84b5d5b90df6cdb379718d7358571d7382f3
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.0.alpha.
|
1
|
+
1.0.0.alpha.11
|
data/bin/bel2_validator
CHANGED
@@ -15,6 +15,13 @@ require 'bel_parser'
|
|
15
15
|
require 'bel_parser/expression/validator'
|
16
16
|
BELParser::Expression::Validator
|
17
17
|
.new(ARGV.first, namespaces)
|
18
|
-
.each($stdin) do |
|
19
|
-
puts
|
18
|
+
.each($stdin) do |(line_number, line, ast, messages)|
|
19
|
+
puts "#{line_number}: #{line}"
|
20
|
+
puts " AST Type: #{ast.type}"
|
21
|
+
puts messages
|
22
|
+
.map { |r| "#{r}\n" }
|
23
|
+
.join
|
24
|
+
.each_line
|
25
|
+
.map { |l| " #{l}" }
|
26
|
+
.join
|
20
27
|
end
|
@@ -20,15 +20,17 @@ module BELParser
|
|
20
20
|
|
21
21
|
def initialize(specification_version, namespaces)
|
22
22
|
@spec = BELParser::Language.specification(specification_version)
|
23
|
-
@validator = BELParser::Language::ExpressionValidator.new(
|
23
|
+
@validator = BELParser::Language::ExpressionValidator.new(
|
24
|
+
@spec, namespaces)
|
24
25
|
end
|
25
26
|
|
26
27
|
def each(io)
|
27
28
|
if block_given?
|
28
29
|
filtered_ast = FILTER.each(BELParser::ASTGenerator.new.each(io))
|
29
|
-
filtered_ast.each do |
|
30
|
-
|
31
|
-
|
30
|
+
filtered_ast.each do |(line_number, line, ast_results)|
|
31
|
+
ast_results.each do |ast|
|
32
|
+
yield [line_number, line, ast, @validator.validate(ast)]
|
33
|
+
end
|
32
34
|
end
|
33
35
|
else
|
34
36
|
enum_for(:each, io)
|
@@ -46,8 +48,17 @@ if __FILE__ == $PROGRAM_NAME
|
|
46
48
|
USAGE
|
47
49
|
exit 1
|
48
50
|
end
|
49
|
-
|
50
|
-
BELParser::Expression::Validator
|
51
|
-
|
52
|
-
|
51
|
+
namespaces = Hash[ARGV[1..-1].map { |ns| ns.split('=') }]
|
52
|
+
BELParser::Expression::Validator
|
53
|
+
.new(ARGV.first, namespaces)
|
54
|
+
.each($stdin) do |(line_number, line, ast, messages)|
|
55
|
+
puts "#{line_number}: #{line}"
|
56
|
+
puts " AST Type: #{ast.type}"
|
57
|
+
puts messages
|
58
|
+
.map { |r| "#{r}\n" }
|
59
|
+
.join
|
60
|
+
.each_line
|
61
|
+
.map { |l| " #{l}" }
|
62
|
+
.join
|
63
|
+
end
|
53
64
|
end
|
@@ -54,11 +54,11 @@ module BELParser
|
|
54
54
|
)
|
55
55
|
end
|
56
56
|
@hash.freeze
|
57
|
-
|
57
|
+
end
|
58
58
|
|
59
59
|
unless defined? @names
|
60
60
|
@names = constants.map(&method(:const_get)).map(&:first).sort.freeze
|
61
|
-
|
61
|
+
end
|
62
62
|
|
63
63
|
unless defined? @values
|
64
64
|
@values = constants.map(&method(:const_get)).map(&:to_a).flatten.freeze
|
@@ -13,7 +13,7 @@ module BELParser
|
|
13
13
|
|
14
14
|
def self.map(stmt_node, spec, _namespaces)
|
15
15
|
return nil unless stmt_node.is_a?(BELParser::Parsers::AST::Statement)
|
16
|
-
return nil
|
16
|
+
return nil if stmt_node.relationship.string_literal.nil?
|
17
17
|
rel = spec.relationship(stmt_node.relationship.string_literal.to_sym)
|
18
18
|
return nil unless rel.listable?
|
19
19
|
|
@@ -44,7 +44,7 @@ module BELParser
|
|
44
44
|
end
|
45
45
|
|
46
46
|
def to_s
|
47
|
-
<<-MSG.gsub(/ {12}/, '').
|
47
|
+
<<-MSG.gsub(/ {12}/, '').delete("\n")
|
48
48
|
A "#{@rel.long}" statement cannot use the subject term as an
|
49
49
|
object list() argument.
|
50
50
|
MSG
|
@@ -13,7 +13,7 @@ module BELParser
|
|
13
13
|
|
14
14
|
def self.map(stmt_node, spec, _namespaces)
|
15
15
|
return nil unless stmt_node.is_a?(BELParser::Parsers::AST::Statement)
|
16
|
-
return nil
|
16
|
+
return nil if stmt_node.relationship.string_literal.nil?
|
17
17
|
|
18
18
|
list_func = spec.function(:list)
|
19
19
|
return nil unless list_func
|
@@ -14,6 +14,7 @@ module BELParser
|
|
14
14
|
|
15
15
|
def self.map(node, spec, _namespaces)
|
16
16
|
return nil unless node.is_a?(BELParser::Parsers::AST::Relationship)
|
17
|
+
return nil if node.string_literal.nil?
|
17
18
|
|
18
19
|
relationship_name = node.string_literal
|
19
20
|
rel = spec.relationship(relationship_name.to_sym)
|
@@ -166,6 +166,10 @@ module BELParser
|
|
166
166
|
SemanticIsAminoAcidRange.new(**properties)
|
167
167
|
end
|
168
168
|
|
169
|
+
def is_sequence_position(**properties)
|
170
|
+
SemanticIsSequencePosition.new(**properties)
|
171
|
+
end
|
172
|
+
|
169
173
|
def variadic_arguments(*params_or_terms, **properties)
|
170
174
|
SemanticVariadicArguments.new(params_or_terms, **properties)
|
171
175
|
end
|
@@ -229,13 +233,11 @@ module BELParser
|
|
229
233
|
# Return success if semantic AST does not supply argument patterns.
|
230
234
|
if arguments.empty? || variadic_arguments?
|
231
235
|
success(parse_node)
|
236
|
+
# Or, check argument length.
|
237
|
+
elsif arguments.length == parse_node.arguments.length
|
238
|
+
success(parse_node)
|
232
239
|
else
|
233
|
-
|
234
|
-
if arguments.length == parse_node.arguments.length
|
235
|
-
success(parse_node)
|
236
|
-
else
|
237
|
-
failure(parse_node)
|
238
|
-
end
|
240
|
+
failure(parse_node)
|
239
241
|
end
|
240
242
|
end
|
241
243
|
end
|
@@ -612,6 +614,30 @@ module BELParser
|
|
612
614
|
end
|
613
615
|
end
|
614
616
|
end
|
617
|
+
|
618
|
+
# AST node for IsSequencePosition is a semantic AST.
|
619
|
+
class SemanticIsSequencePosition < SemanticASTNode
|
620
|
+
include BELParser::Quoting
|
621
|
+
|
622
|
+
def initialize(**properties)
|
623
|
+
super(:is_sequence_position, [], properties)
|
624
|
+
end
|
625
|
+
|
626
|
+
def match(value_type, _)
|
627
|
+
string_literal = unquote(value_type.string_literal)
|
628
|
+
integer_position =
|
629
|
+
begin
|
630
|
+
Integer(string_literal)
|
631
|
+
rescue
|
632
|
+
nil
|
633
|
+
end
|
634
|
+
if integer_position && integer_position > 0
|
635
|
+
success(value_type)
|
636
|
+
else
|
637
|
+
failure(value_type)
|
638
|
+
end
|
639
|
+
end
|
640
|
+
end
|
615
641
|
end
|
616
642
|
end
|
617
643
|
end
|
@@ -66,14 +66,14 @@ module BELParser
|
|
66
66
|
any),
|
67
67
|
value(
|
68
68
|
value_type(
|
69
|
-
|
69
|
+
is_sequence_position)))),
|
70
70
|
argument(
|
71
71
|
parameter(
|
72
72
|
prefix(
|
73
73
|
any),
|
74
74
|
value(
|
75
75
|
value_type(
|
76
|
-
|
76
|
+
is_sequence_position)))))
|
77
77
|
end
|
78
78
|
private_constant :AST
|
79
79
|
|
@@ -152,14 +152,14 @@ module BELParser
|
|
152
152
|
any),
|
153
153
|
value(
|
154
154
|
value_type(
|
155
|
-
|
155
|
+
is_sequence_position)))),
|
156
156
|
argument(
|
157
157
|
parameter(
|
158
158
|
prefix(
|
159
159
|
any),
|
160
160
|
value(
|
161
161
|
value_type(
|
162
|
-
|
162
|
+
is_sequence_position)))))
|
163
163
|
end
|
164
164
|
private_constant :AST
|
165
165
|
|
@@ -238,14 +238,14 @@ module BELParser
|
|
238
238
|
any),
|
239
239
|
value(
|
240
240
|
value_type(
|
241
|
-
|
241
|
+
is_sequence_position)))),
|
242
242
|
argument(
|
243
243
|
parameter(
|
244
244
|
prefix(
|
245
245
|
any),
|
246
246
|
value(
|
247
247
|
value_type(
|
248
|
-
|
248
|
+
is_sequence_position)))))
|
249
249
|
end
|
250
250
|
private_constant :AST
|
251
251
|
|