proc/trim(string)
while(string[1]==" " || string[1]==" ")
string = copytext(string,2)
return string
proc/parse(string,list/variables=new,list/functions=new,list/arguments=new,list/strings=new,list/blocks=new)
var a,b,c,p
for()
a = findtext(string,"\"")
b = findtext(string,"\"",a+1)
if(!a||!b){break}
strings["[strings.len+1]"] = copytext(string,a+1,b)
string = copytext(string,1,a) + " STRING [strings.len] " + copytext(string,b+1)
string = replacetext(string,"\n"," ")
string = replacetext(string," "," ")
string = replacetext(string," "," ")
string = replacetext(string," "," ")
for()
a = findtext(string,"(")
b = findtext(string,")",a+1)
if(!a||!b){break}
c = copytext(string,a+1,b)
c = replacetext(c,",","&")
c = params2list(c)
for(p = 1 to c:len)
c[p] = trim(c[p])
arguments["[arguments.len+1]"] = c
string = copytext(string,1,a) + " ARG [arguments.len] " + copytext(string,b+1)
for()
a = findtext(string,"{")
b = findtext(string,"}",a+1)
if(!a||!b){break}
blocks["[blocks.len+1]"] = trim(copytext(string,a+1,b))
string = copytext(string,1,a) + " BLOCK [blocks.len] " + copytext(string,b+1)
string = replacetext(string," "," ")
string = replacetext(string," "," ")
world << "<b>DEBUG"
world << " <tt><b>STRINGS"
for(var/i in strings)
world <<" <tt>[i] = [strings[i]]"
world << " <tt><b>VARIABLES"
for(var/i in variables)
world <<" <tt>[i] = [variables[i]]"
world << " <tt><b>FUNCTIONS"
for(var/i in functions)
world <<" <tt>[i] = [functions[i]]"
world << " <tt><b>BLOCKS"
for(var/i in blocks)
world <<" <tt>[i] = [blocks[i]]"
world << " <tt><b>ARGUMENTS"
for(var/i in arguments)
world <<" <tt>[i] = [arguments[i]]"
var list/l = arguments[i]
for(var/ii in l)
world << " <tt>[ii]"
world << " <tt><b>CODE"
world << " <tt>[string]"
mob/Login()
var demo = {"
print test(3,"Meow")
function test(a=5,s="defaulted to lol"){
return(333)
}
"}
world << parse(demo)
This is the result of the variable demo being parsed.