Well, lately when I didn't have subscription I felt like.. making parsers for some really odd reason, don't ask why
Anyways,
PHP Code:
/* Made by Chompy
Parser v1.0
Usage:
<$var|this.var$>
<$function|function(params)$>
* params can't be spaced (ex. (foo, bar)), have to be (foo,bar)
*/
public function cParse(a) {
temp.b = temp.a.tokenize(" ");
temp.i = 0;
for(temp.c : b) {
if (c.pos("<$") > -1) {
temp.d = c.substring(0, c.pos("<$") + 2);
temp.e = c.substring(d.length(), c.pos("|") - d.length());
temp.f = c.substring(c.pos("|") + 1, c.pos("$>") - (d.length() + e.length()) - 1);
temp.g = c.substring(c.pos("$>") + 2);
switch(e) {
case "var":
b[i] = d.substring(0, d.length() - 2);
b[i] @= makevar(f);
b[i] @= g;
break;
case "function":
temp.j = f.substring(0, f.pos("("));
temp.k = f.substring(f.pos("(") + 1, f.pos(")") - (j.length() + 1));
if (makevar(k) != NULL) {
k = makevar(k);
}
temp.p = k.tokenize(",");
temp.l = (@ j)(@ p[0], p[1], p[2], p[3], p[4], p[5], p[6]);
b[i] = d.substring(0, d.length() - 2);
b[i] @= l;
b[i] @= g;
break;
default:
if (i > 0) {
b[i-1] = b[i-1].substring(0, b[i-1].length());
}
b[i] = d.substring(0, d.length() - 2);
b[i] @= g;
break;
}
}
i ++;
}
temp.h = "";
for(temp.str : b) {
h @= str @ " ";
}
return h;
}
Basicly, you can do:
PHP Code:
function onCreated() {
this.nick = "Chompi";
echo(cParse("Hi <$var|this.nick$>!"));
}
And it will output "Hi Chompi!".
It will parse all variables and functions it finds
I'll also use this thread to post my other parsers that I've made, so.. have fun? xD
(PS: I know they probably isn't for good use, butI learnt much out of making parsers so by reading them or making your own, you learn how things works :o)