2021-12-07 16:09:17 +01:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2021-11-23 13:10:03 +01:00
|
|
|
module Rpl
|
2021-12-07 15:50:58 +01:00
|
|
|
module Lang
|
|
|
|
module Core
|
|
|
|
module_function
|
2021-11-10 16:20:47 +01:00
|
|
|
|
2021-12-07 15:50:58 +01:00
|
|
|
# no operation
|
2021-12-07 16:46:33 +01:00
|
|
|
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
|
2021-11-10 16:20:47 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|