class BELParser::Language::Semantics::MultipleSubjectObject
MultipleSubjectObject
implements a {SemanticsFunction} that maps a {BELParser::Parsers::AST::Statement} to a {SemanticsWarning} if the subject term is referenced as an argument of the object list term.
Public Class Methods
map(stmt_node, spec, _namespaces, will_match_partial = false)
click to toggle source
# 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)
click to toggle source
# 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