class BELParser::Language::Semantics::ListFunctionSubject

ListFunctionSubject implements a {SemanticsFunction} that maps a {BELParser::Parsers::AST::Subject} to {SemanticsWarning} if a list {BELParser::Parsers::AST::Term} is used as the {BELParser::Parsers::AST::Subject} of a {BELParser::Parsers::AST::Statement}.

Public Class Methods

map(node, spec, _namespaces, will_match_partial = false) click to toggle source
# File lib/bel_parser/language/semantics/list_function_subject.rb, line 16
def self.map(node, spec, _namespaces, will_match_partial = false)
  return nil unless node.is_a?(BELParser::Parsers::AST::Subject)

  list_func = spec.function(:list)
  return nil unless list_func

  return nil unless node.term.function
  return nil unless node.term.function.identifier
  func_name = node.term.function.identifier.string_literal
  sub_func  = spec.function(func_name.to_sym)
  ListFunctionSubjectWarning.new(node, spec) if sub_func == list_func
end