Exemple #1
0
        public static Variable checkIfValidSum(Logic[] PrelogicOrder, int lineNumber)
        {
            Logic[] logicOrder = (Logic[])PrelogicOrder.Clone();
            UnpackPackages(logicOrder, lineNumber);

            logicOrder = BoolCompressExpressions.compressExpression(logicOrder, lineNumber, null, false);
            logicOrder = BoolExpressionParser.compressAndOrStatements(logicOrder, lineNumber, null);

            if (logicOrder.Length == 0)
            {
                return(new Variable("No var"));
            }

            expectType theExpectedType = new expectType();

            for (int i = 0; i < logicOrder.Length; i++)
            {
                if (logicOrder[i].currentType == WordTypes.booleanExpression)
                {
                    setNewExpectVariable(theExpectedType, VariableTypes.boolean, lineNumber, logicOrder);
                }

                else if (logicOrder [i].currentType == WordTypes.variable)
                {
                    logicOrder [i] = new Variable(logicOrder [i].word);
                }
                else if (logicOrder [i].currentType == WordTypes.mathOperator)
                {
                }
                else if (logicOrder [i].currentType == WordTypes.number)
                {
                    setNewExpectVariable(theExpectedType, VariableTypes.number, lineNumber, logicOrder);
                }
                else if (logicOrder [i].currentType == WordTypes.textString)
                {
                    setNewExpectVariable(theExpectedType, VariableTypes.textString, lineNumber, logicOrder);
                }
                else if (logicOrder [i].currentType == WordTypes.booleanValue)
                {
                    setNewExpectVariable(theExpectedType, VariableTypes.boolean, lineNumber, logicOrder);
                }
            }

            if (theExpectedType.currentType == VariableTypes.unknown)
            {
                return(new Variable());
            }

            return(theExpectedType.returnExpectedVariable());
        }
        public static Variable parseIntoSum(Logic[] logicOrderInput, int lineNumber, Scope currentScope)
        {
            Logic[] logicOrder = (Logic[])logicOrderInput.Clone();
            UnpackPackages(logicOrder, lineNumber, currentScope);

            logicOrder = BoolCompressExpressions.compressExpression(logicOrder, lineNumber, currentScope, true);
            logicOrder = BoolExpressionParser.compressAndOrStatements(logicOrder, lineNumber, currentScope);

            if (logicOrder.Length == 0)
            {
                return(new Variable("CalcVar"));
            }

            expectType theExpectedType = new expectType();

            calcSumType(logicOrder, theExpectedType, lineNumber, currentScope);
            return(getCalcSum(theExpectedType, logicOrder, lineNumber));
        }