2021-12-07 16:09:17 +01:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2022-02-11 15:46:47 +01:00
|
|
|
module RplLang
|
2022-02-25 15:43:48 +01:00
|
|
|
module Words
|
2022-02-11 15:46:47 +01:00
|
|
|
module Program
|
|
|
|
def populate_dictionary
|
|
|
|
super
|
2021-11-18 12:00:02 +01:00
|
|
|
|
2022-02-11 15:46:47 +01:00
|
|
|
@dictionary.add_word( ['eval'],
|
|
|
|
'Program',
|
|
|
|
'( a -- … ) interpret',
|
|
|
|
proc do
|
|
|
|
args = stack_extract( [:any] )
|
2021-11-18 12:00:02 +01:00
|
|
|
|
2022-02-22 14:58:17 +01:00
|
|
|
if %i[list numeric boolean].include?( args[0][:type] )
|
2022-02-17 15:21:24 +01:00
|
|
|
@stack << args[0] # these types evaluate to themselves
|
|
|
|
else
|
|
|
|
run( args[0][:value].to_s )
|
|
|
|
end
|
2022-02-11 15:46:47 +01:00
|
|
|
end )
|
|
|
|
end
|
2021-11-18 12:00:02 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|