allow making REPL using preloaded interpreter
This commit is contained in:
parent
603a1627df
commit
f74a8d8e45
1 changed files with 5 additions and 2 deletions
7
bin/rpl
7
bin/rpl
|
@ -6,11 +6,14 @@ require 'readline'
|
|||
require 'rpl'
|
||||
|
||||
class RplRepl
|
||||
def initialize
|
||||
@interpreter = Rpl.new
|
||||
def initialize( interpreter )
|
||||
interpreter ||= Rpl.new
|
||||
@interpreter = interpreter
|
||||
end
|
||||
|
||||
def run
|
||||
print_stack unless @interpreter.stack.empty?
|
||||
|
||||
Readline.completion_proc = proc do |s|
|
||||
( @interpreter.dictionary.words.keys + @interpreter.dictionary.vars.keys ).grep(/^#{Regexp.escape(s)}/)
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue