rpl.rb/lib/rpl/words/program.rb

27 lines
766 B
Ruby
Raw Normal View History

2021-12-07 16:09:17 +01:00
# frozen_string_literal: true
module RplLang
module Words
module Program
2022-02-26 18:53:39 +01:00
include Types
def populate_dictionary
super
2021-11-18 12:00:02 +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
end )
end
2021-11-18 12:00:02 +01:00
end
end
end