Class: BELParser::Language::Semantics::SemanticPrefix

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

Overview

AST node for Prefix 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_sexp, #updated

Constructor Details

#initialize(children = [], **properties) ⇒ SemanticPrefix

Returns a new instance of SemanticPrefix.



427
428
429
# File 'lib/bel_parser/language/semantics_ast.rb', line 427

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

Instance Method Details

#match(parse_node, spec) ⇒ Object



439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
# File 'lib/bel_parser/language/semantics_ast.rb', line 439

def match(parse_node, spec)
  return nil_node_warning(
    parse_node,
    spec,
    BELParser::Parsers::AST::Prefix) if parse_node.nil?

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

  prefix_patterns.map do |pattern|
    pattern.match(parse_node, spec)
  end
end

#prefix_patternsObject



435
436
437
# File 'lib/bel_parser/language/semantics_ast.rb', line 435

def prefix_patterns
  children
end

#terminal?Boolean

Returns:

  • (Boolean)


431
432
433
# File 'lib/bel_parser/language/semantics_ast.rb', line 431

def terminal?
  true
end