Exemplo n.º 1
0
    public static void FindUserFunctions(string[] text)
    {
        Struct tempS;
        string name = "", type = "";

        for (int i = 0; i < text.Length; i++)
        {
            string temp = text[i].Replace("private ", "").Replace("static ", "").Replace("public ", "").Replace("operator ", "").Trim();
            if (temp.Length >= 9 && temp.Substring(0, 9) == "function " && temp.IndexOf("takes") != -1 && temp.IndexOf("returns") != -1)
            {
                temp = temp.Substring(9, temp.Length - 9);
                type = temp.Substring(temp.IndexOf("returns") + 8, temp.Length - temp.IndexOf("returns") - 8);
                if (type != "nothing" && type != "void")
                {
                    name = temp.Substring(0, temp.IndexOf(' '));
                    JData.Add(name, type);
                    //Types.AddFunc(name, type);
                }
            }
            else if (temp.Length >= 7 && temp.Substring(0, 7) == "method " && temp.IndexOf("takes") != -1 && temp.IndexOf("returns") != -1)
            {
                temp = temp.Substring(7, temp.Length - 7);
                type = temp.Substring(temp.IndexOf("returns") + 8, temp.Length - temp.IndexOf("returns") - 8);
                if (type != "nothing" && type != "void")
                {
                    name = temp.Substring(0, temp.IndexOf(' ')).Trim();
                    JData.Add(name, type);
                    //Types.AddFunc(name, type);
                }
            }
            else if (temp.Length >= 7 && temp.Substring(0, 7) == "struct ")
            {
                int close = i + 1;
                if (temp[temp.Length - 1] == '{' || text[i + 1].Trim() == "{")
                {
                    close = Analyzer.FindBraces(text, i);
                }
                else
                {
                    for (int j = i; j < text.Length; j++)
                    {
                        if (text[j].Trim() == "endstruct")
                        {
                            close = j - 1;
                            break;
                        }
                    }
                }
                tempS = new Struct();
                tempS.FindVars(text, i, close);
                tempS.FindMethods(text, i, close);
                Structs.Add(tempS);
            }
            else
            {
                int index  = temp.IndexOf(' ');
                int bIndex = temp.IndexOf('(');
                if (index != -1 && index < bIndex && temp.Substring(0, index) != "define" &&
                    temp.Substring(0, index) != "callback" && temp.Substring(0, index) != "lambda" &&
                    temp.Substring(0, index) != "library" && temp.Substring(0, index) != "scope" &&
                    temp.Substring(0, index) != "enum" && temp.Substring(0, index) != "struct" &&
                    temp.Substring(0, index) != "loop" && temp.Substring(0, index) != "for" &&
                    temp.Substring(0, index) != "while" && temp.Substring(0, index) != "whilenot" &&
                    temp.Substring(0, index) != "until" && temp.Substring(0, 2) != "if" &&
                    temp.Substring(0, index) != "else" && temp.Substring(0, index) != "elseif" &&
                    temp.Substring(0, index) != "call" && temp.Substring(0, index) != "set" &&
                    temp.Substring(0, index) != "return" && temp.Substring(0, index) != "exitwhen" &&
                    temp.Substring(0, index) != "local" && temp.Substring(0, index) != "void" &&
                    temp.Substring(0, index) != "nothing" && temp.IndexOf('=') == -1 &&
                    Analyzer.CountSymbolsInText("(", temp) == 1 && Analyzer.CountSymbolsInText(")", temp) == 1 &&
                    temp.IndexOf(';') == -1)
                {
                    type = temp.Substring(0, index).Trim();
                    temp = temp.Replace(type, "");
                    JData.Add(temp.Substring(0, temp.IndexOf('(')).Trim(), type);
                    //Types.AddFunc(temp.Substring(0, temp.IndexOf('(')).Trim(), type);
                }
            }
        }
    }
Exemplo n.º 2
0
    public static void FindUserFunctions(string[] text)
    {
        Struct tempS;
        string name = "", type = "";
        for (int i = 0; i < text.Length; i++)
        {
            string temp = text[i].Replace("private ", "").Replace("static ", "").Replace("public ", "").Replace("operator ", "").Trim();
            if (temp.Length >= 9 && temp.Substring(0, 9) == "function " && temp.IndexOf("takes") != -1 && temp.IndexOf("returns") != -1)
            {
                temp = temp.Substring(9, temp.Length - 9);
                type = temp.Substring(temp.IndexOf("returns") + 8, temp.Length - temp.IndexOf("returns") - 8);
                if (type != "nothing" && type != "void")
                {
                    name = temp.Substring(0, temp.IndexOf(' '));
                    JData.Add(name, type);
                    //Types.AddFunc(name, type);
                }
            }
            else if (temp.Length >= 7 && temp.Substring(0, 7) == "method " && temp.IndexOf("takes") != -1 && temp.IndexOf("returns") != -1)
            {
                temp = temp.Substring(7, temp.Length - 7);
                type = temp.Substring(temp.IndexOf("returns") + 8, temp.Length - temp.IndexOf("returns") - 8);
                if (type != "nothing" && type != "void")
                {
                    name = temp.Substring(0, temp.IndexOf(' ')).Trim();
                    JData.Add(name, type);
                    //Types.AddFunc(name, type);
                }
            }
            else if (temp.Length >= 7 && temp.Substring(0, 7) == "struct ")
            {
                int close = i + 1;
                if (temp[temp.Length - 1] == '{' || text[i + 1].Trim() == "{")
                    close = Analyzer.FindBraces(text, i);
                else
                    for (int j = i; j < text.Length; j++)
                        if (text[j].Trim() == "endstruct")
                        {
                            close = j - 1;
                            break;
                        }
                tempS = new Struct();
                tempS.FindVars(text, i, close);
                tempS.FindMethods(text, i, close);
                Structs.Add(tempS);
            }
            else
            {
                int index = temp.IndexOf(' ');
                int bIndex = temp.IndexOf('(');
                if (index != -1 && index < bIndex && temp.Substring(0, index) != "define" &&
                    temp.Substring(0, index) != "callback" && temp.Substring(0, index) != "lambda" &&
                    temp.Substring(0, index) != "library" && temp.Substring(0, index) != "scope" &&
                    temp.Substring(0, index) != "enum" && temp.Substring(0, index) != "struct" &&
                    temp.Substring(0, index) != "loop" && temp.Substring(0, index) != "for" &&
                    temp.Substring(0, index) != "while" && temp.Substring(0, index) != "whilenot" &&
                    temp.Substring(0, index) != "until" && temp.Substring(0, 2) != "if" &&
                    temp.Substring(0, index) != "else" && temp.Substring(0, index) != "elseif" &&
                    temp.Substring(0, index) != "call" && temp.Substring(0, index) != "set" &&
                    temp.Substring(0, index) != "return" && temp.Substring(0, index) != "exitwhen" &&
                    temp.Substring(0, index) != "local" && temp.Substring(0, index) != "void" &&
                    temp.Substring(0, index) != "nothing" && temp.IndexOf('=') == -1 &&
                    Analyzer.CountSymbolsInText("(", temp) == 1 && Analyzer.CountSymbolsInText(")", temp) == 1 &&
                    temp.IndexOf(';') == -1)
                {
                    type = temp.Substring(0, index).Trim();
                    temp = temp.Replace(type, "");
                    JData.Add(temp.Substring(0, temp.IndexOf('(')).Trim(), type);
                    //Types.AddFunc(temp.Substring(0, temp.IndexOf('(')).Trim(), type);
                }
            }

        }
    }