private static void ParseVariableDeclaration(FunctionDefinitionSet functionSet, StringAbstraction s, Block block) { var split = s.Split("="); IIntegerReturningStatement toSetTo = ParseIntReturningExpression(s.AfterFirstOccuranceOf("="), functionSet); block.AddChild(new IntegerAssignment(new VariableName(s.BeforeFirstOccuranceOf("=").ToString()), toSetTo)); }
private static IBooleanReturningStatement ParseLessThanCondition(CodeFileAbstraction codeFile, FunctionDefinitionSet functionSet) { StringAbstraction expression = codeFile.GetCurrentLine().AfterFirstColon(); IIntegerReturningStatement smaller = ParseIntReturningExpression(expression.BeforeFirstOccuranceOf("<"), functionSet); IIntegerReturningStatement bigger = ParseIntReturningExpression(expression.AfterFirstOccuranceOf("<"), functionSet); IBooleanReturningStatement condition = new CompareLessThan(smaller, bigger); return(condition); }
private void ParseFunctionDefinition(CodeFileAbstraction codeFile, FunctionDefinitionSet functionSet, StringAbstraction s) { List <StringAbstraction> args = new List <StringAbstraction>(codeFile.GetCurrentLine().AfterFirstPipe().Split(",")); Block functionBlock = GetBlock(codeFile, functionSet); functionSet.Add(new FunctionName(s.BeforeFirstOccuranceOf("|").Value()), new IntReturningFunction( functionBlock, ParseIntReturningExpression(codeFile.GetCurrentLine().Replace("return", ""), functionSet), args.Select(x => new VariableName(x.Value())).ToList() )); }