Difference between revisions of "Czervik LSL Computer"

From Second Life Wiki
Jump to navigation Jump to search
m (typos and grammar)
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
The below code is some code being written by [[User:Xaviar Czervik|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.
The below code is some code being written by [[User:Xaviar Czervik|Xaviar Czervik]]. It isn't even partially done, and if 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 in crashing the LSL compiler (This code doesn't compile 99% of the time) check out the code below. And in case you couldn't tell, I don't believe in comments.




<pre>
<lsl>
key kQuery;
key kQuery;
integer iLine = 0;
integer iLine = 0;
Line 15: Line 15:
string getType(string s) {
string getType(string s) {
     if ((string)((integer)s) == s)
     if ((string)((integer)s) == s)
return "int";
    return "int";
     return "str";
     return "str";
}
}
Line 26: Line 26:
integer ifTest() {
integer ifTest() {
     integer i = 0;
     integer i = 0;
    if (llGetListLength(ifStack) == 0)
        return 1;
     while (i < llGetListLength(ifStack)) {
     while (i < llGetListLength(ifStack)) {
string ifStr = llList2String(ifStack, 0);
        string ifStr = llList2String(ifStack, 0);
list ll = llParseString2List(ifStr, [" "], []);
        list ll = llParseString2List(ifStr, [" "], []);
list ld = [];
        list ld = [];
integer pos;
        integer pos;
pos = llListFindList(stringsName, [llList2String(ld, 1)]);
        pos = llListFindList(stringsName, [llList2String(ll, 1)]);
if (pos != -1) {
        llOwnerSay("Looking up '" + llList2String(ll, 1) + "'.");
    ld += llList2String(stringsName, pos);
        if (pos != -1) {
    ld += "";
            ld += llList2String(stringsName, pos);
    pos = llListFindList(stringsName, [llList2String(ld, 3)]);
            ld += "";
    ld += llList2String(stringsName, pos);
            pos = llListFindList(stringsName, [llList2String(ll, 3)]);
} else if (llListFindList(intsName, [llList2String(ld, 1)]) != -1) {
            ld += llList2String(stringsName, pos);
    ld += llList2String(intsName, pos);
        } else if (llListFindList(intsName, [llList2String(ll, 1)]) != -1) {
    ld += 0;
            ld += llList2String(intsName, pos);
    pos = llListFindList(intsName, [llList2String(ld, 3)]);
            ld += 0;
    ld += llList2String(intsName, pos);
            pos = llListFindList(intsName, [llList2String(ll, 3)]);
} else {
            ld += llList2String(intsName, pos);
    fail("Variable not found.");
        } else {
}
            fail("Variable not found on line " + (string)iLine + ".");
 
        }
string typeFirst  = getType(llList2String(ld, 1));
        string typeFirst  = getType(llList2String(ld, 1));
string typeSecond = getType(llList2String(ld, 3));
        string typeSecond = getType(llList2String(ld, 3));
    if (typeFirst == "str" || typeSecond == "str") {
        if (typeFirst == "str" || typeSecond == "str") {
if (llList2String(ld, 2) == "==") {
            if (llList2String(ld, 2) == "==") {
    if (llList2String(ld, 1) == llList2String(ld, 3)) {} else {
                if (llList2String(ld, 1) == llList2String(ld, 3)) {} else {
return 0;
                    return 0;
    }
                }
} else if (llList2String(ld, 2) == "!=") {
            } else if (llList2String(ld, 2) == "!=") {
    if (llList2String(ld, 1) != llList2String(ld, 3)) {} else {
                if (llList2String(ld, 1) != llList2String(ld, 3)) {} else {
return 0;
                    return 0;
    }
                }
} else {
            } else {
    fail("Can not compare two strings using the " + llList2String(ld, 2) + " opperator.");
                fail("Can not compare two strings using the " + llList2String(ld, 2) + " opperator.");
}
            }
    } else {
        } else {
if (llList2String(ld, 2) == "==") {
            if (llList2String(ld, 2) == "==") {
    if (llList2String(ld, 1) == llList2String(ld, 3)) {} else {
                if (llList2String(ld, 1) == llList2String(ld, 3)) {} else {
return 0;
                    return 0;
    }
                }
} else if (llList2String(ld, 2) == "!=") {
            } else if (llList2String(ld, 2) == "!=") {
    if (llList2String(ld, 1) != llList2String(ld, 3)) {} else {
                if (llList2String(ld, 1) != llList2String(ld, 3)) {} else {
return 0;
                    return 0;
    }
                }
} else if (llList2String(ld, 2) == "<") {
            } else if (llList2String(ld, 2) == "<") {
    if ((integer)llList2String(ld, 1) < (integer)llList2String(ld, 3)) {} else {
                if ((integer)llList2String(ld, 1) < (integer)llList2String(ld, 3)) {} else {
return 0;
                    return 0;
    }
                }
} else if (llList2String(ld, 2) == ">") {
            } else if (llList2String(ld, 2) == ">") {
    if ((integer)llList2String(ld, 1) > (integer)llList2String(ld, 3)) {} else {
                if ((integer)llList2String(ld, 1) > (integer)llList2String(ld, 3)) {} else {
return 0;
                    return 0;
    }
                }
} else if (llList2String(ld, 2) == "<=") {
            } else if (llList2String(ld, 2) == "<=") {
    if ((integer)llList2String(ld, 1) <= (integer)llList2String(ld, 3)) {} else {
                if ((integer)llList2String(ld, 1) <= (integer)llList2String(ld, 3)) {} else {
return 0;
                    return 0;
    }
                }
} else if (llList2String(ld, 2) == ">=") {
            } else if (llList2String(ld, 2) == ">=") {
    if ((integer)llList2String(ld, 1) >= (integer)llList2String(ld, 3)) {} else {
                if ((integer)llList2String(ld, 1) >= (integer)llList2String(ld, 3)) {} else {
return 0;
                    return 0;
    }
                }
} else {
            } else {
    fail("Can not compare two ints using the " + llList2String(ld, 2) + " opperator.");
                fail("Can not compare two ints using the " + llList2String(ld, 2) + " opperator.");
}
            }
    }
        }
i++;
        i++;
     }
     }
     return 1;
     return 1;
Line 98: Line 100:
         llSay(0, "Starting Program...");
         llSay(0, "Starting Program...");
         kQuery = llGetNotecardLine("Program", iLine);
         kQuery = llGetNotecardLine("Program", iLine);
    }
   
    changed(integer i) {
        llResetScript();
     }
     }


     dataserver(key query_id, string data) {
     dataserver(key query_id, string data) {
         if (query_id == kQuery) {
         llOwnerSay(data);
            if (data == EOF) {     
        if (data == EOF) {     
                llSay(0, "Ending Program.");
            llSay(0, "Ending Program.");
            } else {  
        } else {
if (data == ":")
            if (data == ":")
    ifStack = llListReplaceList(ifStack, [], llGetListLength(ifStack) - 1, llGetListLength(ifStack) - 1);
                ifStack = llListReplaceList(ifStack, [], llGetListLength(ifStack) - 1, llGetListLength(ifStack) - 1);
if (ifTest()) {
            if (ifTest()) {
list ld = llParseString2List(data, [" "], []);
                list ld = llParseString2List(data, [" "], []);
if (llList2String(ld, 0) == "str") {
                if (llList2String(ld, 0) == "str") {
    stringsName += llList2String(ld, 1);
                    llOwnerSay("Init: " + llList2String(ld, 1));
    strings += llList2String(ld, 2);
                    stringsName += llList2String(ld, 1);
} else if (llList2String(ld, 0) == "int") {
                    strings += llGetSubString(llList2String(ld, 3), 1, -2);
    intsName += (integer)llList2String(ld, 1);
                    llOwnerSay("-----VAR: " + llList2CSV(strings));
    ints += (integer)llList2String(ld, 2);
                } else if (llList2String(ld, 0) == "int") {
} else if (llList2String(ld, 0) == "?") {
                    intsName += (integer)llList2String(ld, 1);
    ifStack += data;
                    ints += (integer)llList2String(ld, 3);
} else if (llList2String(ld, 0) == "say") {
                } else if (llList2String(ld, 0) == "?") {
    if (llGetSubString(llList2String(ld, 1), 0, 0) == "\"") {
                    ifStack += data;
llSay(0, llGetSubString(llList2String(ld, 1), 1, -2));
                } else if (llList2String(ld, 0) == "say") {
    } else {
                    llOwnerSay("Say: " + data);
        string type = getType(llList2String(ld, 3));
                    integer pos = llListFindList(stringsName, [llList2String(ld, 1)]);
        if (type == "str") {
                    if (pos != -1) {
    integer pos = llListFindList(stringsName, [llList2String(ld, 1)]);
                        llSay(0, llList2String(strings, pos));
    if (pos != -1)
                    } else {
        llSay(0, llList2String(strings, pos));
                        integer pos = llListFindList(intsName, [(integer)llList2String(ld, 1)]);
} else {
                        if (pos != -1)
    integer pos = llListFindList(intsName, [llList2String(ld, 1)]);
                            llSay(0, (string)llList2Integer(ints, pos));
    if (pos != -1)
                    }
        llSay(0, (string)llList2Integer(ints, pos));
                } else {
}
                    llOwnerSay("AAAA");
    }
                    llOwnerSay("-----NAME: " + llList2CSV(stringsName));
} else {
                    integer pos = llListFindList(stringsName, [llList2String(ld, 0)]);
   
                    llOwnerSay(llList2String(ld, 0));
}
                    if (pos != -1) {
                ++iLine;
                        if (llList2String(ld, 1) == "=") {
                kQuery = llGetNotecardLine("My Notecard", iLine);
                            llOwnerSay("-----VAR: " + llList2CSV(strings));
                            llListReplaceList(strings, [llList2String(ld, 2)], pos-1, pos-1);
                            llOwnerSay("-----VAR: " + llList2CSV(strings));
                        }
                    } else {
                        integer pos = llListFindList(intsName, [(integer)llList2String(ld, 0)]);
                        if (pos != -1) {
                            if (llList2String(ld, 1) == "=") {
                                llListReplaceList(ints, [(integer)llList2String(ld, 2)], pos, pos);
                            }
                        } else {
                            fail("Variable not found on line " + (string)iLine + ".");
                        }
                    }
                }
                   
            } else {
             }
             }
            ++iLine;
            kQuery = llGetNotecardLine("Program", iLine);
         }
         }
     }
     }
}
}
</pre>
</lsl>

Latest revision as of 15:04, 30 March 2008

The below code is some code being written by Xaviar Czervik. It isn't even partially done, and if 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 in crashing the LSL compiler (This code doesn't compile 99% of the time) check out the code below. And in case you couldn't tell, I don't believe in comments.


<lsl> 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;
   if (llGetListLength(ifStack) == 0)
       return 1;
   while (i < llGetListLength(ifStack)) {
       string ifStr = llList2String(ifStack, 0);
       list ll = llParseString2List(ifStr, [" "], []);
       list ld = [];
       integer pos;
       pos = llListFindList(stringsName, [llList2String(ll, 1)]);
       llOwnerSay("Looking up '" + llList2String(ll, 1) + "'.");
       if (pos != -1) {
           ld += llList2String(stringsName, pos);
           ld += "";
           pos = llListFindList(stringsName, [llList2String(ll, 3)]);
           ld += llList2String(stringsName, pos);
       } else if (llListFindList(intsName, [llList2String(ll, 1)]) != -1) {
           ld += llList2String(intsName, pos);
           ld += 0;
           pos = llListFindList(intsName, [llList2String(ll, 3)]);
           ld += llList2String(intsName, pos);
       } else {
           fail("Variable not found on line " + (string)iLine + ".");
       }
       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);
   }
   
   changed(integer i) {
       llResetScript();
   }
   dataserver(key query_id, string data) {
       llOwnerSay(data);
       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") {
                   llOwnerSay("Init: " + llList2String(ld, 1));
                   stringsName += llList2String(ld, 1);
                   strings += llGetSubString(llList2String(ld, 3), 1, -2);
                   llOwnerSay("-----VAR: " + llList2CSV(strings));
               } else if (llList2String(ld, 0) == "int") {
                   intsName += (integer)llList2String(ld, 1);
                   ints += (integer)llList2String(ld, 3);
               } else if (llList2String(ld, 0) == "?") {
                   ifStack += data;
               } else if (llList2String(ld, 0) == "say") {
                   llOwnerSay("Say: " + data);
                   integer pos = llListFindList(stringsName, [llList2String(ld, 1)]);
                   if (pos != -1) {
                       llSay(0, llList2String(strings, pos));
                   } else {
                       integer pos = llListFindList(intsName, [(integer)llList2String(ld, 1)]);
                       if (pos != -1)
                           llSay(0, (string)llList2Integer(ints, pos));
                   }
               } else {
                   llOwnerSay("AAAA");
                   llOwnerSay("-----NAME: " + llList2CSV(stringsName));
                   integer pos = llListFindList(stringsName, [llList2String(ld, 0)]);
                   llOwnerSay(llList2String(ld, 0));
                   if (pos != -1) {
                       if (llList2String(ld, 1) == "=") {
                           llOwnerSay("-----VAR: " + llList2CSV(strings));
                           llListReplaceList(strings, [llList2String(ld, 2)], pos-1, pos-1);
                           llOwnerSay("-----VAR: " + llList2CSV(strings));
                       }
                   } else {
                       integer pos = llListFindList(intsName, [(integer)llList2String(ld, 0)]);
                       if (pos != -1) {
                           if (llList2String(ld, 1) == "=") {
                               llListReplaceList(ints, [(integer)llList2String(ld, 2)], pos, pos);
                           }
                       } else {
                           fail("Variable not found on line " + (string)iLine + ".");
                       }
                   }
               }
                   
           } else {
           }
           ++iLine;
           kQuery = llGetNotecardLine("Program", iLine);
       }
   }

} </lsl>