Class: Electr::Syntaxer
- Inherits:
-
Object
- Object
- Electr::Syntaxer
- 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
-
#initialize(lexical_units) ⇒ Syntaxer
constructor
lexical_units - Array of LexicalUnits.
-
#run ⇒ Object
Public: Compile lexical units into an AST.
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
#run ⇒ Object
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 |