Class: BELParser::Language::Semantics::SignatureMapping
- Inherits:
-
Object
- Object
- BELParser::Language::Semantics::SignatureMapping
- Includes:
- SemanticsFunction
- Defined in:
- lib/bel_parser/language/semantics/signature_mapping.rb
Overview
SignatureMapping implements a SemanticsFunction that maps a Parsers::AST::Node to SemanticsResult by checking each signature for the Function.
Class Method Summary collapse
-
.map(term_node, spec, _namespaces, will_match_partial = false) ⇒ Object
Map term to BEL signatures defined by a BELParser::Language::Specification.
Class Method Details
.map(term_node, spec, _namespaces, will_match_partial = false) ⇒ Object
Map term to BEL signatures defined by a BELParser::Language::Specification. The mapping includes both successful and failed signature matches.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/bel_parser/language/semantics/signature_mapping.rb', line 20 def self.map(term_node, spec, _namespaces, will_match_partial = false) return nil unless term_node.is_a?(BELParser::Parsers::AST::Term) return nil unless term_node.function return nil unless term_node.function.identifier # double negate truthy or falsey value to strict boolean will_match_partial = !!will_match_partial function_name = term_node.function.identifier.string_literal function = spec.function(function_name.to_sym) return nil unless function function.signatures.map { |signature| self._map_signature(term_node, spec, signature, will_match_partial) } end |