Merge branch 'trunk' of ssh://src.le-moine.org:38172/gwh/rpl.rb into trunk

This commit is contained in:
Gwenhael Le Moine 2022-08-30 13:37:43 +02:00
commit 703c659f83
No known key found for this signature in database
GPG key ID: FDFE3669426707A7
3 changed files with 11 additions and 2 deletions

View file

@ -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

View file

@ -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}"

View file

@ -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