Class: BELParser::Language::Semantics::SemanticIdentifier

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

Overview

AST node for Identifier is a semantic AST.

Instance Attribute Summary

Attributes inherited from AST::Node

#children, #hash, #type

Instance Method Summary collapse

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(children = [], **properties) ⇒ SemanticIdentifier

Returns a new instance of SemanticIdentifier.



513
514
515
# File 'lib/bel_parser/language/semantics_ast.rb', line 513

def initialize(children = [], **properties)
  super(:identifier, children, properties)
end

Instance Method Details

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



525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
# File 'lib/bel_parser/language/semantics_ast.rb', line 525

def match(identifier, spec, will_match_partial = false)
  return nil_node_warning(
    identifier,
    spec,
    BELParser::Parsers::AST::Identifier) if identifier.nil?

  if identifier.type != BELParser::Parsers::AST::Identifier.ast_type
    return type_warning(
      identifier,
      spec,
      BELParser::Parsers::AST::Identifier,
      identifier)
  end

  value_patterns.map { |pattern| pattern.match(identifier, spec) }
end

#terminal?Boolean

Returns:

  • (Boolean)


517
518
519
# File 'lib/bel_parser/language/semantics_ast.rb', line 517

def terminal?
  true
end

#value_patternsObject



521
522
523
# File 'lib/bel_parser/language/semantics_ast.rb', line 521

def value_patterns
  children
end