private IExpressionBinding Visit(Declaration module, Declaration parent, VBAParser.ExpressionContext expression)
        {
            switch (expression)
            {
            case VBAParser.LExprContext lExprContext:
                return(Visit(module, parent, lExprContext.lExpression()));

            default:
                throw new NotSupportedException($"Unexpected expression type {expression.GetType()}");
            }
        }
Beispiel #2
0
        private IExpressionBinding Visit(Declaration module, Declaration parent, VBAParser.ExpressionContext expression, IBoundExpression withBlockVariable, StatementResolutionContext statementContext)
        {
            switch (expression)
            {
            case VBAParser.LExprContext lExprContext:
                return(Visit(module, parent, lExprContext.lExpression(), withBlockVariable, statementContext));

            case VBAParser.ParenthesizedExprContext parenthesizedExprContext:
                return(Visit(module, parent, parenthesizedExprContext, withBlockVariable));

            case VBAParser.RelationalOpContext relationalOpContext:
                return(Visit(module, parent, relationalOpContext, withBlockVariable));

            case VBAParser.LiteralExprContext literalExprContext:
                return(Visit(literalExprContext.literalExpression()));

            case VBAParser.NewExprContext newExprContext:
                return(Visit(module, parent, newExprContext, withBlockVariable));

            case VBAParser.LogicalNotOpContext logicalNotOpContext:
                return(VisitUnaryOp(module, parent, logicalNotOpContext, logicalNotOpContext.expression(), withBlockVariable));

            case VBAParser.UnaryMinusOpContext unaryMinusOpContext:
                return(VisitUnaryOp(module, parent, unaryMinusOpContext, unaryMinusOpContext.expression(), withBlockVariable));

            case VBAParser.LogicalAndOpContext logicalAndOpContext:
                return(VisitBinaryOp(module, parent, logicalAndOpContext, logicalAndOpContext.expression()[0], logicalAndOpContext.expression()[1], withBlockVariable));

            case VBAParser.LogicalOrOpContext logicalOrOpContext:
                return(VisitBinaryOp(module, parent, logicalOrOpContext, logicalOrOpContext.expression()[0], logicalOrOpContext.expression()[1], withBlockVariable));

            case VBAParser.LogicalXorOpContext logicalXorOpContext:
                return(VisitBinaryOp(module, parent, logicalXorOpContext, logicalXorOpContext.expression()[0], logicalXorOpContext.expression()[1], withBlockVariable));

            case VBAParser.LogicalEqvOpContext logicalEqvOpContext:
                return(VisitBinaryOp(module, parent, logicalEqvOpContext, logicalEqvOpContext.expression()[0], logicalEqvOpContext.expression()[1], withBlockVariable));

            case VBAParser.LogicalImpOpContext logicalImpOpContext:
                return(VisitBinaryOp(module, parent, logicalImpOpContext, logicalImpOpContext.expression()[0], logicalImpOpContext.expression()[1], withBlockVariable));

            case VBAParser.AddOpContext addOpContext:
                return(VisitBinaryOp(module, parent, addOpContext, addOpContext.expression()[0], addOpContext.expression()[1], withBlockVariable));

            case VBAParser.ConcatOpContext concatOpContext:
                return(VisitBinaryOp(module, parent, concatOpContext, concatOpContext.expression()[0], concatOpContext.expression()[1], withBlockVariable));

            case VBAParser.MultOpContext multOpContext:
                return(VisitBinaryOp(module, parent, multOpContext, multOpContext.expression()[0], multOpContext.expression()[1], withBlockVariable));

            case VBAParser.ModOpContext modOpContext:
                return(VisitBinaryOp(module, parent, modOpContext, modOpContext.expression()[0], modOpContext.expression()[1], withBlockVariable));

            case VBAParser.PowOpContext powOpContext:
                return(VisitBinaryOp(module, parent, powOpContext, powOpContext.expression()[0], powOpContext.expression()[1], withBlockVariable));

            case VBAParser.IntDivOpContext intDivOpContext:
                return(VisitBinaryOp(module, parent, intDivOpContext, intDivOpContext.expression()[0], intDivOpContext.expression()[1], withBlockVariable));

            case VBAParser.MarkedFileNumberExprContext markedFileNumberExprContext:
                return(Visit(module, parent, markedFileNumberExprContext, withBlockVariable));

            case VBAParser.BuiltInTypeExprContext builtInTypeExprContext:
                return(Visit(builtInTypeExprContext));

            //We do not handle the VBAParser.TypeofexprContext because that should only ever appear as a child of an IS relational operator expression and is specifically handled there.
            default:
                throw new NotSupportedException($"Unexpected expression type {expression.GetType()}");
            }
        }