20 lines
419 B
Plaintext
20 lines
419 B
Plaintext
local state = require("ForthState")
|
|
local ForthDictionary = {}
|
|
|
|
global type Dictionary = record
|
|
contents: {string: function(State)}
|
|
end
|
|
|
|
|
|
function Dictionary:define(word: string, instructions: function(State))
|
|
self.contents[word] = instructions
|
|
end
|
|
local dict_mt = {__index = Dictionary}
|
|
function Dictionary:new(): Dictionary
|
|
return setmetatable({contents = {}} as Dictionary, dict_mt)
|
|
end
|
|
|
|
|
|
|
|
return ForthDictionary
|