Class: Electr::ASTReader

Inherits:
BaseReader show all
Defined in:
lib/electr/repl/ast_reader.rb

Overview

Special reader for a REPL that display an AST instead of the computation.

Instance Method Summary collapse

Constructor Details

#initialize(readline_lib = Readline) ⇒ ASTReader

Returns a new instance of ASTReader.



7
8
9
# File 'lib/electr/repl/ast_reader.rb', line 7

def initialize(readline_lib = Readline)
  super("E--ast> ", readline_lib)
end

Instance Method Details

#runObject



11
12
13
14
# File 'lib/electr/repl/ast_reader.rb', line 11

def run
  line = @readline.readline(@prompt, true)
  Compiler.compile_to_ast(line)
end