Module: RplLang::Words::General

Includes:
Types
Included in:
Rpl
Defined in:
lib/rpl/words/general.rb

Instance Method Summary collapse

Methods included from Types

new_object

Instance Method Details

#populate_dictionaryObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/rpl/words/general.rb', line 8

def populate_dictionary
  super

  category = 'General'

  @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 + »' ) )
end