Added basic WordInfo implementation

This commit is contained in:
Starfflame 2021-05-11 01:01:38 -05:00
parent 41276fde68
commit ca797f9e49
2 changed files with 26 additions and 4 deletions

View File

@ -1,13 +1,15 @@
local state = require("ForthState")
local wordinfo = require("ForthWordInfo")
local ForthDictionary = {}
global type Dictionary = record
contents: {string: function(State)}
contents: {string: WordInfo}
end
function Dictionary:define(word: string, instructions: function(State))
self.contents[word] = instructions
function Dictionary:define(word: string, info: WordInfo)
self.contents[word] = info
end
local dict_mt = {__index = Dictionary}
function Dictionary:new(): Dictionary

20
ForthWordInfo.tl Normal file
View File

@ -0,0 +1,20 @@
local state = require("ForthState")
local ForthWordInfo = {}
global type WordInfo = record
func: function(State)
immediate: boolean
end
local wordi_mt = {__index = WordInfo}
function WordInfo:new(funct: State, imm: boolean): WordInfo
return setmetatable({func = funct, immediate = imm} as WordInfo, wordi_mt)
end
local s = State:new()
print(s)
return ForthWordInfo