Class: BELParser::Parsers::AST::Statement

Inherits:
Node show all
Defined in:
lib/bel_parser/parsers/ast/node.rb

Overview

AST node representing a statement.

Instance Attribute Summary

Attributes inherited from Node

#character_range, #complete, #line_number

Attributes inherited from AST::Node

#children, #hash, #type

Instance Method Summary collapse

Methods inherited from Node

#add_syntax_error, #append, #child, #children?, #complete?, #concat, #first_child, #fourth_child, #freeze, #incomplete?, #num_children, #range_end, #range_start, #second_child, #syntax_errors, #third_child, #traverse, #updated

Methods inherited from AST::Node

#==, #append, #concat, #dup, #eql?, #inspect, #to_a, #to_ast, #to_bel, #to_s, #to_sexp, #updated

Methods included from BELParser::Parsers

#serialize

Constructor Details

#initialize(children = [], properties = {}) ⇒ Statement

New Statement AST node.



684
685
686
# File 'lib/bel_parser/parsers/ast/node.rb', line 684

def initialize(children = [], properties = {})
  super(Statement.ast_type, children, properties)
end

Instance Method Details

#commentObject



715
716
717
# File 'lib/bel_parser/parsers/ast/node.rb', line 715

def comment
  comment? ? children[-1] : nil
end

#comment?Boolean

Returns:

  • (Boolean)


711
712
713
# File 'lib/bel_parser/parsers/ast/node.rb', line 711

def comment?
  children[-1] && children[-1].is_a?(Comment)
end

#objectObject

Get the object of the nested statement.



707
708
709
# File 'lib/bel_parser/parsers/ast/node.rb', line 707

def object
  object? ? children[2] : nil
end

#object?Boolean

Returns:

  • (Boolean)


702
703
704
# File 'lib/bel_parser/parsers/ast/node.rb', line 702

def object?
  children[2] && children[2].is_a?(Object)
end

#relationshipObject

Get the relationship of the nested statement.



698
699
700
# File 'lib/bel_parser/parsers/ast/node.rb', line 698

def relationship
  relationship? ? children[1] : nil
end

#relationship?Boolean

Returns:

  • (Boolean)


693
694
695
# File 'lib/bel_parser/parsers/ast/node.rb', line 693

def relationship?
  children[1] && children[1].is_a?(Relationship)
end

#subjectObject

Get the subject of the statement.



689
690
691
# File 'lib/bel_parser/parsers/ast/node.rb', line 689

def subject
  children[0]
end