diff --git a/README.md b/README.md index c8a46e4..0e497eb 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,9 @@ To run REPL locally: `rake run` To run the test suite: `rake test` +# BUGs + * var1 var2 +|-|*|\ ===> result in on stack (normal) AND stored in var1 (_bug_) + # TODO-list * pseudo filesystem: subdir/namespace for variables . 'a dir' crdir 'a dir' cd vars diff --git a/bin/rpl b/bin/rpl index 7a6835f..7f7c3f9 100755 --- a/bin/rpl +++ b/bin/rpl @@ -84,5 +84,5 @@ end # third launch REPL if (explicitely or implicitely) asked RplRepl.new( interpreter ).run if options[:run_REPL] -# last print resulting stack on exit (formatted so that it can be fed back later to interpreter) -pp interpreter.export_stack +# last print defined vars and resulting stack on exit (formatted so that it can be fed back later to interpreter) +pp "#{interpreter.export_vars} #{interpreter.export_stack}" diff --git a/lib/rpl/interpreter.rb b/lib/rpl/interpreter.rb index ba5483e..48b8d2b 100644 --- a/lib/rpl/interpreter.rb +++ b/lib/rpl/interpreter.rb @@ -101,6 +101,12 @@ class Interpreter args end + def export_vars + @dictionary.vars + .map { |name, value| "#{value.to_s} '#{name}' sto" } + .join(' ') + end + def export_stack @stack.map(&:to_s).join(' ') end