Class: SyntaxTree::Bf::Parser

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#sourceObject (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

#parseObject



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