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

Constructor Details

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

New Statement AST node.



664
665
666
# File 'lib/bel_parser/parsers/ast/node.rb', line 664

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

Instance Method Details

#commentObject



695
696
697
# File 'lib/bel_parser/parsers/ast/node.rb', line 695

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

#comment?Boolean

Returns:

  • (Boolean)


691
692
693
# File 'lib/bel_parser/parsers/ast/node.rb', line 691

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

#objectObject

Get the object of the nested statement.



687
688
689
# File 'lib/bel_parser/parsers/ast/node.rb', line 687

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

#object?Boolean

Returns:

  • (Boolean)


682
683
684
# File 'lib/bel_parser/parsers/ast/node.rb', line 682

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

#relationshipObject

Get the relationship of the nested statement.



678
679
680
# File 'lib/bel_parser/parsers/ast/node.rb', line 678

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

#relationship?Boolean

Returns:

  • (Boolean)


673
674
675
# File 'lib/bel_parser/parsers/ast/node.rb', line 673

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

#subjectObject

Get the subject of the statement.



669
670
671
# File 'lib/bel_parser/parsers/ast/node.rb', line 669

def subject
  children[0]
end