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