From e7532a3559cab0c9797a05641cb353fd99333f38 Mon Sep 17 00:00:00 2001 From: Gwenhael Le Moine Date: Wed, 8 Dec 2021 16:07:56 +0100 Subject: [PATCH] EVAL all the things!!! --- lib/core/program.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/core/program.rb b/lib/core/program.rb index 1c253be..95114f5 100644 --- a/lib/core/program.rb +++ b/lib/core/program.rb @@ -7,11 +7,11 @@ module Rpl # evaluate (run) a program, or recall a variable. ex: 'my_prog' eval def eval( stack, dictionary ) - stack, args = Rpl::Lang::Core.stack_extract( stack, [%i[program word name]] ) + stack, args = Rpl::Lang::Core.stack_extract( stack, [:any] ) - # we trim enclosing «» - preparsed_input = args[0][:type] == :word ? args[0][:value] : args[0][:value][1..-2] - parsed_input = Rpl::Lang::Parser.new.parse_input( preparsed_input ) + # we trim enclosing characters if necessary + preparsed_input = %i[string name program].include?( args[0][:type] ) ? args[0][:value][1..-2] : args[0][:value] + parsed_input = Rpl::Lang::Parser.new.parse_input( preparsed_input.to_s ) stack, dictionary = Rpl::Lang::Runner.new.run_input( parsed_input, stack, dictionary )