private static Logic[] splitPackagesAndStatements(Logic[] logicOrder, int lineNumber, Scope currentScope) { List <Logic> newOrder = new List <Logic> (); for (int i = 0; i < logicOrder.Length; i++) { if (logicOrder [i].currentType == WordTypes.functionCall && SpecialWordParser.isKeyWord((logicOrder [i] as FunctionCall).name)) { Package temp = new Package("(" + (logicOrder [i] as FunctionCall).parameter + ")", lineNumber); temp.logicOrder = WordsToLogicParser.determineLogicFromWords(new string[] { temp.word }, lineNumber, currentScope); if ((logicOrder [i] as FunctionCall).name == "if") { newOrder.Add(new IfStatement()); newOrder.Add(temp); } else if ((logicOrder [i] as FunctionCall).name == "while") { newOrder.Add(new WhileLoop()); newOrder.Add(temp); } } else { newOrder.Add(logicOrder [i]); } } return(newOrder.ToArray()); }
static void parseCodeLineLogic(Scope currentScope) { foreach (CodeLine tempLine in currentScope.codeLines) { tempLine.logicOrder = WordsToLogicParser.determineLogicFromWords(tempLine.words, tempLine.lineNumber, currentScope); } }
public static string[] getParameterNames(string trimmedPara, int lineNumber, Scope currentScope) { string[] words = WordParser.parseWords(trimmedPara); if (words.Length == 0) { return(new string[0]); } Logic[] logicOrder = WordsToLogicParser.determineLogicFromWords(words, lineNumber, currentScope); List <Logic[]> packedLogics = convertIntoParameterLogic(words, logicOrder, lineNumber); List <string> returnWords = new List <string>(); foreach (Logic[] l in packedLogics) { if (l.Length != 1) { ErrorMessage.sendErrorMessage(lineNumber, "Du tycks ha glömt ett \",\""); } returnWords.Add(l [0].word); } return(returnWords.ToArray()); }
public static int getParameterAmount(string trimmedPara, int lineNumber, Scope currentScope) { string[] words = WordParser.parseWords(trimmedPara); if (words.Length == 0) { return(0); } Logic[] logicOrder = WordsToLogicParser.determineLogicFromWords(words, lineNumber, currentScope); List <Logic[]> packedLogics = convertIntoParameterLogic(words, logicOrder, lineNumber); return(packedLogics.Count); }
public static void unpackPackage(string word, int lineNumber, Scope currentScope, Package currentPackage) { if (word.Length <= 2) { return; } string trimedString = removeSurrondingParanteser(word); string[] words = WordParser.parseWords(trimedString); Logic[] logicOrder = WordsToLogicParser.determineLogicFromWords(words, lineNumber, currentScope); currentPackage.logicOrder = logicOrder; }
public static Variable[] getValueOfParameters(string trimmedPara, Function calledFunction, int lineNumber, Scope currentScope, FunctionCall theFuncCall) { string[] words = WordParser.parseWords(trimmedPara); if (words.Length != 0) { Logic[] logicOrder = WordsToLogicParser.determineLogicFromWords(words, lineNumber, currentScope); List <Logic[]> packedLogics = convertIntoParameterLogic(words, logicOrder, lineNumber); theFuncCall.setReturnCalculations(packedLogics); if (packedLogics != null) { return(parseInputVariables(packedLogics, lineNumber, calledFunction, currentScope)); } } return(new Variable[0]); }
public static void SubmitInput(string inputFromUser, Scope currentScope) { if (!CodeWalker.isWaitingForUserInput) { return; } CodeWalker.isWaitingForUserInput = false; var oldLine = currentScope.getCurrentLine().cloneLine(); var oldLineString = oldLine.getFullLine(); var newLine = ReplaceInputWithValue(oldLineString, inputFromUser); var lines = SyntaxCheck.parseLines(newLine); var words = lines.First().words; var logic = WordsToLogicParser.determineLogicFromWords(words, 1, currentScope); currentScope.getCurrentLine().words = words; currentScope.getCurrentLine().logicOrder = logic; CodeWalker.parseLine(currentScope.getCurrentLine(), oldLine); }