Пример #1
0
        private static Expression ParseEqualityExpression(Scanner scanner)
        {
            Expression left = ParseComparisonExpression(scanner);

            while (true)
            {
                if (scanner.TryGetDelimiter("=="))
                {
                    Expression right = ParseComparisonExpression(scanner);
                    left = new EqualExpression(left, right);
                }
                else if (scanner.TryGetDelimiter("!="))
                {
                    Expression right = ParseComparisonExpression(scanner);
                    left = new NotEqualExpression(left, right);
                }
                else if (scanner.TryGetIdentifier("is"))
                {
                    Expression right = ParseComparisonExpression(scanner);
                    left = new IsExpression(left, right);
                }
                else if (scanner.TryGetIdentifier("isnot"))
                {
                    Expression right = ParseComparisonExpression(scanner);
                    left = new IsNotExpression(left, right);
                }
                else
                {
                    return(left);
                }
            }
        }
Пример #2
0
 private static Expression ParseEqualityExpression(Scanner scanner)
 {
     Expression left = ParseComparisonExpression(scanner);
     while (true)
     {
         if (scanner.TryGetDelimiter("=="))
         {
             Expression right = ParseComparisonExpression(scanner);
             left = new EqualExpression(left,right);
         }
         else if (scanner.TryGetDelimiter("!="))
         {
             Expression right = ParseComparisonExpression(scanner);
             left = new NotEqualExpression(left,right);
         }
         else if (scanner.TryGetIdentifier("is"))
         {
             Expression right = ParseComparisonExpression(scanner);
             left = new IsExpression(left,right);
         }
         else if (scanner.TryGetIdentifier("isnot"))
         {
             Expression right = ParseComparisonExpression(scanner);
             left = new IsNotExpression(left,right);
         }
         else
         {
             return left;
         }
     }
 }