Class: Brainfucktt::Node
- Inherits:
-
Treetop::Runtime::SyntaxNode
- Object
- Treetop::Runtime::SyntaxNode
- Brainfucktt::Node
- Defined in:
- lib/brainfucktt/node.rb
Overview
The base class for Brainfucktt syntax nodes in the AST
Direct Known Subclasses
Language::DecrementByte, Language::DecrementPointer, Language::IncrementByte, Language::IncrementPointer, Language::InputByte, Language::Loop, Language::OutputByte, Language::Tree
Instance Method Summary collapse
-
#elements ⇒ <Brainfucktt::Node>
The children of this Node instance.
-
#inspect(indent = "") ⇒ String
Print out the AST of this instance node and it’s children with indentation.
-
#to_s ⇒ String
Return the text value of this Node instance.
Instance Method Details
#elements ⇒ <Brainfucktt::Node>
The children of this Node instance.
11 12 13 |
# File 'lib/brainfucktt/node.rb', line 11 def elements super.find_all { |node| node.is_a?(Brainfucktt::Node) } rescue [] end |
#inspect(indent = "") ⇒ String
Print out the AST of this instance node and it’s children with indentation.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/brainfucktt/node.rb', line 25 def inspect(indent="") result = "" result << indent result << self.class.to_s.sub(/.*:/,'') result << " #{to_s} " unless self.is_a?(Language::Tree) || self.is_a?(Language::Loop) unless elements.empty? result << ":" elements.each do |e| result << "\n#{e.inspect(indent+" ")}" rescue "\n#{indent} #{e.inspect}" end end result end |
#to_s ⇒ String
Return the text value of this Node instance.
18 19 20 |
# File 'lib/brainfucktt/node.rb', line 18 def to_s text_value end |