Class: BELParser::Language::Semantics::MultipleSubjectObject
- Inherits:
-
Object
- Object
- BELParser::Language::Semantics::MultipleSubjectObject
- Includes:
- SemanticsFunction
- Defined in:
- lib/bel_parser/language/semantics/multiple_subject_object.rb
Overview
MultipleSubjectObject implements a SemanticsFunction that maps a Parsers::AST::Statement to a SemanticsWarning if the subject term is referenced as an argument of the object list term.
Class Method Summary collapse
- .map(stmt_node, spec, _namespaces, will_match_partial = false) ⇒ Object
- .map_subject_object(stmt_node, rel, spec) ⇒ Object
Class Method Details
.map(stmt_node, spec, _namespaces, will_match_partial = false) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/bel_parser/language/semantics/multiple_subject_object.rb', line 14 def self.map(stmt_node, spec, _namespaces, will_match_partial = false) return nil unless stmt_node.is_a?(BELParser::Parsers::AST::Statement) return nil unless stmt_node.relationship? return nil if stmt_node.relationship.string_literal.nil? rel = spec.relationship(stmt_node.relationship.string_literal.to_sym) return nil unless rel return nil unless rel.listable? list_func = spec.function(:list) return nil unless list_func return nil unless stmt_node.object? return nil unless stmt_node.object.term? map_subject_object(stmt_node, rel, spec) end |
.map_subject_object(stmt_node, rel, spec) ⇒ Object
30 31 32 33 34 35 36 37 38 |
# File 'lib/bel_parser/language/semantics/multiple_subject_object.rb', line 30 def self.map_subject_object(stmt_node, rel, spec) sub_term = stmt_node.subject.term list_term = stmt_node.object.child return nil if list_term.arguments.empty? if list_term.arguments.any? { |arg| arg.child && sub_term == arg.child } MultipleSubjectObjectWarning.new(stmt_node, spec, rel) end end |