Class: AbstractSyntaxTree
- Inherits:
-
Object
- Object
- AbstractSyntaxTree
- Defined in:
- lib/rosetta/abstract_syntax_tree.rb
Overview
Holds all logic for creating the AST, including parsing.
Instance Attribute Summary collapse
-
#base_tokens ⇒ Object
readonly
Returns the value of attribute base_tokens.
Instance Method Summary collapse
- #formatted_token_tree ⇒ Object
-
#initialize(base_tokens) ⇒ AbstractSyntaxTree
constructor
A new instance of AbstractSyntaxTree.
- #node_representation ⇒ Object
- #raw_tokens ⇒ Object
- #token_tree ⇒ Object
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_tokens ⇒ Object (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_tree ⇒ Object
17 18 19 |
# File 'lib/rosetta/abstract_syntax_tree.rb', line 17 def formatted_token_tree token_tree.map(&:to_s) end |
#node_representation ⇒ Object
21 22 23 |
# File 'lib/rosetta/abstract_syntax_tree.rb', line 21 def node_representation token_tree.map(&:node_representation) end |
#raw_tokens ⇒ Object
25 26 27 |
# File 'lib/rosetta/abstract_syntax_tree.rb', line 25 def raw_tokens @base_tokens.map(&:to_s) end |
#token_tree ⇒ Object
13 14 15 |
# File 'lib/rosetta/abstract_syntax_tree.rb', line 13 def token_tree @token_tree ||= TreeParser.call(@base_tokens) end |