rpl.rb/lib/core/general.rb

40 lines
915 B
Ruby
Raw Normal View History

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