Example #1
0
        internal static void Start(Line line, int startPos, Dictionary <string, Variable> variables)
        {
            LastIndex = 0;
            bool logic         = true;
            var  type          = VariableType.NON;
            bool math          = true;
            bool plus          = false;
            bool addMath       = false;
            bool firstOperand  = true;
            bool doubleOperand = false;
            bool oneOperand    = false;

            for (int i = startPos; i < line.Count; i++)
            {
                var word = line.Words[i];

                if (word.Token == Tokens.BOOLOPERATOR || word.Token == Tokens.EQU)
                {
                    oneOperand = false;

                    if (logic)
                    {
                        Data.Errors.Add(new Errore(line.Number, line.FileName, 1909, ""));
                        return;
                    }

                    if (firstOperand)
                    {
                        Data.Errors.Add(new Errore(line.Number, line.FileName, 1910, ""));
                        return;
                    }

                    if (doubleOperand)
                    {
                        Data.Errors.Add(new Errore(line.Number, line.FileName, 1912, ""));
                        return;
                    }

                    logic = true;

                    if (!math)
                    {
                        math = true;
                    }
                    else
                    {
                        if (word.Text == "-")
                        {
                            if (i != startPos + 1)
                            {
                                Data.Errors.Add(new Errore(line.Number, line.FileName, 1426, ""));
                                return;
                            }
                            else if (i - 1 >= 0 && i - 1 < line.Count && line.Words[i - 1].Token != Tokens.BRACKETLEFT)
                            {
                                Data.Errors.Add(new Errore(line.Number, line.FileName, 1426, ""));
                                return;
                            }
                        }
                    }

                    continue;
                }
                if (word.Token == Tokens.MATHOPERATOR)
                {
                    if (i - 1 >= 0 && line.Words[i - 1].Token != Tokens.VARIABLE && line.Words[i - 1].Token != Tokens.NUMBER && line.Words[i - 1].Token != Tokens.METHOD && line.Words[i - 1].Token != Tokens.STRING && line.Words[i - 1].Token != Tokens.BRACKETRIGHT && line.Words[i - 1].Token != Tokens.BRACKETRIGHTARRAY && line.Words[i - 1].Token != Tokens.DOUBLEBRACKET && line.Words[i - 1].Token != Tokens.DOUBLEBRACKETARRAY)
                    {
                        if (word.Text != "-")
                        {
                            Data.Errors.Add(new Errore(line.Number, line.FileName, 1409, ""));
                            return;
                        }
                    }

                    addMath = true;

                    if (!firstOperand && !doubleOperand && !logic)
                    {
                        firstOperand = true;
                        oneOperand   = true;
                    }
                    else if (!firstOperand && doubleOperand)
                    {
                        doubleOperand = false;
                    }

                    logic = true;

                    plus = false;
                    if (word.Text == "+")
                    {
                        plus = true;
                    }

                    if (!math)
                    {
                        math = true;
                    }
                    else
                    {
                        if (word.Text == "-")
                        {
                            if (i + 1 < line.Count && line.Words[i + 1].Token != Tokens.NUMBER && line.Words[i + 1].Token != Tokens.VARIABLE && line.Words[i + 1].Token != Tokens.METHOD)
                            {
                                Data.Errors.Add(new Errore(line.Number, line.FileName, 1426, "2"));
                                return;
                            }
                        }
                    }
                }
                else if (word.Token == Tokens.NUMBER)
                {
                    if ((!firstOperand && doubleOperand) || doubleOperand)
                    {
                        Data.Errors.Add(new Errore(line.Number, line.FileName, 1912, ""));
                        return;
                    }

                    if (!doubleOperand && !firstOperand)
                    {
                        doubleOperand = true;
                        oneOperand    = false;
                    }
                    if (firstOperand)
                    {
                        firstOperand = false;
                    }

                    if (!logic)
                    {
                        Data.Errors.Add(new Errore(line.Number, line.FileName, 1905, ""));
                        return;
                    }

                    logic = false;

                    if (math)
                    {
                        math = false;
                    }
                    else
                    {
                        Data.Errors.Add(new Errore(line.Number, line.FileName, 1426, ""));
                        return;
                    }

                    if (type == VariableType.NON)
                    {
                        type = VariableType.NUMBER;
                    }
                    else if (type != VariableType.NUMBER && type != VariableType.ANY)
                    {
                        Data.Errors.Add(new Errore(line.Number, line.FileName, 1407, ""));
                        return;
                    }
                }
                else if (word.Token == Tokens.STRING)
                {
                    oneOperand = true;

                    if (!logic)
                    {
                        Data.Errors.Add(new Errore(line.Number, line.FileName, 1905, ""));
                        return;
                    }

                    if (!plus && addMath)
                    {
                        Data.Errors.Add(new Errore(line.Number, line.FileName, 1417, ""));
                        return;
                    }

                    logic = false;

                    if (math)
                    {
                        math = false;
                    }
                    else
                    {
                        Data.Errors.Add(new Errore(line.Number, line.FileName, 1426, ""));
                        return;
                    }

                    if (type == VariableType.NON)
                    {
                        type = VariableType.STRING;
                    }
                    else if (type != VariableType.STRING && type != VariableType.ANY)
                    {
                        Data.Errors.Add(new Errore(line.Number, line.FileName, 1407, ""));
                        return;
                    }
                }
                else if (word.Token == Tokens.VARIABLE)
                {
                    if ((!firstOperand && doubleOperand) || doubleOperand)
                    {
                        Data.Errors.Add(new Errore(line.Number, line.FileName, 1912, ""));
                        return;
                    }

                    if (!doubleOperand && !firstOperand)
                    {
                        doubleOperand = true;
                        oneOperand    = false;
                    }
                    if (firstOperand)
                    {
                        firstOperand = false;
                    }

                    if (!logic)
                    {
                        Data.Errors.Add(new Errore(line.Number, line.FileName, 1905, ""));
                        return;
                    }

                    logic = false;

                    if (math)
                    {
                        math = false;
                    }
                    else
                    {
                        Data.Errors.Add(new Errore(line.Number, line.FileName, 1426, ""));
                        return;
                    }

                    if (!variables.ContainsKey(word.Text))
                    {
                        Data.Errors.Add(new Errore(line.Number, line.FileName, 1405, "( " + word.OriginText + " )"));
                        return;
                    }
                    else
                    {
                        var v = variables[word.Text];
                        if (v.Type == VariableType.NUMBER_ARRAY)
                        {
                            if (i + 1 < line.Count && line.Words[i + 1].Token == Tokens.BRACKETLEFTARRAY)
                            {
                                ArrayIndexErrorParser.Start(line, i + 1, variables);
                                if (Data.Errors.Count > 0)
                                {
                                    return;
                                }

                                i = ArrayIndexErrorParser.LastIndex;

                                if (type == VariableType.NON)
                                {
                                    type = VariableType.NUMBER;
                                }
                                else if (type != VariableType.NUMBER && type != VariableType.ANY)
                                {
                                    Data.Errors.Add(new Errore(line.Number, line.FileName, 1407, ""));
                                    return;
                                }

                                if (line.Words[LastIndex].Token == Tokens.BRACKETRIGHTARRAY)
                                {
                                    continue;
                                }
                            }
                            else
                            {
                                Data.Errors.Add(new Errore(line.Number, line.FileName, 1906, "( " + word.Text + " )"));
                                return;
                            }
                        }
                        else if (v.Type == VariableType.STRING_ARRAY)
                        {
                            if (i + 1 < line.Count && line.Words[i + 1].Token == Tokens.BRACKETLEFTARRAY)
                            {
                                ArrayIndexErrorParser.Start(line, i + 1, variables);
                                if (Data.Errors.Count > 0)
                                {
                                    return;
                                }

                                i = ArrayIndexErrorParser.LastIndex;

                                if (!plus && addMath)
                                {
                                    Data.Errors.Add(new Errore(line.Number, line.FileName, 1417, ""));
                                    return;
                                }

                                if (type == VariableType.NON)
                                {
                                    type = VariableType.STRING;
                                }
                                else if (type != VariableType.STRING && type != VariableType.ANY)
                                {
                                    Data.Errors.Add(new Errore(line.Number, line.FileName, 1407, ""));
                                    return;
                                }

                                if (line.Words[LastIndex].Token == Tokens.BRACKETRIGHTARRAY)
                                {
                                    continue;
                                }
                            }
                            else
                            {
                                Data.Errors.Add(new Errore(line.Number, line.FileName, 1906, "( " + word.Text + " )"));
                                return;
                            }
                        }
                        else if (v.Type == VariableType.NUMBER)
                        {
                            if (type == VariableType.NON)
                            {
                                type = VariableType.NUMBER;
                            }
                            else if (type != VariableType.NUMBER && type != VariableType.ANY)
                            {
                                Data.Errors.Add(new Errore(line.Number, line.FileName, 1407, ""));
                                return;
                            }
                        }
                        else if (v.Type == VariableType.STRING)
                        {
                            if (!plus && addMath)
                            {
                                Data.Errors.Add(new Errore(line.Number, line.FileName, 1417, ""));
                                return;
                            }

                            if (type == VariableType.NON)
                            {
                                type = VariableType.STRING;
                            }
                            else if (type != VariableType.STRING && type != VariableType.ANY)
                            {
                                Data.Errors.Add(new Errore(line.Number, line.FileName, 1407, ""));
                                return;
                            }
                        }
                        else
                        {
                            Data.Errors.Add(new Errore(line.Number, line.FileName, 1906, "( " + word.Text + " )"));
                            return;
                        }
                    }
                }
                else if (word.Token == Tokens.METHOD)
                {
                    if ((!firstOperand && doubleOperand) || doubleOperand)
                    {
                        Data.Errors.Add(new Errore(line.Number, line.FileName, 1912, ""));
                        return;
                    }

                    //Console.WriteLine("=> " + firstOperand + "  " + doubleOperand);
                    if (!doubleOperand && !firstOperand)
                    {
                        doubleOperand = true;
                        oneOperand    = false;
                    }
                    if (firstOperand)
                    {
                        firstOperand = false;
                    }
                    //Console.WriteLine("=> " + firstOperand + "  " + doubleOperand);

                    if (!logic)
                    {
                        Data.Errors.Add(new Errore(line.Number, line.FileName, 1905, ""));
                        return;
                    }

                    logic = false;

                    if (math)
                    {
                        math = false;
                    }
                    else
                    {
                        Data.Errors.Add(new Errore(line.Number, line.FileName, 1426, ""));
                        return;
                    }

                    var lastIndex = MethodErrorParser.GetMethodLastIndex(i, line, word.Text);
                    var param     = MethodErrorParser.GetParam(i, lastIndex, line);
                    MethodErrorParser.Start(param, word.Text, variables, line);

                    if (Data.Errors.Count > 0)
                    {
                        return;
                    }

                    var sign = DefaultObjectList.Objects[word.ToLower()];

                    if (sign.OutputType == VariableType.NON)
                    {
                        Data.Errors.Add(new Errore(line.Number, line.FileName, 1313, ""));
                        return;
                    }
                    else if (sign.OutputType == VariableType.STRING)
                    {
                        //Console.WriteLine("=> " + oneOperand);

                        if (!plus && addMath)
                        {
                            Data.Errors.Add(new Errore(line.Number, line.FileName, 1417, ""));
                            return;
                        }
                    }

                    i = lastIndex;

                    if (type == VariableType.NON)
                    {
                        type = sign.OutputType;
                    }
                    else if (sign.OutputType != VariableType.ANY && type != sign.OutputType)
                    {
                        Data.Errors.Add(new Errore(line.Number, line.FileName, 1407, ""));
                        return;
                    }

                    if (sign.OutputType == VariableType.ANY || sign.OutputType == VariableType.STRING)
                    {
                        if (!doubleOperand)
                        {
                            oneOperand = true;
                        }
                    }
                }
                else if (word.Token == Tokens.BRACKETLEFT || word.Token == Tokens.BRACKETRIGHT)
                {
                    continue;
                }
                else if (word.Token == Tokens.KEYWORD)
                {
                    if (word.ToLower() == "and" || word.ToLower() == "or" || word.ToLower() == "then")
                    {
                        if (word.ToLower() == "and" || word.ToLower() == "or")
                        {
                            if (i + 1 < line.Count && (line.Words[i + 1].ToLower() == "and" || line.Words[i + 1].ToLower() == "or" || line.Words[i + 1].ToLower() == "then"))
                            {
                                Data.Errors.Add(new Errore(line.Number, line.FileName, 1912, ""));
                                return;
                            }
                        }
                        if (logic && !doubleOperand)
                        {
                            Data.Errors.Add(new Errore(line.Number, line.FileName, 1911, ""));
                            return;
                        }
                        if (!firstOperand && !doubleOperand && !oneOperand)
                        {
                            //Console.WriteLine(firstOperand + " " + doubleOperand + " " + oneOperand);
                            Data.Errors.Add(new Errore(line.Number, line.FileName, 1911, ""));
                            return;
                        }

                        LastIndex = i;
                        return;
                    }
                    else
                    {
                        Data.Errors.Add(new Errore(line.Number, line.FileName, 1034, "( " + word.Text + " )"));
                        return;
                    }
                }
                else
                {
                    Data.Errors.Add(new Errore(line.Number, line.FileName, 1034, "( " + word.Text + " )"));
                    return;
                }
            }

            if (logic && !doubleOperand)
            {
                Data.Errors.Add(new Errore(line.Number, line.FileName, 1911, ""));
                return;
            }
            if (!firstOperand && !doubleOperand && !oneOperand)
            {
                Data.Errors.Add(new Errore(line.Number, line.FileName, 1911, ""));
                return;
            }

            LastIndex = line.Count;
        }
Example #2
0
        private static bool ParseValue(int startPos, int lastPos, Line line, Dictionary <string, Variable> variables, bool step)
        {
            bool math = true;

            for (int i = startPos; i < lastPos; i++)
            {
                var word = line.Words[i];

                if (word.Token == Tokens.BRACKETLEFTARRAY)
                {
                    ArrayIndexErrorParser.Start(line, 1, variables);
                    if (Data.Errors.Count > 0)
                    {
                        return(true);
                    }

                    i = ArrayIndexErrorParser.LastIndex;

                    if (line.Words[ArrayIndexErrorParser.LastIndex].Token == Tokens.BRACKETRIGHTARRAY)
                    {
                        continue;
                    }
                }
                else if (word.Token == Tokens.MATHOPERATOR)
                {
                    if (!math)
                    {
                        math = true;
                    }
                    else
                    {
                        if (word.Text == "-")
                        {
                            if (i == startPos && step)
                            {
                                continue;
                            }

                            if (i + 1 < line.Count && line.Words[i + 1].Token != Tokens.NUMBER && line.Words[i + 1].Token != Tokens.VARIABLE && line.Words[i + 1].Token != Tokens.METHOD)
                            {
                                Data.Errors.Add(new Errore(line.Number, line.FileName, 1426, ""));
                                return(true);
                            }
                        }
                    }
                }
                else if (word.Token == Tokens.NUMBER)
                {
                    if (math)
                    {
                        math = false;
                    }
                    else
                    {
                        Data.Errors.Add(new Errore(line.Number, line.FileName, 1426, ""));
                        return(true);
                    }
                }
                else if (word.Token == Tokens.VARIABLE)
                {
                    if (math)
                    {
                        math = false;
                    }
                    else
                    {
                        Data.Errors.Add(new Errore(line.Number, line.FileName, 1426, ""));
                        return(true);
                    }

                    if (!variables.ContainsKey(word.Text))
                    {
                        Data.Errors.Add(new Errore(line.Number, line.FileName, 1405, "( " + word.OriginText + " )"));
                        return(true);
                    }
                    else
                    {
                        var v = variables[word.Text];
                        if (v.Type == VariableType.NUMBER_ARRAY)
                        {
                            if (i + 1 < lastPos && line.Words[i + 1].Token == Tokens.BRACKETLEFTARRAY)
                            {
                                ArrayIndexErrorParser.Start(line, i + 1, variables);
                                if (Data.Errors.Count > 0)
                                {
                                    return(true);
                                }

                                i = ArrayIndexErrorParser.LastIndex;

                                if (line.Words[ArrayIndexErrorParser.LastIndex].Token == Tokens.BRACKETRIGHTARRAY)
                                {
                                    continue;
                                }
                            }
                            else
                            {
                                Data.Errors.Add(new Errore(line.Number, line.FileName, 1425, "( " + word.Text + " )"));
                                return(true);
                            }
                        }
                        else if (v.Type != VariableType.NUMBER)
                        {
                            Data.Errors.Add(new Errore(line.Number, line.FileName, 1423, "( " + word.Text + " )"));
                            return(true);
                        }
                    }
                }
                else if (word.Token == Tokens.METHOD)
                {
                    if (math)
                    {
                        math = false;
                    }
                    else
                    {
                        Data.Errors.Add(new Errore(line.Number, line.FileName, 1426, ""));
                        return(true);
                    }

                    var lastIndex = MethodErrorParser.GetMethodLastIndex(i, line, word.Text);
                    var param     = MethodErrorParser.GetParam(i, lastIndex, line);
                    MethodErrorParser.Start(param, word.Text, variables, line);

                    if (Data.Errors.Count > 0)
                    {
                        return(true);
                    }

                    var sign = DefaultObjectList.Objects[word.ToLower()];

                    if (sign.OutputType != VariableType.NUMBER)
                    {
                        if (sign.OutputType != VariableType.ANY && word.ToLower() != "f.get")
                        {
                            Data.Errors.Add(new Errore(line.Number, line.FileName, 1424, ""));
                            return(true);
                        }
                    }

                    i = lastIndex;
                }
                else if (word.Token == Tokens.BRACKETLEFT || word.Token == Tokens.BRACKETRIGHT)
                {
                    continue;
                }
                else
                {
                    Data.Errors.Add(new Errore(line.Number, line.FileName, 1427, "( " + word.Text + " )"));
                    return(true);
                }
            }

            return(false);
        }
Example #3
0
        internal static void Start(Line line, int startPos, Dictionary <string, Variable> variables)
        {
            int bracket = 0;

            LastIndex = 0;
            bool math = true;

            for (int i = startPos; i < line.Count; i++)
            {
                var word = line.Words[i];
                if (word.Token == Tokens.BRACKETLEFTARRAY)
                {
                    bracket++;
                }
                else if (word.Token == Tokens.BRACKETRIGHTARRAY)
                {
                    bracket--;
                }
                else if (word.Token == Tokens.MATHOPERATOR)
                {
                    if (!math)
                    {
                        math = true;
                    }
                    else
                    {
                        if (word.Text == "-")
                        {
                            if (i + 1 < line.Count && line.Words[i + 1].Token != Tokens.NUMBER && line.Words[i + 1].Token != Tokens.VARIABLE && line.Words[i + 1].Token != Tokens.METHOD)
                            {
                                Data.Errors.Add(new Errore(line.Number, line.FileName, 1426, ""));
                                return;
                            }
                        }
                    }
                }
                else if (word.Token == Tokens.NUMBER)
                {
                    if (math)
                    {
                        math = false;
                    }
                    else
                    {
                        Data.Errors.Add(new Errore(line.Number, line.FileName, 1426, ""));
                        return;
                    }
                }
                else if (word.Token == Tokens.VARIABLE)
                {
                    if (math)
                    {
                        math = false;
                    }
                    else
                    {
                        Data.Errors.Add(new Errore(line.Number, line.FileName, 1426, ""));
                        return;
                    }

                    if (!variables.ContainsKey(word.Text))
                    {
                        Data.Errors.Add(new Errore(line.Number, line.FileName, 1405, "( " + word.OriginText + " )"));
                        return;
                    }
                    else
                    {
                        var v = variables[word.Text];
                        if (v.Type == VariableType.NUMBER_ARRAY)
                        {
                            if (i + 1 < line.Count && line.Words[i + 1].Token == Tokens.BRACKETLEFTARRAY)
                            {
                                Start(line, i + 1, variables);
                                if (Data.Errors.Count > 0)
                                {
                                    return;
                                }

                                i = LastIndex;

                                if (line.Words[LastIndex].Token == Tokens.BRACKETRIGHTARRAY)
                                {
                                    continue;
                                }
                            }
                            else
                            {
                                Data.Errors.Add(new Errore(line.Number, line.FileName, 1425, "( " + word.Text + " )"));
                                return;
                            }
                        }
                        else if (v.Type != VariableType.NUMBER)
                        {
                            Data.Errors.Add(new Errore(line.Number, line.FileName, 1423, "( " + word.Text + " )"));
                            return;
                        }
                    }
                }
                else if (word.Token == Tokens.METHOD)
                {
                    if (math)
                    {
                        math = false;
                    }
                    else
                    {
                        Data.Errors.Add(new Errore(line.Number, line.FileName, 1426, ""));
                        return;
                    }

                    var lastIndex = MethodErrorParser.GetMethodLastIndex(i, line, word.Text);
                    var param     = MethodErrorParser.GetParam(i, lastIndex, line);
                    MethodErrorParser.Start(param, word.Text, variables, line);

                    if (Data.Errors.Count > 0)
                    {
                        return;
                    }

                    var sign = DefaultObjectList.Objects[word.ToLower()];

                    if (sign.OutputType != VariableType.NUMBER)
                    {
                        if (sign.OutputType != VariableType.ANY && word.ToLower() != "f.get")
                        {
                            Data.Errors.Add(new Errore(line.Number, line.FileName, 1424, ""));
                            return;
                        }
                    }

                    i = lastIndex;
                }
                else if (word.Token == Tokens.BRACKETLEFT || word.Token == Tokens.BRACKETRIGHT)
                {
                    continue;
                }
                else
                {
                    //Builder.Project.WriteTextAndTokens(line);
                    //Console.WriteLine(i);
                    Data.Errors.Add(new Errore(line.Number, line.FileName, 1427, "( " + word.Text + " )"));
                    return;
                }

                if (bracket == 0)
                {
                    LastIndex = i;
                    break;
                }
            }
        }
Example #4
0
        internal static bool ParseInitVarError(Line line, VariableType type, bool array, int startPos, int endPos, int minimumWords)
        {
            bool         math      = true;
            bool         plus      = false;
            bool         addMath   = false;
            string       varName   = "";
            bool         badString = false;
            var          firstType = type;
            VariableType oldType   = VariableType.NON;

            if (line.Words[0].Text.ToLower() != "for")
            {
                varName = line.Words[0].Text;
            }
            else
            {
                varName = line.Words[1].Text;
            }
            if (line.Count < minimumWords) // default 3
            {
                Data.Errors.Add(new Errore(line.Number, line.FileName, 1411, ""));
                return(true);
            }

            for (int j = startPos; j < endPos; j++) // default startPos = 2, endPos = line.Count
            {
                oldType = type;
                var word  = line.Words[j];
                var token = word.Token;
                if (token == Tokens.MATHOPERATOR)
                {
                    plus    = false;
                    addMath = true;
                    if (word.Text == "+")
                    {
                        plus = true;
                    }
                    if (word.Text == "-")
                    {
                        if (j == 2)
                        {
                            if (line.Count >= 4 && line.Words[3].Token == Tokens.NUMBER)
                            {
                                if (!Data.Project.Variables.ContainsKey(varName))
                                {
                                    //Builder.Project.MainVariables.Add(varName, new Variable() { Init = true, OldName = varName, NewName = varName, Type = VariableType.NUMBER });
                                    if (type == VariableType.NON)
                                    {
                                        type = VariableType.NUMBER;
                                    }
                                    else if (type != VariableType.NUMBER)
                                    {
                                        if (firstType == VariableType.NON)
                                        {
                                            if (type == VariableType.STRING)
                                            {
                                                badString = true;
                                                type      = VariableType.NUMBER;
                                            }
                                        }
                                        if (!badString)
                                        {
                                            Data.Errors.Add(new Errore(line.Number, line.FileName, 1407, ""));
                                            return(true);
                                        }
                                    }
                                }
                                else
                                {
                                    var v = Data.Project.Variables[varName];
                                    if (v.Type != VariableType.NUMBER)
                                    {
                                        Data.Errors.Add(new Errore(line.Number, line.FileName, 1407, ""));
                                        return(true);
                                    }
                                    return(false);
                                }
                            }
                            else
                            {
                                Data.Errors.Add(new Errore(line.Number, line.FileName, 1415, ""));
                                return(true);
                            }
                        }
                        else
                        {
                            if (!math)
                            {
                                math = true;
                            }
                            else
                            {
                                if (j + 1 < line.Words.Count && line.Words[j + 1] != null && (line.Words[j + 1].Token == Tokens.NUMBER || line.Words[j + 1].Token == Tokens.VARIABLE || line.Words[j + 1].Token == Tokens.METHOD))
                                {
                                    continue;
                                }
                                else
                                {
                                    Data.Errors.Add(new Errore(line.Number, line.FileName, 1409, "( " + word.Text + " )"));
                                    return(true);
                                }
                            }
                        }
                    }
                    else
                    {
                        if (!math)
                        {
                            math = true;
                        }
                        else
                        {
                            Data.Errors.Add(new Errore(line.Number, line.FileName, 1408, ""));
                            return(true);
                        }
                    }
                }
                else if (token == Tokens.NUMBER)
                {
                    if (!math)
                    {
                        Data.Errors.Add(new Errore(line.Number, line.FileName, 1416, ""));
                        return(true);
                    }
                    else
                    {
                        math = false;
                    }
                    if (type == VariableType.NON)
                    {
                        type = VariableType.NUMBER;
                    }
                    else if (type != VariableType.NUMBER)
                    {
                        if (firstType == VariableType.NON)
                        {
                            if (type == VariableType.STRING)
                            {
                                badString = true;
                                type      = VariableType.NUMBER;
                            }
                        }
                        else if (firstType == VariableType.STRING)
                        {
                            badString = true;
                        }

                        if (!badString)
                        {
                            //Console.WriteLine('\n');
                            //Console.WriteLine(word.OriginText);
                            Data.Errors.Add(new Errore(line.Number, line.FileName, 1407, ""));
                            return(true);
                        }
                    }
                }
                else if (token == Tokens.STRING)
                {
                    if (!math)
                    {
                        Data.Errors.Add(new Errore(line.Number, line.FileName, 1416, ""));
                        return(true);
                    }
                    else
                    {
                        math = false;
                    }

                    if (type == VariableType.NON)
                    {
                        type = VariableType.STRING;
                    }
                    else if (type != VariableType.STRING)
                    {
                        if (firstType == VariableType.NON)
                        {
                            if (type == VariableType.NUMBER)
                            {
                                badString = true;
                                type      = VariableType.STRING;
                            }
                        }
                        if (!badString)
                        {
                            Data.Errors.Add(new Errore(line.Number, line.FileName, 1407, ""));
                            return(true);
                        }
                    }
                }
                else if (token == Tokens.VARIABLE)
                {
                    if (!VarContains(line, word.Text, word.OriginText))
                    {
                        return(true);
                    }

                    var v = Data.Project.Variables[word.Text];

                    if (v.Type == VariableType.NUMBER)
                    {
                        if (!math)
                        {
                            Data.Errors.Add(new Errore(line.Number, line.FileName, 1416, ""));
                            return(true);
                        }
                        else
                        {
                            math = false;
                        }
                        if (type == VariableType.NON)
                        {
                            type = VariableType.NUMBER;
                        }
                        else if (type != VariableType.NUMBER)
                        {
                            if (firstType == VariableType.NON)
                            {
                                if (type == VariableType.STRING)
                                {
                                    badString = true;
                                    type      = VariableType.NUMBER;
                                }
                            }
                            else if (firstType == VariableType.STRING)
                            {
                                badString = true;
                            }

                            if (!badString)
                            {
                                Data.Errors.Add(new Errore(line.Number, line.FileName, 1407, ""));
                                return(true);
                            }
                        }
                    }
                    else if (v.Type == VariableType.STRING)
                    {
                        if (!math)
                        {
                            Data.Errors.Add(new Errore(line.Number, line.FileName, 1416, ""));
                            return(true);
                        }
                        else
                        {
                            math = false;
                        }

                        if (type == VariableType.NON)
                        {
                            type = VariableType.STRING;
                        }
                        else if (type != VariableType.STRING)
                        {
                            if (firstType == VariableType.NON)
                            {
                                if (type == VariableType.NUMBER)
                                {
                                    badString = true;
                                    type      = VariableType.STRING;
                                }
                            }
                            if (!badString)
                            {
                                Data.Errors.Add(new Errore(line.Number, line.FileName, 1407, ""));
                                return(true);
                            }
                        }
                    }
                    else if (v.Type == VariableType.NUMBER_ARRAY)
                    {
                        if (j + 1 < line.Count && line.Words[j + 1].Text == "[")
                        {
                            ArrayIndexErrorParser.Start(line, j + 1, Data.Project.Variables);
                            if (Data.Errors.Count > 0)
                            {
                                return(true);
                            }

                            j = ArrayIndexErrorParser.LastIndex;

                            if (!math)
                            {
                                Data.Errors.Add(new Errore(line.Number, line.FileName, 1416, ""));
                                return(true);
                            }
                            else
                            {
                                math = false;
                            }
                            if (type == VariableType.NON)
                            {
                                type = VariableType.NUMBER;
                            }
                            else if (type != VariableType.NUMBER)
                            {
                                if (firstType == VariableType.NON)
                                {
                                    if (type == VariableType.STRING)
                                    {
                                        badString = true;
                                        type      = VariableType.NUMBER;
                                    }
                                }
                                if (!badString)
                                {
                                    Data.Errors.Add(new Errore(line.Number, line.FileName, 1407, ""));
                                    return(true);
                                }
                            }
                        }
                        else
                        {
                            if (array)
                            {
                                Data.Errors.Add(new Errore(line.Number, line.FileName, 1425, ""));
                                return(true);
                            }
                            if (addMath)
                            {
                                Data.Errors.Add(new Errore(line.Number, line.FileName, 1418, ""));
                                return(true);
                            }

                            if (type == VariableType.NON)
                            {
                                type = VariableType.NUMBER_ARRAY;
                            }
                            else if (type != VariableType.NUMBER_ARRAY)
                            {
                                Data.Errors.Add(new Errore(line.Number, line.FileName, 1407, ""));
                                return(true);
                            }
                        }
                    }
                    else if (v.Type == VariableType.STRING_ARRAY)
                    {
                        if (j + 1 < line.Count && line.Words[j + 1].Text == "[")
                        {
                            ArrayIndexErrorParser.Start(line, j + 1, Data.Project.Variables);
                            if (Data.Errors.Count > 0)
                            {
                                return(true);
                            }

                            j = ArrayIndexErrorParser.LastIndex;

                            if (!math)
                            {
                                Data.Errors.Add(new Errore(line.Number, line.FileName, 1416, ""));
                                return(true);
                            }
                            else
                            {
                                math = false;
                            }

                            if (type == VariableType.NON)
                            {
                                type = VariableType.STRING;
                            }
                            else if (type != VariableType.STRING)
                            {
                                if (firstType == VariableType.NON)
                                {
                                    if (type == VariableType.NUMBER)
                                    {
                                        badString = true;
                                        type      = VariableType.STRING;
                                    }
                                }
                                if (!badString)
                                {
                                    Data.Errors.Add(new Errore(line.Number, line.FileName, 1407, ""));
                                    return(true);
                                }
                            }
                        }
                        else
                        {
                            if (array)
                            {
                                Data.Errors.Add(new Errore(line.Number, line.FileName, 1425, ""));
                                return(true);
                            }
                            if (addMath)
                            {
                                Data.Errors.Add(new Errore(line.Number, line.FileName, 1418, ""));
                                return(true);
                            }

                            if (type == VariableType.NON)
                            {
                                type = VariableType.STRING_ARRAY;
                            }
                            else if (type != VariableType.STRING_ARRAY)
                            {
                                Data.Errors.Add(new Errore(line.Number, line.FileName, 1407, ""));
                                return(true);
                            }
                        }
                    }
                }
                else if (token == Tokens.METHOD)
                {
                    var tmpIndex = MethodErrorParser.GetMethodLastIndex(j, line, word.Text);
                    if (tmpIndex == -1)
                    {
                        if (Data.Errors.Count > 0)
                        {
                            return(true);
                        }

                        Data.Errors.Add(new Errore(line.Number, line.FileName, 1314, ""));
                        return(true);
                    }
                    else if (Data.Errors.Count > 0)
                    {
                        return(true);
                    }
                    else if (ParseMethodError(j, word.ToLower(), line))
                    {
                        return(true);
                    }

                    var sign = DefaultObjectList.Get(word.ToLower());

                    if (sign.OutputType == VariableType.NON)
                    {
                        Data.Errors.Add(new Errore(line.Number, line.FileName, 1306, ""));
                        return(true);
                    }
                    else if (sign.OutputType == VariableType.NUMBER)
                    {
                        if (!math)
                        {
                            Data.Errors.Add(new Errore(line.Number, line.FileName, 1416, ""));
                            return(true);
                        }
                        else
                        {
                            math = false;
                        }
                        if (type == VariableType.NON)
                        {
                            type = VariableType.NUMBER;
                        }
                        else if (type != VariableType.NUMBER)
                        {
                            if (firstType == VariableType.NON)
                            {
                                if (type == VariableType.STRING)
                                {
                                    badString = true;
                                    type      = VariableType.NUMBER;
                                }
                            }
                            else if (firstType == VariableType.STRING)
                            {
                                badString = true;
                            }

                            if (!badString)
                            {
                                Data.Errors.Add(new Errore(line.Number, line.FileName, 1407, ""));
                                return(true);
                            }
                        }
                    }
                    else if (sign.OutputType == VariableType.NUMBER_ARRAY)
                    {
                        if (array)
                        {
                            Data.Errors.Add(new Errore(line.Number, line.FileName, 1425, ""));
                            return(true);
                        }
                        if (addMath)
                        {
                            Data.Errors.Add(new Errore(line.Number, line.FileName, 1418, ""));
                            return(true);
                        }

                        if (type == VariableType.NON)
                        {
                            type = VariableType.NUMBER_ARRAY;
                        }
                        else if (type != VariableType.NUMBER_ARRAY)
                        {
                            Data.Errors.Add(new Errore(line.Number, line.FileName, 1407, ""));
                            return(true);
                        }
                    }
                    else if (sign.OutputType == VariableType.STRING)
                    {
                        if (!math)
                        {
                            Data.Errors.Add(new Errore(line.Number, line.FileName, 1416, ""));
                            return(true);
                        }
                        else
                        {
                            math = false;
                        }

                        if (type == VariableType.NON)
                        {
                            type = VariableType.STRING;
                        }
                        else if (type != VariableType.STRING)
                        {
                            if (firstType == VariableType.NON)
                            {
                                if (type == VariableType.NUMBER)
                                {
                                    badString = true;
                                    type      = VariableType.STRING;
                                }
                            }
                            if (!badString)
                            {
                                Data.Errors.Add(new Errore(line.Number, line.FileName, 1407, ""));
                                return(true);
                            }
                        }
                    }
                    else if (sign.OutputType == VariableType.STRING_ARRAY)
                    {
                        if (array)
                        {
                            Data.Errors.Add(new Errore(line.Number, line.FileName, 1425, ""));
                            return(true);
                        }
                        if (addMath)
                        {
                            Data.Errors.Add(new Errore(line.Number, line.FileName, 1418, ""));
                            return(true);
                        }

                        if (type == VariableType.NON)
                        {
                            type = VariableType.STRING_ARRAY;
                        }
                        else if (type != VariableType.STRING_ARRAY)
                        {
                            Data.Errors.Add(new Errore(line.Number, line.FileName, 1407, ""));
                            return(true);
                        }
                    }
                    else if (sign.OutputType == VariableType.ANY)
                    {
                        if (word.ToLower().IndexOf("f.call") != -1)
                        {
                            type = VariableType.ANY;

                            /*
                             * if (j + 2 < line.Count)
                             * {
                             *  var tmpName = line.Words[j + 2].Text.Replace("\"", "");
                             *  if (Builder.Project.SubNames.ContainsKey(tmpName))
                             *  {
                             *      if (type == VariableType.NON)
                             *      {
                             *          type = Builder.Project.SubNames[tmpName];
                             *      }
                             *      else if (type != Builder.Project.SubNames[tmpName])
                             *      {
                             *          Data.Errors.Add(new Errore(line.Number, line.FileName, 1407, ""));
                             *          return true;
                             *      }
                             *  }
                             * }
                             */
                        }
                    }

                    j = tmpIndex;
                }
                else if (token == Tokens.BRACKETLEFT || token == Tokens.BRACKETRIGHT || token == Tokens.BRACKETLEFTARRAY || token == Tokens.BRACKETRIGHTARRAY)
                {
                    continue;
                }
                else
                {
                    Data.Errors.Add(new Errore(line.Number, line.FileName, 1401, word.Text + " " + token));
                    return(true);
                }
                if (!plus && addMath)
                {
                    if (oldType != VariableType.NON && ((oldType == VariableType.NUMBER && type == VariableType.STRING) || (oldType == VariableType.STRING && type == VariableType.NUMBER) || (oldType == VariableType.STRING && type == VariableType.STRING)))
                    {
                        Data.Errors.Add(new Errore(line.Number, line.FileName, 1417, ""));
                        return(true);
                    }
                }
            }

            if (type != VariableType.NON)
            {
                if (badString && type == VariableType.NUMBER)
                {
                    type = VariableType.STRING;
                }
                if (!Data.Project.Variables.ContainsKey(varName))
                {
                    //Console.WriteLine("=================> " + varName + " " + type + " " + line.Number.ToString());
                    if (!array)
                    {
                        Data.Project.Variables.Add(varName, new Variable(varName)
                        {
                            Init = true, Type = type, Line = line
                        });
                    }
                    else
                    {
                        if (type == VariableType.NUMBER || type == VariableType.NUMBER_ARRAY)
                        {
                            Data.Project.Variables.Add(varName, new Variable(varName)
                            {
                                Init = true, Type = VariableType.NUMBER_ARRAY, Line = line
                            });
                        }
                        else if (type == VariableType.STRING || type == VariableType.STRING_ARRAY)
                        {
                            Data.Project.Variables.Add(varName, new Variable(varName)
                            {
                                Init = true, Type = VariableType.STRING_ARRAY, Line = line
                            });
                        }
                    }
                }
            }
            else
            {
                Data.Errors.Add(new Errore(line.Number, line.FileName, 1401, ""));
                return(true);
            }

            return(false);
        }