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
|
2022-02-26 18:53:39 +01:00
|
|
|
include Types
|
|
|
|
|
2022-02-11 15:46:47 +01:00
|
|
|
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-26 18:53:39 +01:00
|
|
|
if [RplList, RplNumeric, RplBoolean].include?( args[0].class )
|
2022-02-17 15:21:24 +01:00
|
|
|
@stack << args[0] # these types evaluate to themselves
|
|
|
|
else
|
2022-02-26 18:53:39 +01:00
|
|
|
run( args[0].value.to_s )
|
2022-02-17 15:21:24 +01:00
|
|
|
end
|
2022-02-11 15:46:47 +01:00
|
|
|
end )
|
|
|
|
end
|
2021-11-18 12:00:02 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|