rpl.rb/lib/core/general.rb

30 lines
583 B
Ruby
Raw Normal View History

2021-12-07 16:09:17 +01:00
# frozen_string_literal: true
2022-02-10 14:50:59 +01:00
module Lang
module Core
module_function
2022-02-10 14:50:59 +01:00
# no operation
def nop; end
2022-02-09 16:35:54 +01:00
2022-02-10 14:50:59 +01:00
# show version
def version
@stack += parse( @version.to_s )
end
2022-02-09 16:35:54 +01:00
2022-02-10 14:50:59 +01:00
# show complete identification string
def uname
@stack += parse( "\"Rpl Interpreter version #{@version}\"" )
end
2022-02-09 16:35:54 +01:00
2022-02-10 14:50:59 +01:00
def help
args = stack_extract( [%i[name]] )
2022-02-09 16:38:09 +01:00
2022-02-10 14:50:59 +01:00
word = @dictionary.words[ args[0][:value] ]
2022-02-09 16:38:09 +01:00
2022-02-10 14:50:59 +01:00
@stack << { type: :string,
value: "#{args[0][:value]}: #{word.nil? ? 'not a core word' : word[:help]}" }
end
end
end