Beispiel #1
0
        string PrintExpression(SwiftParser.ComparativeExprContext context)
        {
            string result;

            if (context.rangeExpr().Count() == 1)
            {
                result = PrintExpression(context.rangeExpr()[0]);
            }
            else if (context.children[1].GetText() == "===")
            {
                result = $"CompareWithTypes({PrintExpression(context.rangeExpr()[0])}," +
                         $"{PrintExpression(context.rangeExpr()[1])})";
            }
            else if (context.children[1].GetText() == "!==")
            {
                result = $"!CompareWithTypes({PrintExpression(context.rangeExpr()[0])}," +
                         $"{PrintExpression(context.rangeExpr()[1])})";
            }
            else
            {
                result = PrintExpression(context.rangeExpr()[0])
                         + context.children[1].GetText() + PrintExpression(context.rangeExpr()[1]);
            }

            return($"({result})");
        }
Beispiel #2
0
 string PrintExpression(SwiftParser.ComparativeExprContext context)
 {
     if (context.additiveExpr().Count() == 1)
     {
         return(PrintExpression(context.additiveExpr()[0]));
     }
     else if (context.children[1].GetText() == "===")
     {
         return($"CompareWithTypes({PrintExpression(context.additiveExpr()[0])}," +
                $"{PrintExpression(context.additiveExpr()[1])})");
     }
     else if (context.children[1].GetText() == "!==")
     {
         return($"!CompareWithTypes({PrintExpression(context.additiveExpr()[0])}," +
                $"{PrintExpression(context.additiveExpr()[1])})");
     }
     else if (context.children[1].GetText() == "<")
     {
         return($"LessThanEvenForStrings({PrintExpression(context.additiveExpr()[0])}," +
                $"{PrintExpression(context.additiveExpr()[1])})");
     }
     else if (context.children[1].GetText() == "<=")
     {
         return($"!GreaterThanEvenForStrings({PrintExpression(context.additiveExpr()[0])}," +
                $"{PrintExpression(context.additiveExpr()[1])})");
     }
     else if (context.children[1].GetText() == ">")
     {
         return($"GreaterThanEvenForStrings({PrintExpression(context.additiveExpr()[0])}," +
                $"{PrintExpression(context.additiveExpr()[1])})");
     }
     else if (context.children[1].GetText() == ">=")
     {
         return($"!LessThanEvenForStrings({PrintExpression(context.additiveExpr()[0])}," +
                $"{PrintExpression(context.additiveExpr()[1])})");
     }
     else
     {
         return($"{PrintExpression(context.additiveExpr()[0])}"
                + $" {context.children[1].GetText()} {PrintExpression(context.additiveExpr()[1])}");
     }
 }