Fixing nested functions
Math and nested functions dont work
This commit is contained in:
parent
37d37366b2
commit
7f12111deb
@ -394,6 +394,7 @@ local function pieceList(list,self,name)
|
|||||||
local cc = 0
|
local cc = 0
|
||||||
for i=1,#list do
|
for i=1,#list do
|
||||||
if list[i]:match("[%w_]-%[.-%]") and list[i]:sub(1,1)~='"' then
|
if list[i]:match("[%w_]-%[.-%]") and list[i]:sub(1,1)~='"' then
|
||||||
|
print("dict")
|
||||||
local dict,sym=list[i]:match("([%w_]-)%[(.-)%]")
|
local dict,sym=list[i]:match("([%w_]-)%[(.-)%]")
|
||||||
if tonumber(sym) then
|
if tonumber(sym) then
|
||||||
L[#L+1]={"\1"..dict,tonumber(sym),IsALookup=true}
|
L[#L+1]={"\1"..dict,tonumber(sym),IsALookup=true}
|
||||||
@ -405,32 +406,41 @@ 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]:sub(1,1)=="\"" and list[i]:sub(-1,-1)=="\"" then
|
||||||
|
print("string")
|
||||||
|
L[#L+1]=list[i]:sub(2,-2)
|
||||||
|
elseif list[i]:sub(1,1)=="[" and list[i]:sub(-1,-1)=="]" then
|
||||||
|
print("index")
|
||||||
|
L[#L+1]=pieceList(list[i]:sub(2,-2),self,name)
|
||||||
|
elseif tonumber(list[i]) then
|
||||||
|
print("number")
|
||||||
|
L[#L+1]=tonumber(list[i])
|
||||||
|
elseif list[i]=="true" then
|
||||||
|
print("true")
|
||||||
|
L[#L+1]=true
|
||||||
|
elseif list[i]=="false" then
|
||||||
|
print("false")
|
||||||
|
L[#L+1]=false
|
||||||
|
elseif list[i]:match("[%w_]+")==list[i] then
|
||||||
|
print("var?")
|
||||||
|
L[#L+1]="\1"..list[i]
|
||||||
|
elseif list[i]:match("[%w_]-%..-") then
|
||||||
|
print("dict?")
|
||||||
|
local dict,sym=list[i]:match("([%w_]-)%.(.+)")
|
||||||
|
L[#L+1]={"\1"..dict,sym,IsALookup=true}
|
||||||
|
elseif list[i]:match("[_%w%+%-/%*%^%(%)%%]+") and list[i]:match("[%+%-/%*%^%%]+") then
|
||||||
|
print("math")
|
||||||
|
local char="$"..string.char(mathass+64)
|
||||||
|
self:compileExpr(char,list[i],name)
|
||||||
|
mathass=mathass+1
|
||||||
|
L[#L+1]="\1"..char
|
||||||
elseif list[i]:match("^([%w_]+)%s*%((.*)%)$") then
|
elseif list[i]:match("^([%w_]+)%s*%((.*)%)$") then
|
||||||
|
print("func")
|
||||||
local func,args = list[i]:match("^([%w_]+)%s*%((.*)%)$")
|
local func,args = list[i]:match("^([%w_]+)%s*%((.*)%)$")
|
||||||
local sym = "`"..string.char(65+cc)
|
local sym = "`"..string.char(65+cc)
|
||||||
self:compileFWR(func,sym,args,name)
|
self:compileFWR(func,sym,args,name)
|
||||||
cc=cc+1
|
cc=cc+1
|
||||||
L[#L+1]="\1"..sym
|
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
|
|
||||||
L[#L+1]=pieceList(list[i]:sub(2,-2),self,name)
|
|
||||||
elseif tonumber(list[i]) then
|
|
||||||
L[#L+1]=tonumber(list[i])
|
|
||||||
elseif list[i]:match("[%w_]-%..-") then
|
|
||||||
local dict,sym=list[i]:match("([%w_]-)%.(.+)")
|
|
||||||
L[#L+1]={"\1"..dict,sym,IsALookup=true}
|
|
||||||
elseif list[i]=="true" then
|
|
||||||
L[#L+1]=true
|
|
||||||
elseif list[i]=="false" then
|
|
||||||
L[#L+1]=false
|
|
||||||
elseif list[i]:match("[%w_]+")==list[i] then
|
|
||||||
L[#L+1]="\1"..list[i]
|
|
||||||
elseif list[i]:match("[_%w%+%-/%*%^%(%)%%]+") then
|
|
||||||
local char="$"..string.char(mathass+64)
|
|
||||||
self:compileExpr(char,list[i],name)
|
|
||||||
mathass=mathass+1
|
|
||||||
L[#L+1]="\1"..char
|
|
||||||
else
|
else
|
||||||
self:pushError("Invalid Syntax!",list[i])
|
self:pushError("Invalid Syntax!",list[i])
|
||||||
end
|
end
|
||||||
@ -625,6 +635,7 @@ function parseManager:compileExpr(eql,expr,name)
|
|||||||
local count=0
|
local count=0
|
||||||
for i,v in pairs(self.methods) do
|
for i,v in pairs(self.methods) do
|
||||||
expr=expr:gsub(i.."(%b())",function(a)
|
expr=expr:gsub(i.."(%b())",function(a)
|
||||||
|
print("MET:",a)
|
||||||
a=a:sub(2,-2)
|
a=a:sub(2,-2)
|
||||||
if a:sub(1,1)=="-" then
|
if a:sub(1,1)=="-" then
|
||||||
a="0"..a
|
a="0"..a
|
||||||
@ -635,6 +646,7 @@ function parseManager:compileExpr(eql,expr,name)
|
|||||||
end
|
end
|
||||||
for i,v in pairs(self.cFuncs) do
|
for i,v in pairs(self.cFuncs) do
|
||||||
expr=expr:gsub(i.."(%b())",function(a)
|
expr=expr:gsub(i.."(%b())",function(a)
|
||||||
|
print("MET:",a)
|
||||||
a=a:sub(2,-2)
|
a=a:sub(2,-2)
|
||||||
if a:sub(1,1)=="-" then
|
if a:sub(1,1)=="-" then
|
||||||
a="0"..a
|
a="0"..a
|
||||||
@ -661,7 +673,8 @@ function parseManager:compileExpr(eql,expr,name)
|
|||||||
return expr
|
return expr
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if expr:match("[!%$%s&_%w%+%-/%*%.%^%(%)%%]+")==expr then
|
if expr:match("[!%$%s&_%w%+%-,/%*%.%^%(%)%%]+")==expr then
|
||||||
|
print(expr)
|
||||||
expr = expr:gsub("%s","")
|
expr = expr:gsub("%s","")
|
||||||
parseManager:pieceExpr(expr)
|
parseManager:pieceExpr(expr)
|
||||||
cmds[#cmds]["vars"]={"\1"..eql}
|
cmds[#cmds]["vars"]={"\1"..eql}
|
||||||
|
|||||||
2
test.dms
2
test.dms
@ -5,7 +5,7 @@ VERSION 4.1 //The version that nested functions was introduced
|
|||||||
// New feature functions inside of functions
|
// New feature functions inside of functions
|
||||||
a = hmm(5,1)
|
a = hmm(5,1)
|
||||||
"a = $a$"
|
"a = $a$"
|
||||||
b = hmm(hmm(6,hmm(1,1)),hmm(5,3))
|
b = hmm(hmm(6,hmm(1,1)),5 + sqrt(100))
|
||||||
"b = $b$"
|
"b = $b$"
|
||||||
}
|
}
|
||||||
[hmm:function(a,b)]{
|
[hmm:function(a,b)]{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user