Added basic WordInfo implementation
This commit is contained in:
parent
41276fde68
commit
ca797f9e49
|
@ -1,13 +1,15 @@
|
||||||
local state = require("ForthState")
|
local state = require("ForthState")
|
||||||
|
local wordinfo = require("ForthWordInfo")
|
||||||
local ForthDictionary = {}
|
local ForthDictionary = {}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
global type Dictionary = record
|
global type Dictionary = record
|
||||||
contents: {string: function(State)}
|
contents: {string: WordInfo}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function Dictionary:define(word: string, info: WordInfo)
|
||||||
function Dictionary:define(word: string, instructions: function(State))
|
self.contents[word] = info
|
||||||
self.contents[word] = instructions
|
|
||||||
end
|
end
|
||||||
local dict_mt = {__index = Dictionary}
|
local dict_mt = {__index = Dictionary}
|
||||||
function Dictionary:new(): Dictionary
|
function Dictionary:new(): Dictionary
|
||||||
|
|
|
@ -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
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue