Class: SyntaxTree::Bf::Parser
- Inherits:
-
Object
- Object
- SyntaxTree::Bf::Parser
- Defined in:
- lib/syntax_tree/bf/parser.rb
Overview
Parses the given source code into a syntax tree.
Defined Under Namespace
Classes: Error
Instance Attribute Summary collapse
-
#source ⇒ Object
readonly
Returns the value of attribute source.
Instance Method Summary collapse
-
#initialize(source) ⇒ Parser
constructor
A new instance of Parser.
- #parse ⇒ Object
Constructor Details
#initialize(source) ⇒ Parser
Returns a new instance of Parser.
12 13 14 |
# File 'lib/syntax_tree/bf/parser.rb', line 12 def initialize(source) @source = source end |
Instance Attribute Details
#source ⇒ Object (readonly)
Returns the value of attribute source.
10 11 12 |
# File 'lib/syntax_tree/bf/parser.rb', line 10 def source @source end |
Instance Method Details
#parse ⇒ Object
16 17 18 |
# File 'lib/syntax_tree/bf/parser.rb', line 16 def parse Root.new(nodes: parse_segment(source, 0), location: 0...source.length) end |