Class: BELParser::Language::Semantics::SemanticReturnTypeOf

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

Overview

AST node for ReturnTypeOf 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(return_types, **properties) ⇒ SemanticReturnTypeOf

Returns a new instance of SemanticReturnTypeOf.



660
661
662
# File 'lib/bel_parser/language/semantics_ast.rb', line 660

def initialize(return_types, **properties)
  super(:return_type_of, return_types, properties)
end

Instance Method Details

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



668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
# File 'lib/bel_parser/language/semantics_ast.rb', line 668

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

  function = spec.function(identifier.string_literal.to_sym)
  return invalid_return_type_warning(
    identifier,
    spec,
    return_types) unless function

  if return_types.any? { |rt| function.return_type <= rt }
    success(identifier, spec)
  else
    invalid_return_type_warning(identifier, spec, return_types)
  end
end

#return_typesObject



664
665
666
# File 'lib/bel_parser/language/semantics_ast.rb', line 664

def return_types
  children
end