Exemplo n.º 1
0
        //FOR CONDITIONAL
        public void evaluateConditions(String[] codes,int lineNumber,Hashtable symbolTable,TextView consoleText)
        {
            String value = symbolTable ["IT"].ToString();

            int i = lineNumber;
            int j;
            Boolean isComment = false;
            //fix the value of IT to a boolean;
            if (value.Equals ("WIN") || value.Equals ("FAIL")) {

            } else {
                //===If numbar Literal ===//
                Match m = Regex.Match (value, @"^\-?\d*\.\d+\s*");
                if (m.Success) {
                    if (m.Value.Equals ("0")) {//if equals to 0
                        value = "FAIL";
                    } else {
                        value = "WIN";
                    }
                }

                //===If numbr Literal ===//
                m = Regex.Match (value, @"^\-?\d+\s*");
                if (m.Success) {
                    if (m.Value.Equals ("0")) {// equals to 0
                        value = "FAIL";
                    } else {
                        value = "WIN";
                    }
                }

                //===If string Literal ===//
                m = Regex.Match (value, @"^\s*""");
                if (m.Success) {
                    if (value [1].Equals ("\"")) {//if empty string
                        value = "FAIL";
                    } else {
                        value = "WIN";
                    }
                }
            }

            for (; i<codes.Length; i++) {
                Match m = Regex.Match (codes[i], @"^\s*YA\s+RLY\s*");
                if (m.Success && value.Equals("WIN")) {
                    j = i+1;	//new line i scan;
                    for(; j < codes.Length ; j++) {

                        //IF MEBBE OR NO WAI OR OIC IS DETECTED
                        Match n = Regex.Match(codes[j],@"^\s*MEBBE\s*");
                        Match o = Regex.Match (codes [j], @"^\s*NO\s+WAI\s*");
                        Match p = Regex.Match (codes [j], @"^\s*OIC\s*$");
                        Match q = Regex.Match (codes [j], @"^\s*NO\s+WAI\s*");
                        Match r = Regex.Match (codes[j], @"^\s*O\s+RLY\?\s*$");
                        if (n.Success || o.Success || p.Success || q.Success || r.Success) {
                            i = j;
                            break;
                        } else {
                            //ELSE, EVALUATE THE LINES!
                            ParserClass parse = new ParserClass ();
                            parse.parseLines(codes [j], ref isComment, i, ref symbolTable, ref MainWindow.symbolTree, consoleText, codes);
                        }
                        i = j;
                    }
                }

                m = Regex.Match (codes[i], @"^\s*MEBBE\s*");
                if (m.Success) {

                }

                m = Regex.Match (codes[i], @"^\s*NO\s+WAI\s*");
                if (m.Success && value.Equals("FAIL")) {
                    j = i+1;	//new line i scan;
                    for(; j < codes.Length ; j++) {
                        //IF MEBBE OR NO WAI OR OIC IS DETECTED
                        Match n = Regex.Match(codes[j],@"^\s*MEBBE\s*");
                        Match o = Regex.Match (codes [j], @"^\s*YA\s+RLY\s*");
                        Match p = Regex.Match (codes [j], @"^\s*OIC\s*$");
                        Match q = Regex.Match (codes [j], @"^\s*NO\s+WAI\s*");
                        Match r = Regex.Match (codes[j], @"^\s*O\s+RLY\?\s*$");
                        if (n.Success || o.Success || p.Success || q.Success || r.Success) {
                        //	consoleText.Buffer.Text += "STOP!\n";
                            i = j;
                            break;
                        } else {
                            //ELSE, EVALUATE THE LINES!
                            ParserClass parse = new ParserClass ();
                            parse.parseLines(codes [j], ref isComment, i, ref symbolTable, ref MainWindow.symbolTree, consoleText, codes);
                        }
                        i = j;
                    }
                }

                m = Regex.Match (codes [i], @"^\s*OIC\s*$");
                if (m.Success) {
                    MainWindow.detectedOIC = true;
                    MainWindow.newIndex = i;
                    //consoleText.Buffer.Text += "EVERYTHING IS DONE\n";
                    break;
                }
            }
        }
Exemplo n.º 2
0
        //SWITCH CASES FNCTION
        public void evaluateCASES(String[] codes,int lineNumber, Hashtable symbolTable, TextView consoleText)
        {
            //get value of IT
            String value = symbolTable ["IT"].ToString();
            Boolean matched = false;
            int i = lineNumber;
            int j;
            int DEFAULT = -1;
            Boolean isComment = false;
            String LITERAL = "";

            if (value.Equals ("WIN") || value.Equals ("FAIL")) {
                LITERAL = "BOOLEAN";
            } else {
                //===If numbar Literal ===//
                Match m = Regex.Match (value, @"^\-?\d*\.\d+\s*");
                if (m.Success) {
                    LITERAL = "NUMBER";
                }

                //===If numbr Literal ===//
                m = Regex.Match (value, @"^\-?\d+\s*");
                if (m.Success) {
                    LITERAL = "NUMBER";
                }

                //===If string Literal ===//
                m = Regex.Match (value, @"^\s*""");
                if (m.Success) {
                    LITERAL = "STRING";
                }
                consoleText.Buffer.Text += LITERAL + "\n";
            }
            j = i;
            for (;j<codes.Length;j++) {
                //j ANG MINAMANIPULATE NATIN DITO JAMES!
                Match m = Regex.Match (codes [j], @"^\s*OMG\s*");
                if (m.Success) {
                    String variable = codes [j];
                    variable = variable.Trim ();
                    variable = variable.Remove (0, m.Value.Length);
                    //consoleText.Buffer.Text += variable + "AND" +value+"\n";
                    if (variable.Equals (value)) {
                        //EQUAL SIYA KAY VAR SO i-EXECUTE NATIN YUNG CODE SA ILALIM NIYA!!!
                        //VVV J+1 ==== NASA ILALIM NI OMG <?>
                        for(var x=j+1;x<codes.Length;x++){
                            //Match z = Regex.Match (codes[x], @"^\s*OMGWTF\s*");
                            Match n = Regex.Match (codes[x], @"^\s*GTFO\s*");
                            Match o = Regex.Match (codes [x], @"^\s*OIC\s*");
                            if (n.Success||o.Success) {

                                break;
                            }
                            ParserClass parse = new ParserClass ();
                            parse.parseLines (codes [x],ref isComment,i, ref symbolTable, ref MainWindow.symbolTree, consoleText, codes);
                            j = x;
                        }
                        matched = true;
                    }
                }
                m = Regex.Match (codes[j], @"^\s*OMGWTF\s*");
                if (m.Success) {
                    DEFAULT = j;
                }

                m = Regex.Match (codes [j], @"^\s*OIC\s*$");
                if (m.Success) {
                    if (!matched) {
                        if (DEFAULT > 0) {
                            //IF MAY DEFAULT (OMGWTF)
                            //DEFAULT AY LOCATION NI OMGWTF
                            //DEFAULT + 1 = ILALIM NIYA NA STATEMENT. EXECUTE TIL END OF STATEMENT!
                            for (var x=DEFAULT+1; x<codes.Length; x++) {
                                Match z = Regex.Match (codes [x], @"^\s*OMG\s*");
                                Match n = Regex.Match (codes [x], @"^\s*GTFO\s*");
                                Match o = Regex.Match (codes [x], @"^\s*OIC\s*");
                                if (n.Success || o.Success || z.Success) {

                                    break;
                                }
                                ParserClass parse = new ParserClass ();
                                parse.parseLines (codes [x], ref isComment, i, ref symbolTable, ref MainWindow.symbolTree, consoleText, codes);
                                j = x+1;
                            }

                        }
                    }
                        //IF NO VALUE WAS MATCHED HEHEHEHE!!!
                        MainWindow.detectedOIC = true;
                        MainWindow.newIndex = j;

                        break;

                }
            }
        }