Class: BELParser::Language::Semantics::SemanticNamespaceOf

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

Overview

AST node for NamespaceOf 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(namespaces, **properties) ⇒ SemanticNamespaceOf

Returns a new instance of SemanticNamespaceOf.



571
572
573
# File 'lib/bel_parser/language/semantics_ast.rb', line 571

def initialize(namespaces, **properties)
  super(:namespace_of, namespaces, properties)
end

Instance Method Details

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



579
580
581
582
583
584
585
586
587
588
589
# File 'lib/bel_parser/language/semantics_ast.rb', line 579

def match(prefix_node, spec, will_match_partial = false)
  unless prefix_node.respond_to?(:namespace) && prefix_node.namespace
    return invalid_namespace(prefix_node, spec, namespaces)
  end

  if namespaces.any? { |i| i == :* || i == input_namespace }
    success(prefix_node, spec)
  else
    invalid_namespace(prefix_node, spec, namespaces)
  end
end

#namespacesObject



575
576
577
# File 'lib/bel_parser/language/semantics_ast.rb', line 575

def namespaces
  children
end