Difference between revisions of "Czervik LSL Computer"
Jump to navigation
Jump to search
Line 5: | Line 5: | ||
key kQuery; | key kQuery; | ||
integer iLine = 0; | integer iLine = 0; | ||
list ifStack; | |||
list stringsName; | list stringsName; | ||
Line 20: | Line 22: | ||
llOwnerSay("Run-time Error: " + error); | llOwnerSay("Run-time Error: " + error); | ||
llResetScript(); | llResetScript(); | ||
} | |||
integer ifTest() { | |||
integer i = 0; | |||
while (i < llGetListLength(ifStack)) { | |||
string ifStr = llList2String(ifStack, 0); | |||
list ll = llParseString2List(ifStr, [" "], []); | |||
list ld = []; | |||
integer pos; | |||
pos = llListFindList(stringsName, [llList2String(ld, 1)]); | |||
if (pos != -1) { | |||
ld += llList2String(stringsName, pos); | |||
ld += ""; | |||
pos = llListFindList(stringsName, [llList2String(ld, 3)]); | |||
ld += llList2String(stringsName, pos); | |||
} else if (llListFindList(intsName, [llList2String(ld, 1)]) != -1) { | |||
ld += llList2String(intsName, pos); | |||
ld += 0; | |||
pos = llListFindList(intsName, [llList2String(ld, 3)]); | |||
ld += llList2String(intsName, pos); | |||
} else { | |||
fail("Variable not found."); | |||
} | |||
string typeFirst = getType(llList2String(ld, 1)); | |||
string typeSecond = getType(llList2String(ld, 3)); | |||
if (typeFirst == "str" || typeSecond == "str") { | |||
if (llList2String(ld, 2) == "==") { | |||
if (llList2String(ld, 1) == llList2String(ld, 3)) {} else { | |||
return 0; | |||
} | |||
} else if (llList2String(ld, 2) == "!=") { | |||
if (llList2String(ld, 1) != llList2String(ld, 3)) {} else { | |||
return 0; | |||
} | |||
} else { | |||
fail("Can not compare two strings using the " + llList2String(ld, 2) + " opperator."); | |||
} | |||
} else { | |||
if (llList2String(ld, 2) == "==") { | |||
if (llList2String(ld, 1) == llList2String(ld, 3)) {} else { | |||
return 0; | |||
} | |||
} else if (llList2String(ld, 2) == "!=") { | |||
if (llList2String(ld, 1) != llList2String(ld, 3)) {} else { | |||
return 0; | |||
} | |||
} else if (llList2String(ld, 2) == "<") { | |||
if ((integer)llList2String(ld, 1) < (integer)llList2String(ld, 3)) {} else { | |||
return 0; | |||
} | |||
} else if (llList2String(ld, 2) == ">") { | |||
if ((integer)llList2String(ld, 1) > (integer)llList2String(ld, 3)) {} else { | |||
return 0; | |||
} | |||
} else if (llList2String(ld, 2) == "<=") { | |||
if ((integer)llList2String(ld, 1) <= (integer)llList2String(ld, 3)) {} else { | |||
return 0; | |||
} | |||
} else if (llList2String(ld, 2) == ">=") { | |||
if ((integer)llList2String(ld, 1) >= (integer)llList2String(ld, 3)) {} else { | |||
return 0; | |||
} | |||
} else { | |||
fail("Can not compare two ints using the " + llList2String(ld, 2) + " opperator."); | |||
} | |||
} | |||
i++; | |||
} | |||
return 1; | |||
} | } | ||
Line 32: | Line 104: | ||
if (data == EOF) { | if (data == EOF) { | ||
llSay(0, "Ending Program."); | llSay(0, "Ending Program."); | ||
} else { | } else { | ||
if (data == ":") | |||
ifStack = llListReplaceList(ifStack, [], llGetListLength(ifStack) - 1, llGetListLength(ifStack) - 1); | |||
if (ifTest()) { | |||
list ld = llParseString2List(data, [" "], []); | list ld = llParseString2List(data, [" "], []); | ||
if (llList2String(ld, 0) == "str") { | if (llList2String(ld, 0) == "str") { | ||
Line 41: | Line 116: | ||
ints += (integer)llList2String(ld, 2); | ints += (integer)llList2String(ld, 2); | ||
} else if (llList2String(ld, 0) == "?") { | } else if (llList2String(ld, 0) == "?") { | ||
ifStack += data; | |||
} else if (llList2String(ld, 0) == "say") { | } else if (llList2String(ld, 0) == "say") { | ||
if (llGetSubString(llList2String(ld, 1), 0, 0) == "\"") { | if (llGetSubString(llList2String(ld, 1), 0, 0) == "\"") { | ||
Line 94: | Line 123: | ||
string type = getType(llList2String(ld, 3)); | string type = getType(llList2String(ld, 3)); | ||
if (type == "str") { | if (type == "str") { | ||
integer pos = llListFindList(stringsName, [llList2String(ld, 1)]); | |||
if (pos != -1) | if (pos != -1) | ||
llSay(0, llList2String(strings, pos)); | llSay(0, llList2String(strings, pos)); | ||
} else { | } else { | ||
integer pos = llListFindList(intsName, [llList2String(ld, 1)]); | |||
if (pos != -1) | if (pos != -1) | ||
llSay(0, (string)llList2Integer(ints, pos)); | llSay(0, (string)llList2Integer(ints, pos)); | ||
} | } | ||
} | } | ||
} | } else { | ||
} | |||
++iLine; | ++iLine; | ||
kQuery = llGetNotecardLine("My Notecard", iLine); | kQuery = llGetNotecardLine("My Notecard", iLine); | ||
} | } | ||
} | } |
Revision as of 14:09, 14 September 2007
The below code is some code being written by Xaviar Czervik. It isn't even partly done, and I were a programmer It'd be version 0.00.0.000.0.01, although I don't do that... So, if you're interested on crashing the LSL compiler (This code doesn't compile 99% of the time) check out the code below. And incase you couldn't tell, I don't believe in comments.
key kQuery; integer iLine = 0; list ifStack; list stringsName; list strings; list intsName; list ints; string getType(string s) { if ((string)((integer)s) == s) return "int"; return "str"; } fail(string error) { llOwnerSay("Run-time Error: " + error); llResetScript(); } integer ifTest() { integer i = 0; while (i < llGetListLength(ifStack)) { string ifStr = llList2String(ifStack, 0); list ll = llParseString2List(ifStr, [" "], []); list ld = []; integer pos; pos = llListFindList(stringsName, [llList2String(ld, 1)]); if (pos != -1) { ld += llList2String(stringsName, pos); ld += ""; pos = llListFindList(stringsName, [llList2String(ld, 3)]); ld += llList2String(stringsName, pos); } else if (llListFindList(intsName, [llList2String(ld, 1)]) != -1) { ld += llList2String(intsName, pos); ld += 0; pos = llListFindList(intsName, [llList2String(ld, 3)]); ld += llList2String(intsName, pos); } else { fail("Variable not found."); } string typeFirst = getType(llList2String(ld, 1)); string typeSecond = getType(llList2String(ld, 3)); if (typeFirst == "str" || typeSecond == "str") { if (llList2String(ld, 2) == "==") { if (llList2String(ld, 1) == llList2String(ld, 3)) {} else { return 0; } } else if (llList2String(ld, 2) == "!=") { if (llList2String(ld, 1) != llList2String(ld, 3)) {} else { return 0; } } else { fail("Can not compare two strings using the " + llList2String(ld, 2) + " opperator."); } } else { if (llList2String(ld, 2) == "==") { if (llList2String(ld, 1) == llList2String(ld, 3)) {} else { return 0; } } else if (llList2String(ld, 2) == "!=") { if (llList2String(ld, 1) != llList2String(ld, 3)) {} else { return 0; } } else if (llList2String(ld, 2) == "<") { if ((integer)llList2String(ld, 1) < (integer)llList2String(ld, 3)) {} else { return 0; } } else if (llList2String(ld, 2) == ">") { if ((integer)llList2String(ld, 1) > (integer)llList2String(ld, 3)) {} else { return 0; } } else if (llList2String(ld, 2) == "<=") { if ((integer)llList2String(ld, 1) <= (integer)llList2String(ld, 3)) {} else { return 0; } } else if (llList2String(ld, 2) == ">=") { if ((integer)llList2String(ld, 1) >= (integer)llList2String(ld, 3)) {} else { return 0; } } else { fail("Can not compare two ints using the " + llList2String(ld, 2) + " opperator."); } } i++; } return 1; } default { touch_start(integer i) { llSay(0, "Starting Program..."); kQuery = llGetNotecardLine("Program", iLine); } dataserver(key query_id, string data) { if (query_id == kQuery) { if (data == EOF) { llSay(0, "Ending Program."); } else { if (data == ":") ifStack = llListReplaceList(ifStack, [], llGetListLength(ifStack) - 1, llGetListLength(ifStack) - 1); if (ifTest()) { list ld = llParseString2List(data, [" "], []); if (llList2String(ld, 0) == "str") { stringsName += llList2String(ld, 1); strings += llList2String(ld, 2); } else if (llList2String(ld, 0) == "int") { intsName += (integer)llList2String(ld, 1); ints += (integer)llList2String(ld, 2); } else if (llList2String(ld, 0) == "?") { ifStack += data; } else if (llList2String(ld, 0) == "say") { if (llGetSubString(llList2String(ld, 1), 0, 0) == "\"") { llSay(0, llGetSubString(llList2String(ld, 1), 1, -2)); } else { string type = getType(llList2String(ld, 3)); if (type == "str") { integer pos = llListFindList(stringsName, [llList2String(ld, 1)]); if (pos != -1) llSay(0, llList2String(strings, pos)); } else { integer pos = llListFindList(intsName, [llList2String(ld, 1)]); if (pos != -1) llSay(0, (string)llList2Integer(ints, pos)); } } } else { } ++iLine; kQuery = llGetNotecardLine("My Notecard", iLine); } } } }