private static Logic[] parseVariablesAndPackagesIntoFunctionCalls(Logic[] logicOrder, int lineNumber, Scope currentScope) { List <Logic> tempOrder = new List <Logic> (); for (int i = 0; i < logicOrder.Length; i++) { if (logicOrder [i].currentType == WordTypes.variable && (i + 1 < logicOrder.Length && logicOrder[i + 1].currentType == WordTypes.package)) { Logic theFuncCall = FunctionParser.parseIntoFunctionCall(logicOrder [i].word + logicOrder [i + 1].word, lineNumber, currentScope); tempOrder.Add(theFuncCall); i += 1; } else { tempOrder.Add(logicOrder [i]); } } return(tempOrder.ToArray()); }
private static Logic getCurrentLogic(string word, int lineNumber, Scope currentScope) { if (word == ",") { return(new CommaSign()); } if (word == ">") { return(new GreaterThenSign()); } if (word == "<") { return(new LessThenSign()); } if (word == ":") { return(new IndentOperator()); } if (word == "!") { return(new XorOperator(word)); } if (word == "not") { return(new NotOperator(word)); } if (word == "or") { return(new OrOperator(word)); } if (word == "and") { return(new AndOperator(word)); } if (isBooleanValue(word) == 1) { return(new BooleanValue(true)); } if (isBooleanValue(word) == 0) { return(new BooleanValue(false)); } if (isNumber(word)) { return(new NumberValue(word)); } if (isString(word)) { return(new TextValue(word)); } if (SpecialWordParser.isKeyWord(word)) { SpecialWordParser.checkIfUnsupportedKeyword(word, lineNumber); WordTypes specialType = SpecialWordParser.getSpecialType(word, lineNumber); if (specialType == WordTypes.forLoop) { return(new ForLoop()); } if (specialType == WordTypes.whileLoop) { return(new WhileLoop()); } if (specialType == WordTypes.ifOperator) { return(new IfStatement()); } if (specialType == WordTypes.elifOperator) { return(new ElifStatement()); } if (specialType == WordTypes.elseOperator) { return(new ElseStatement()); } if (specialType == WordTypes.defStatement) { return(new DefStatement()); } if (specialType == WordTypes.returnStatement) { return(new ReturnStatement()); } if (specialType == WordTypes.breakStatement) { return(new BreakStatement()); } if (specialType == WordTypes.continueStatement) { return(new ContinueStatment()); } } if (startsWithDigitOrWeirdChar(word) == false) { if (endsWithParantes(word)) { Logic temp = FunctionParser.parseIntoFunctionCall(word, lineNumber, currentScope); if (temp != null) { return(temp); } } else { if (containsButNotStartWithDigitWeirdChar(word) == false) { return(checkVariable(word, currentScope.scopeVariables)); } } } if (word.Length == 1) { if (word [0] == '=') { return(new EqualSign()); } if (isMathOperator(word[0])) { return(new MathOperator(word)); } } if (isPackage(word)) { return(new Package(word, lineNumber)); } return(new UnknownLogic(lineNumber)); }