Class: Electr::Syntaxer

Inherits:
Object
  • Object
show all
Defined in:
lib/electr/parser/syntaxer.rb

Overview

A Syntaxer transform a list of lexical units into an AST.

There isn’t a monolithic class that does this work. There is actually some rule’s classes to make the AST.

Instance Method Summary collapse

Constructor Details

#initialize(lexical_units) ⇒ Syntaxer

lexical_units - Array of LexicalUnits



10
11
12
13
# File 'lib/electr/parser/syntaxer.rb', line 10

def initialize(lexical_units)
  @units = lexical_units
  @ast = AST.new "ast"
end

Instance Method Details

#runObject

Public: Compile lexical units into an AST.

Returns the AST.



18
19
20
21
# File 'lib/electr/parser/syntaxer.rb', line 18

def run
  RootRule.new(@units, @ast).apply
  @ast
end