2021-05-10 06:23:32 +00:00
|
|
|
local state = require("ForthState")
|
2021-05-11 01:43:33 +00:00
|
|
|
local ForthDictionary = {}
|
2021-05-10 06:23:32 +00:00
|
|
|
|
2021-05-11 01:43:33 +00:00
|
|
|
global type Dictionary = record
|
2021-05-10 06:23:32 +00:00
|
|
|
contents: {string: function(State)}
|
|
|
|
end
|
|
|
|
|
2021-05-11 01:43:33 +00:00
|
|
|
|
|
|
|
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
|