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_sexp, #updated

Constructor Details

#initialize(namespaces, **properties) ⇒ SemanticNamespaceOf

Returns a new instance of SemanticNamespaceOf.



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

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

Instance Method Details

#match(prefix_node, spec) ⇒ Object



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

def match(prefix_node, spec)
  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



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

def namespaces
  children
end