Ejemplo n.º 1
0
        private static void handleVariable(Logic[] logicOrder, expectType theExpectedType, int lineNumber, Scope currentScope, int i)
        {
            int varPos = currentScope.scopeVariables.containsVariable((logicOrder [i] as Variable).name);

            if (varPos >= 0)
            {
                Variable foundVar = currentScope.scopeVariables.variableList [varPos];
                setNewExpectVariable(theExpectedType, foundVar.variableType, lineNumber);
                logicOrder [i] = foundVar;
            }
            else
            {
                if ((logicOrder [i] as Variable).isCalcVar)
                {
                    setNewExpectVariable(theExpectedType, (logicOrder [i] as Variable).variableType, lineNumber);
                }
                else
                {
                    if ((logicOrder [i] as Variable).name.Length > 10)
                    {
                        ErrorMessage.sendErrorMessage(lineNumber, "Användning av icke deklarerad variabel!");
                    }

                    LevenshteinDist.checkForClosesVariable(logicOrder [i].word, lineNumber, currentScope);
                    ErrorMessage.sendErrorMessage(lineNumber, "Kunde inte hitta variabeln \"" + (logicOrder [i] as Variable).name + "\" i minnet.");
                }
            }
        }
Ejemplo n.º 2
0
        public Function getSavedFunction(string searchedFunction, int lineNumber)
        {
            for (int i = 0; i < savedFunctions.Count; i++)
            {
                if (savedFunctions [i].name == searchedFunction)
                {
                    return(savedFunctions [i]);
                }
            }

            LevenshteinDist.checkForClosesFunctions(searchedFunction, savedFunctions, lineNumber);
            ErrorHandler.ErrorMessage.sendErrorMessage(lineNumber, "Hittar ingen funktion med namn \"" + searchedFunction + "\".");
            return(null);
        }