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 General
|
2022-02-26 18:53:39 +01:00
|
|
|
include Types
|
|
|
|
|
2022-02-11 15:46:47 +01:00
|
|
|
def populate_dictionary
|
|
|
|
super
|
2021-11-10 16:20:47 +01:00
|
|
|
|
2022-08-31 09:57:10 +02:00
|
|
|
category = 'General'
|
|
|
|
|
2022-10-12 17:04:50 +02:00
|
|
|
@dictionary.add_word!( ['nop'],
|
|
|
|
category,
|
|
|
|
'( -- ) no operation',
|
|
|
|
proc {} )
|
|
|
|
|
|
|
|
@dictionary.add_word!( ['help'],
|
|
|
|
category,
|
|
|
|
'( w -- s ) pop help string of the given word',
|
|
|
|
proc do
|
|
|
|
args = stack_extract( [[RplName]] )
|
|
|
|
|
|
|
|
word = @dictionary.words[ args[0].value ]
|
|
|
|
|
|
|
|
@stack << Types.new_object( RplString, "\"#{args[0].value}: #{word.nil? ? 'not a core word' : word[:help]}\"" )
|
|
|
|
end )
|
|
|
|
|
|
|
|
@dictionary.add_word!( ['quit'],
|
|
|
|
category,
|
|
|
|
'( -- ) Stop and quit interpreter',
|
|
|
|
proc {} )
|
|
|
|
|
|
|
|
@dictionary.add_word!( ['version'],
|
|
|
|
category,
|
|
|
|
'( -- n ) Pop the interpreter\'s version number',
|
|
|
|
proc do
|
|
|
|
@stack << Types.new_object( RplString, "\"#{Rpl::VERSION}\"" )
|
|
|
|
end )
|
|
|
|
|
|
|
|
@dictionary.add_word!( ['uname'],
|
|
|
|
category,
|
|
|
|
'( -- s ) Pop the interpreter\'s complete indentification string',
|
|
|
|
Types.new_object( RplProgram, '« "Rpl Interpreter version " version + »' ) )
|
2022-02-11 15:46:47 +01:00
|
|
|
end
|
2021-11-10 16:20:47 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|