Class: AbstractSyntaxTree

Inherits:
Object
  • Object
show all
Defined in:
lib/rosetta/abstract_syntax_tree.rb

Overview

Holds all logic for creating the AST, including parsing.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(base_tokens) ⇒ AbstractSyntaxTree



9
10
11
# File 'lib/rosetta/abstract_syntax_tree.rb', line 9

def initialize(base_tokens)
  @base_tokens = base_tokens
end

Instance Attribute Details

#base_tokensObject (readonly)

Returns the value of attribute base_tokens.



7
8
9
# File 'lib/rosetta/abstract_syntax_tree.rb', line 7

def base_tokens
  @base_tokens
end

Instance Method Details

#formatted_token_treeObject



17
18
19
# File 'lib/rosetta/abstract_syntax_tree.rb', line 17

def formatted_token_tree
  token_tree.map(&:to_s)
end

#node_representationObject



21
22
23
# File 'lib/rosetta/abstract_syntax_tree.rb', line 21

def node_representation
  token_tree.map(&:node_representation)
end

#raw_tokensObject



25
26
27
# File 'lib/rosetta/abstract_syntax_tree.rb', line 25

def raw_tokens
  @base_tokens.map(&:to_s)
end

#token_treeObject



13
14
15
# File 'lib/rosetta/abstract_syntax_tree.rb', line 13

def token_tree
  @token_tree ||= TreeParser.call(@base_tokens)
end