Class: BELParser::Language::Semantics::SemanticFunctionOf

Inherits:
SemanticASTNode show all
Defined in:
lib/bel_parser/language/semantics_ast.rb

Overview

AST node for FunctionOf is a semantic AST.

Instance Attribute Summary

Attributes inherited from AST::Node

#children, #hash, #type

Instance Method Summary collapse

Methods inherited from SemanticASTNode

#terminal?

Methods inherited from AST::Node

#==, #append, #concat, #dup, #eql?, #inspect, #to_a, #to_ast, #to_bel, #to_s, #to_sexp, #updated

Methods included from Parsers

#serialize

Constructor Details

#initialize(functions, **properties) ⇒ SemanticFunctionOf

Returns a new instance of SemanticFunctionOf.



638
639
640
# File 'lib/bel_parser/language/semantics_ast.rb', line 638

def initialize(functions, **properties)
  super(:function_of, functions, properties)
end

Instance Method Details

#functionsObject



642
643
644
# File 'lib/bel_parser/language/semantics_ast.rb', line 642

def functions
  children
end

#match(identifier, spec, will_match_partial = false) ⇒ Object



646
647
648
649
650
651
652
653
654
655
# File 'lib/bel_parser/language/semantics_ast.rb', line 646

def match(identifier, spec, will_match_partial = false)
  return success(identifier, spec) if functions.include?(:*)

  function = spec.function(identifier.string_literal.to_sym)
  if functions.include?(function)
    success(identifier, spec)
  else
    invalid_function_warning(identifier, spec, functions)
  end
end