What have I undertook

added stuff, fixed more bugs, more documentation, more pain and suffering

This is taking too long, but ill push through hahahahahahahahha
This commit is contained in:
Ryan Ward 2019-01-26 19:45:50 -05:00
parent ced07851a7
commit ac7118092a
7 changed files with 144 additions and 59 deletions

0
New Text Document.txt Normal file
View File

View File

@ -1 +0,0 @@
hi

View File

@ -14,6 +14,52 @@ parseManager.methods={}
parseManager.lastCall=nil parseManager.lastCall=nil
parseManager.currentHandle=nil parseManager.currentHandle=nil
parseManager.currentHandleName=nil parseManager.currentHandleName=nil
parseManager.state = {}
parseManager.active = true
function parseManager:mainRunner(block)
local t = self:next(block)
if not t then return nil end
if t.Type=="text" then
io.write(t.text)
io.read()
t=self:next()
elseif t.Type=="condition" then
t=self:next()
elseif t.Type=="assignment" then
t=self:next()
elseif t.Type=="label" then
t=self:next()
elseif t.Type=="method" then
t=self:next()
elseif t.Type=="choice" then
print(t.text)
for i=1,#t.choices do
print(i..". "..t.choices[i])
end
io.write("Choose#: ")
cm=tonumber(io.read())
t=self:next(nil,cm,nil,t)
elseif t.Type=="end" then
if t.text=="leaking" then -- go directly to the block right under the current block if it exists
t=self:next()
else
os.exit()
end
elseif t.Type=="error" then
error(t.text)
else
t=self:next()
end
-- if true return t, else return false
return self.active and t
end
function parseManager:run(block)
local dat = self:mainRunner(block)
while dat do
dat = self:mainRunner()
end
-- print("done")
end
function readonlytable(tab) function readonlytable(tab)
return setmetatable({},{ return setmetatable({},{
__index=tab, __index=tab,
@ -28,9 +74,6 @@ function parseManager:debug(...)
print("<DEBUG>",...) print("<DEBUG>",...)
end end
end end
function parseManager:defualtRunner(func)
--
end
function parseManager:newENV() function parseManager:newENV()
local env={} local env={}
function env:getParent() function env:getParent()
@ -1208,8 +1251,6 @@ function parseManager:next(block,choice)
local args=self:dataToValue(data.args) local args=self:dataToValue(data.args)
local Func local Func
local Ext=false local Ext=false
-- table.print(data.args)
table.print(args)
if type(data.Func)=="table" then if type(data.Func)=="table" then
Ext=true Ext=true
Func=self.currentENV[data.Func[1]][data.Func[2]] Func=self.currentENV[data.Func[1]][data.Func[2]]

View File

@ -0,0 +1,14 @@
ENTRY TEST
[TEST]{
newLightThread("TEST2")
::loop::
print("Hello!")
sleep(.5)
GOTO("loop")
}
[TEST2]{
::loop::
print("Hi!")
sleep(1)
GOTO("loop")
}

View File

@ -1,36 +1,25 @@
package.path="?/init.lua;lua/?/init.lua;lua/?.lua;"..package.path package.path="?/init.lua;lua/?/init.lua;lua/?.lua;"..package.path
local bin = require("bin") local bin = require("bin")
--~ local multi = require("multi") local multi = require("multi")
require("parseManager") require("parseManager")
require("bit") require("bit")
--~ parseManager:define({ test=parseManager:load("test.dms")
--~ rshift=function(self,a,b)
--~ return bit.rshift(a,b)
--~ end,
--~ lshift=function(self,a,b)
--~ return bit.lshift(a,b)
--~ end,
--~ testfunc=function(self,a,b,c)
--~ print(tostring(a).." "..tostring(b).." "..tostring(c))
--~ end
--~ })
test=parseManager:load("textadventure.dms")
print(test:dump()) print(test:dump())
t=test:next() --Code would happen here anyway
while true do local runner = function(block,t)
if not t then break end if not t then return nil end
if t.Type=="text" then if t.Type=="text" then
io.write(t.text) io.write(t.text)
io.read() io.read()
t=test:next() t=self:next()
elseif t.Type=="condition" then elseif t.Type=="condition" then
t=test:next() t=self:next()
elseif t.Type=="assignment" then elseif t.Type=="assignment" then
t=test:next() t=self:next()
elseif t.Type=="label" then elseif t.Type=="label" then
t=test:next() t=self:next()
elseif t.Type=="method" then elseif t.Type=="method" then
t=test:next() t=self:next()
elseif t.Type=="choice" then elseif t.Type=="choice" then
print(t.text) print(t.text)
for i=1,#t.choices do for i=1,#t.choices do
@ -38,19 +27,52 @@ while true do
end end
io.write("Choose#: ") io.write("Choose#: ")
cm=tonumber(io.read()) cm=tonumber(io.read())
t=test:next(nil,cm,nil,t) t=self:next(nil,cm,nil,t)
elseif t.Type=="end" then elseif t.Type=="end" then
if t.text=="leaking" then -- go directly to the block right under the current block if it exists if t.text=="leaking" then -- go directly to the block right under the current block if it exists
t=test:next() t=self:next()
else else
os.exit() os.exit()
end end
elseif t.Type=="error" then elseif t.Type=="error" then
error(t.text) error(t.text)
else else
t=test:next() t=self:next()
end end
return t
end end
--["vars"]={"\1%"..string.char(mathAss+64)} test.mainRunner = runner
--cmds[#cmds+1]={Func="MOD",args={l,(r or "")}} test.active = false
-- multi:newThread("Parse Manager Main State",function()
local dat = self:mainRunner(nil,self:next())
while dat do
thread.skip()
dat = self:mainRunner(nil,dat)
end
end)
function test:run()
multi:mainloop()
end
test:define{
sleep = function(self,n)
thread.sleep(n)
end,
newLightThread = function(self,block)
local state = parseManager:load(self.currentChunk.path)
state.mainENV = self.mainENV
state.mainRunner = runner
multi:newThread("Parse Manager State",function()
local dat = state:mainRunner(nil,state:next())
while dat do
thread.skip()
dat = state:mainRunner(nil,dat)
end
end)
end
}
--End of injecting
--~ test:run()
multi:newThread("",function()
print("Threading works")
end)
multi:mainloop()

View File

@ -1,8 +1,8 @@
local GLOBAL, sThread = require("multi.integration.lanesManager").init() --~ local GLOBAL, sThread = require("multi.integration.lanesManager").init()
GLOBAL["Test"]=true --~ GLOBAL["Test"]=true
multi:newSystemThread("NewThread",function(blck,path,name) --~ multi:newSystemThread("NewThread",function(blck,path,name)
print(GLOBAL["Test"]) --~ print(GLOBAL["Test"])
end) --~ end)
--~ io.flush() --~ io.flush()
--~ i = io.input() --~ i = io.input()
--~ i:seek("cur") --~ i:seek("cur")
@ -19,3 +19,9 @@ end)
--~ io.write("\b") --~ io.write("\b")
--~ io.flush() --~ io.flush()
--~ io.read() --~ io.read()
bool = true
function test()
local t = {}
return bool and t
end
print(test())

View File

@ -6,25 +6,28 @@ ENTRY MAIN
print("We cannot use the filesystem or the extendedDefine module! Exiting program!") print("We cannot use the filesystem or the extendedDefine module! Exiting program!")
QUIT() QUIT()
::define:: ::define::
// USING filesystem as bin USING filesystem as bin
// USING extendedDefine USING extendedDefine
// setVar("name","Thread Test") setVar("name","Thread Test")
// newThread("LoopTest") newThread("LoopTest")
// in = getInput("Enter Something: ") in = getInput("Enter Something: ")
// file = bin.new(in) file = bin.new(in)
// file:tofile("WeCanWriteEm.txt") file:tofile("WeCanWriteEm.txt")
"Let's test simple object creation" test(1,2)
obj = [] "We are here now"
obj.test = say "why no work"
obj.test("Hello!") "?"
"Hmm..."
} }
// [LoopTest]{ [test:function(a,b)]{
// a=0 print("This works right? $a$ $b$")
// name = getVar("name") return True
// ::loop:: }
// a=a+1 [LoopTest]{
// test("$name$ $a$") a=0
// sleep(1) name = getVar("name")
// GOTO("loop") ::loop::
// } a=a+1
test("$name$ $a$")
sleep(1)
GOTO("loop")
}