Added Nested function calls
This commit is contained in:
parent
f2b6304035
commit
0856ab4711
@ -1,6 +1,6 @@
|
|||||||
require("bin")
|
require("bin")
|
||||||
parseManager={}
|
parseManager={}
|
||||||
parseManager.VERSION = 4
|
parseManager.VERSION = 4.1
|
||||||
parseManager.__index=parseManager
|
parseManager.__index=parseManager
|
||||||
parseManager.chunks={}
|
parseManager.chunks={}
|
||||||
parseManager.stats={warnings = true}
|
parseManager.stats={warnings = true}
|
||||||
@ -243,6 +243,9 @@ function parseManager.split(s,pat)
|
|||||||
res[#res + 1] = elem
|
res[#res + 1] = elem
|
||||||
elem = ''
|
elem = ''
|
||||||
state = 3 -- skip over the next space if present
|
state = 3 -- skip over the next space if present
|
||||||
|
elseif c == "(" then
|
||||||
|
state = 1
|
||||||
|
elem = elem .. '('
|
||||||
else
|
else
|
||||||
elem = elem .. c
|
elem = elem .. c
|
||||||
end
|
end
|
||||||
@ -254,6 +257,9 @@ function parseManager.split(s,pat)
|
|||||||
elseif c=="]" then
|
elseif c=="]" then
|
||||||
state = 0
|
state = 0
|
||||||
elem = elem .. ']'
|
elem = elem .. ']'
|
||||||
|
elseif c==")" then
|
||||||
|
state = 0
|
||||||
|
elem = elem .. ')'
|
||||||
elseif c == '\\' then
|
elseif c == '\\' then
|
||||||
state = 2
|
state = 2
|
||||||
else
|
else
|
||||||
@ -399,6 +405,12 @@ local function pieceList(list,self,name)
|
|||||||
cc=cc+1
|
cc=cc+1
|
||||||
L[#L+1]="\1"..sym
|
L[#L+1]="\1"..sym
|
||||||
end
|
end
|
||||||
|
elseif list[i]:match("^([%w_]+)%s*%((.*)%)$") then
|
||||||
|
local func,args = list[i]:match("^([%w_]+)%s*%((.*)%)$")
|
||||||
|
local sym = "`"..string.char(65+cc)
|
||||||
|
self:compileFWR(func,sym,args,name)
|
||||||
|
cc=cc+1
|
||||||
|
L[#L+1]="\1"..sym
|
||||||
elseif list[i]:sub(1,1)=="\"" and list[i]:sub(-1,-1)=="\"" then
|
elseif list[i]:sub(1,1)=="\"" and list[i]:sub(-1,-1)=="\"" then
|
||||||
L[#L+1]=list[i]:sub(2,-2)
|
L[#L+1]=list[i]:sub(2,-2)
|
||||||
elseif list[i]:sub(1,1)=="[" and list[i]:sub(-1,-1)=="]" then
|
elseif list[i]:sub(1,1)=="[" and list[i]:sub(-1,-1)=="]" then
|
||||||
@ -487,7 +499,6 @@ function parseManager:compileAssign(assignA,assignB,name)
|
|||||||
assign.vals[#assign.vals+1]=tonumber(listB[k])
|
assign.vals[#assign.vals+1]=tonumber(listB[k])
|
||||||
elseif listB[k]:match("%w-%.%w+")==listB[k] then
|
elseif listB[k]:match("%w-%.%w+")==listB[k] then
|
||||||
local dict,sym=listB[k]:match("(%w-)%.(%w+)")
|
local dict,sym=listB[k]:match("(%w-)%.(%w+)")
|
||||||
print(dict,sym)
|
|
||||||
assign.vals[#assign.vals+1]={"\1"..dict,sym,IsALookup=true}
|
assign.vals[#assign.vals+1]={"\1"..dict,sym,IsALookup=true}
|
||||||
elseif listB[k]:sub(1,1)=="[" and listB[k]:sub(-1,-1)=="]" then
|
elseif listB[k]:sub(1,1)=="[" and listB[k]:sub(-1,-1)=="]" then
|
||||||
if listB[k]:match("%[%]") then
|
if listB[k]:match("%[%]") then
|
||||||
|
|||||||
35
test.dms
35
test.dms
@ -1,15 +1,26 @@
|
|||||||
ENTRY TEST
|
ENTRY MAIN
|
||||||
USING extendedDefine
|
USING extendedDefine
|
||||||
[TEST]{
|
VERSION 4.1 //The version that nested functions was introduced
|
||||||
newThread("TEST2")
|
[MAIN]{
|
||||||
::loop::
|
// New feature functions inside of functions
|
||||||
print("Hello!")
|
a = hmm(5,1)
|
||||||
sleep(.5)
|
"a = $a$"
|
||||||
GOTO("loop")
|
b = hmm(hmm(6,hmm(1,1)),hmm(5,3))
|
||||||
|
"b = $b$"
|
||||||
}
|
}
|
||||||
[TEST2]{
|
[hmm:function(a,b)]{
|
||||||
::loop::
|
return a+b
|
||||||
print("Hi!")
|
|
||||||
sleep(1)
|
|
||||||
GOTO("loop")
|
|
||||||
}
|
}
|
||||||
|
// [TEST]{
|
||||||
|
// newThread("TEST2")
|
||||||
|
// ::loop::
|
||||||
|
// print("Hello!")
|
||||||
|
// sleep(.5)
|
||||||
|
// GOTO("loop")
|
||||||
|
// }
|
||||||
|
// [TEST2]{
|
||||||
|
// ::loop::
|
||||||
|
// print("Hi!")
|
||||||
|
// sleep(1)
|
||||||
|
// GOTO("loop")
|
||||||
|
// }
|
||||||
Loading…
x
Reference in New Issue
Block a user