Example #1
0
 private AST.Expression Multiplicative()
 {
     AST.Expression result = Unary();
     while (true)
     {
         if (IsMatch(TokenType.STAR))
         {
             result = new AST.BinaryExpression('*', result, Unary());
             continue;
         }
         if (IsMatch(TokenType.SLASH))
         {
             result = new AST.BinaryExpression('/', result, Unary());
             continue;
         }
         break;
     }
     return(result);
 }
Example #2
0
        private AST.Expression Additive()
        {
            AST.Expression result = Multiplicative();

            while (true)
            {
                if (IsMatch(TokenType.PLUS))
                {
                    result = new AST.BinaryExpression('+', result, Multiplicative());
                    continue;
                }
                if (IsMatch(TokenType.MINUS))
                {
                    result = new AST.BinaryExpression('-', result, Multiplicative());
                    continue;
                }
                break;
            }

            return(result);
        }