From 0856ab47112446f8d58f405a9c562e704fe00052 Mon Sep 17 00:00:00 2001 From: Ryan Ward Date: Wed, 27 Mar 2019 08:31:39 -0400 Subject: [PATCH] Added Nested function calls --- parseManager/init.lua | 15 +++++++++++++-- test.dms | 37 ++++++++++++++++++++++++------------- 2 files changed, 37 insertions(+), 15 deletions(-) diff --git a/parseManager/init.lua b/parseManager/init.lua index 2190272..637ff89 100644 --- a/parseManager/init.lua +++ b/parseManager/init.lua @@ -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 diff --git a/test.dms b/test.dms index 4b161a8..92e0d9a 100644 --- a/test.dms +++ b/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") -} \ No newline at end of file +[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") +// } \ No newline at end of file