class BELParser::Language::Semantics::RelationshipNotListable

RelationshipNotListable implements a {SemanticsFunction} that maps a {BELParser::Parsers::AST::Statement} to a {SemanticsWarning} if the relationship cannot be used for multiple terms in a list.

Public Class Methods

map(node, spec, _namespaces, will_match_partial = false) click to toggle source
# File lib/bel_parser/language/semantics/relationship_not_listable.rb, line 14
def self.map(node, spec, _namespaces, will_match_partial = false)
  return nil unless node.is_a?(BELParser::Parsers::AST::Statement)
  return nil unless node.relationship?
  return nil unless node.object?
  return nil unless node.object.term?

  map_statement(node, spec)
end
map_statement(stmt_node, spec) click to toggle source
# File lib/bel_parser/language/semantics/relationship_not_listable.rb, line 23
def self.map_statement(stmt_node, spec)
  list_func = spec.function(:list)
  return nil unless list_func
  return nil unless stmt_node.object.child.function

  obj_func = stmt_node.object.child.function.identifier.string_literal
  return nil unless spec.function(obj_func.to_sym) == list_func

  rel = spec.relationship(stmt_node.relationship.string_literal.to_sym)
  return nil unless rel

  RelationshipNotMultipleWarning.new(stmt_node, spec, rel) unless
    rel.listable?
end