diff --git a/ForthDictionary.tl b/ForthDictionary.tl index 2352ebb..8f48fa3 100644 --- a/ForthDictionary.tl +++ b/ForthDictionary.tl @@ -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 diff --git a/ForthWordInfo.tl b/ForthWordInfo.tl new file mode 100644 index 0000000..e28d39f --- /dev/null +++ b/ForthWordInfo.tl @@ -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 + +