コード例 #1
0
        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));
        }
コード例 #2
0
        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);
        }
コード例 #3
0
 private static IIntegerReturningStatement ParseIntReturningExpression(StringAbstraction s, FunctionDefinitionSet functionSet)
 {
     if (s.IsNumeric())
     {
         return(s.GetIntValue());
     }
     if (s.Contains(">"))
     {
         return(ParseFunctionEvalulation(s, functionSet));
     }
     if (s.StartsWith("sum:"))
     {
         return(ParseSum(s, functionSet));
     }
     if (s.StartsWith("-"))
     {
         return(new Negation(new IntVariableEvaluation(new VariableName(s.AfterFirstOccuranceOf("-").Value()))));
     }
     return(new IntVariableEvaluation(new VariableName(s.Value())));
 }