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_bel, #to_s, #to_sexp, #updated

Methods included from Parsers

#serialize

Constructor Details

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

Returns a new instance of SemanticPrefix.



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

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

Instance Method Details

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



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

def match(parse_node, spec, will_match_partial = false)
  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



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

def prefix_patterns
  children
end

#terminal?Boolean

Returns:

  • (Boolean)


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

def terminal?
  true
end