示例#1
0
 private IExpression Visit(VBAConditionalCompilationParser.LiteralContext context)
 {
     if (context.HEXLITERAL() != null)
     {
         return(VisitHexLiteral(context));
     }
     else if (context.OCTLITERAL() != null)
     {
         return(VisitOctLiteral(context));
     }
     else if (context.DATELITERAL() != null)
     {
         return(VisitDateLiteral(context));
     }
     else if (context.FLOATLITERAL() != null)
     {
         return(VisitFloatLiteral(context));
     }
     else if (context.INTEGERLITERAL() != null)
     {
         return(VisitIntegerLiteral(context));
     }
     else if (context.STRINGLITERAL() != null)
     {
         return(VisitStringLiteral(context));
     }
     else if (context.TRUE() != null)
     {
         return(new ConstantExpression(new BoolValue(true)));
     }
     else if (context.FALSE() != null)
     {
         return(new ConstantExpression(new BoolValue(false)));
     }
     else if (context.NOTHING() != null || context.NULL() != null)
     {
         return(new ConstantExpression(null));
     }
     else if (context.EMPTY() != null)
     {
         return(new ConstantExpression(EmptyValue.Value));
     }
     throw new Exception(string.Format("Unexpected literal encountered: {0}", ParserRuleContextHelper.GetText(context, _stream)));
 }
示例#2
0
 private IExpression VisitFloatLiteral(VBAConditionalCompilationParser.LiteralContext context)
 {
     return(new NumberLiteralExpression(new ConstantExpression(new StringValue(context.FLOATLITERAL().GetText()))));
 }