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.

Instance Method Summary collapse

Constructor Details

#initialize(lexical_units) ⇒ Syntaxer

lexical_units - Array of LexicalUnits



7
8
9
10
# File 'lib/electr/parser/syntaxer.rb', line 7

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.



15
16
17
18
# File 'lib/electr/parser/syntaxer.rb', line 15

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