示例#1
0
        public static Logic parsePureFunctionCall(Logic[] logicOrder, int lineNumber, Scope currentScope)
        {
            if (logicOrder.Length != 1)
            {
                return(new UnknownLogic(lineNumber));
            }

            if (logicOrder [0].currentType == WordTypes.functionCall)
            {
                FunctionCall tempCall = (logicOrder [0] as FunctionCall);
                FunctionParser.linkFunctionCall(tempCall, lineNumber, currentScope);


                if (tempCall.targetFunc.pauseWalker)
                {
                    CodeWalker.pauseWalker();
                }

                tempCall.runFunction(currentScope);

                if (tempCall.targetFunc.isUserFunction)
                {
                    throw new FunctionCallException();
                }

                return(tempCall);
            }
            else
            {
                return(new UnknownLogic(lineNumber));
            }
        }
        private static bool forCheck(Logic[] logicOrder, int lineNumber, Scope currentScope)
        {
            if (logicOrder.Length != 5)
            {
                ErrorMessage.sendErrorMessage(lineNumber, "Okänt format på din for loop");
            }

            if (logicOrder [1].currentType != WordTypes.variable)
            {
                ErrorMessage.sendErrorMessage(lineNumber, "Förväntade sig en variabel som 2:a ord");
            }

            if (logicOrder[2].word != "in")
            {
                ErrorMessage.sendErrorMessage(lineNumber, "Förväntade sig ordet \"in\" 3:e ord");
            }

            if (logicOrder [3].currentType != WordTypes.functionCall)
            {
                ErrorMessage.sendErrorMessage(lineNumber, "Förväntade sig funktionsanrop till \"range\" som 4:e ord");
            }

            FunctionParser.linkFunctionCall((logicOrder [3] as FunctionCall), lineNumber, currentScope);
            if ((logicOrder [3] as FunctionCall).targetFunc.name != "range")
            {
                ErrorMessage.sendErrorMessage(lineNumber, "Förväntade sig funktionsanrop till \"range\" som 4:e ord");
            }

            if (logicOrder [4].currentType != WordTypes.indentOperator)
            {
                ErrorMessage.sendErrorMessage(lineNumber, "Saknas ett \":\" i slutet av din for loop");
            }


            return(true);
        }