예제 #1
0
        private static Expression ParseBitwiseXorExpression(Scanner scanner)
        {
            Expression left = ParseBitwiseAndExpression(scanner);

            while (scanner.TryGetDelimiter("^"))
            {
                Expression right = ParseBitwiseAndExpression(scanner);
                left = new BitwiseXorExpression(left, right);
            }
            return(left);
        }
예제 #2
0
 private static Expression ParseBitwiseXorExpression(Scanner scanner)
 {
     Expression left = ParseBitwiseAndExpression(scanner);
     while (scanner.TryGetDelimiter("^"))
     {
         Expression right = ParseBitwiseAndExpression(scanner);
         left = new BitwiseXorExpression(left,right);
     }
     return left;
 }
예제 #3
0
 private static Expression ParseAssigmentExpression(Scanner scanner)
 {
     Expression left = ParseLogicalOrExpression(scanner);
     if (scanner.TryGetDelimiter("="))
     {
         Expression right = ParseAssigmentExpression(scanner);
         return new AssignmentExpression(left,right);
     }
     else if (scanner.TryGetDelimiter("+="))
     {
         Expression right = ParseAssigmentExpression(scanner);
         right = new AddExpression(left,right);
         return new AssignmentExpression(left,right);
     }
     else if (scanner.TryGetDelimiter("-="))
     {
         Expression right = ParseAssigmentExpression(scanner);
         right = new SubtractExpression(left,right);
         return new AssignmentExpression(left,right);
     }
     else if (scanner.TryGetDelimiter("*="))
     {
         Expression right = ParseAssigmentExpression(scanner);
         right = new MultiplyExpression(left,right);
         return new AssignmentExpression(left,right);
     }
     else if (scanner.TryGetDelimiter("/="))
     {
         Expression right = ParseAssigmentExpression(scanner);
         right = new DivideExpression(left,right);
         return new AssignmentExpression(left,right);
     }
     else if (scanner.TryGetDelimiter("%="))
     {
         Expression right = ParseAssigmentExpression(scanner);
         right = new ModuloExpression(left,right);
         return new AssignmentExpression(left,right);
     }
     else if (scanner.TryGetDelimiter("<<="))
     {
         Expression right = ParseAssigmentExpression(scanner);
         right = new LeftShiftExpression(left,right);
         return new AssignmentExpression(left,right);
     }
     else if (scanner.TryGetDelimiter(">>="))
     {
         Expression right = ParseAssigmentExpression(scanner);
         right = new RightShiftExpression(left,right);
         return new AssignmentExpression(left,right);
     }
     else if (scanner.TryGetDelimiter("&="))
     {
         Expression right = ParseAssigmentExpression(scanner);
         right = new BitwiseAndExpression(left,right);
         return new AssignmentExpression(left,right);
     }
     else if (scanner.TryGetDelimiter("^="))
     {
         Expression right = ParseAssigmentExpression(scanner);
         right = new BitwiseXorExpression(left,right);
         return new AssignmentExpression(left,right);
     }
     else if (scanner.TryGetDelimiter("|="))
     {
         Expression right = ParseAssigmentExpression(scanner);
         right = new BitwiseOrExpression(left,right);
         return new AssignmentExpression(left,right);
     }
     else if (scanner.TryGetDelimiter("&&="))
     {
         Expression right = ParseAssigmentExpression(scanner);
         right = new LogicalAndExpression(left,right);
         return new AssignmentExpression(left,right);
     }
     else if (scanner.TryGetDelimiter("^^="))
     {
         Expression right = ParseAssigmentExpression(scanner);
         right = new LogicalXorExpression(left,right);
         return new AssignmentExpression(left,right);
     }
     else if (scanner.TryGetDelimiter("||="))
     {
         Expression right = ParseAssigmentExpression(scanner);
         right = new LogicalOrExpression(left,right);
         return new AssignmentExpression(left,right);
     }
     else
     {
         return left;
     }
 }
예제 #4
0
        private static Expression ParseAssigmentExpression(Scanner scanner)
        {
            Expression left = ParseLogicalOrExpression(scanner);

            if (scanner.TryGetDelimiter("="))
            {
                Expression right = ParseAssigmentExpression(scanner);
                return(new AssignmentExpression(left, right));
            }
            else if (scanner.TryGetDelimiter("+="))
            {
                Expression right = ParseAssigmentExpression(scanner);
                right = new AddExpression(left, right);
                return(new AssignmentExpression(left, right));
            }
            else if (scanner.TryGetDelimiter("-="))
            {
                Expression right = ParseAssigmentExpression(scanner);
                right = new SubtractExpression(left, right);
                return(new AssignmentExpression(left, right));
            }
            else if (scanner.TryGetDelimiter("*="))
            {
                Expression right = ParseAssigmentExpression(scanner);
                right = new MultiplyExpression(left, right);
                return(new AssignmentExpression(left, right));
            }
            else if (scanner.TryGetDelimiter("/="))
            {
                Expression right = ParseAssigmentExpression(scanner);
                right = new DivideExpression(left, right);
                return(new AssignmentExpression(left, right));
            }
            else if (scanner.TryGetDelimiter("%="))
            {
                Expression right = ParseAssigmentExpression(scanner);
                right = new ModuloExpression(left, right);
                return(new AssignmentExpression(left, right));
            }
            else if (scanner.TryGetDelimiter("<<="))
            {
                Expression right = ParseAssigmentExpression(scanner);
                right = new LeftShiftExpression(left, right);
                return(new AssignmentExpression(left, right));
            }
            else if (scanner.TryGetDelimiter(">>="))
            {
                Expression right = ParseAssigmentExpression(scanner);
                right = new RightShiftExpression(left, right);
                return(new AssignmentExpression(left, right));
            }
            else if (scanner.TryGetDelimiter("&="))
            {
                Expression right = ParseAssigmentExpression(scanner);
                right = new BitwiseAndExpression(left, right);
                return(new AssignmentExpression(left, right));
            }
            else if (scanner.TryGetDelimiter("^="))
            {
                Expression right = ParseAssigmentExpression(scanner);
                right = new BitwiseXorExpression(left, right);
                return(new AssignmentExpression(left, right));
            }
            else if (scanner.TryGetDelimiter("|="))
            {
                Expression right = ParseAssigmentExpression(scanner);
                right = new BitwiseOrExpression(left, right);
                return(new AssignmentExpression(left, right));
            }
            else if (scanner.TryGetDelimiter("&&="))
            {
                Expression right = ParseAssigmentExpression(scanner);
                right = new LogicalAndExpression(left, right);
                return(new AssignmentExpression(left, right));
            }
            else if (scanner.TryGetDelimiter("^^="))
            {
                Expression right = ParseAssigmentExpression(scanner);
                right = new LogicalXorExpression(left, right);
                return(new AssignmentExpression(left, right));
            }
            else if (scanner.TryGetDelimiter("||="))
            {
                Expression right = ParseAssigmentExpression(scanner);
                right = new LogicalOrExpression(left, right);
                return(new AssignmentExpression(left, right));
            }
            else
            {
                return(left);
            }
        }