private void UpdateCondition(VBAParser.RelationalOpContext condition, IModuleRewriter rewriter)
 {
     if (condition.EQ() != null)
     {
         rewriter.Replace(condition.EQ(), "<>");
     }
     if (condition.NEQ() != null)
     {
         rewriter.Replace(condition.NEQ(), "=");
     }
     if (condition.LT() != null)
     {
         rewriter.Replace(condition.LT(), ">=");
     }
     if (condition.GT() != null)
     {
         rewriter.Replace(condition.GT(), "<=");
     }
     if (condition.LEQ() != null)
     {
         rewriter.Replace(condition.LEQ(), ">");
     }
     if (condition.GEQ() != null)
     {
         rewriter.Replace(condition.GEQ(), "<");
     }
     if (condition.IS() != null || condition.LIKE() != null)
     {
         UpdateCondition((ParserRuleContext)condition, rewriter);
     }
 }
Exemplo n.º 2
0
        private IExpressionBinding Visit(Declaration module, Declaration parent, VBAParser.RelationalOpContext expression, IBoundExpression withBlockVariable)
        {
            // To make the grammar we treat a type-of-is expression as a construct of the form "TYPEOF expression", where expression
            // is always "expression IS expression".
            if (expression.expression()[0] is VBAParser.TypeofexprContext typeofExpr)
            {
                return(VisitTypeOf(module, parent, expression, typeofExpr, expression.expression()[1], withBlockVariable));
            }

            var isIsRelation = expression.IS() != null;

            return(VisitBinaryOp(module, parent, expression, expression.expression()[0], expression.expression()[1], withBlockVariable, isIsRelation));
        }