Esempio n. 1
0
 private CodeExpression BuildLiteralValue(XSharpParser.LiteralValueContext context)
 {
     CodeExpression expr = null;
     ITerminalNode node;
     //
     node = context.BIN_CONST();
     if (node != null)
     {
         expr = new CodePrimitiveExpression(GetNumericValue(context));
     }
     node = context.INT_CONST();
     if (node != null)
     {
         expr = new CodePrimitiveExpression(GetNumericValue(context));
     }
     //
     node = context.HEX_CONST();
     if (node != null)
     {
         expr = new CodePrimitiveExpression(GetNumericValue(context));
     }
     //
     node = context.REAL_CONST();
     if (node != null)
     {
         expr = new CodePrimitiveExpression(GetNumericValue(context));
     }
     //
     node = context.TRUE_CONST();
     if (node != null)
     {
         expr = new CodePrimitiveExpression(true);
     }
     //
     node = context.FALSE_CONST();
     if (node != null)
     {
         expr = new CodePrimitiveExpression(false);
     }
     //
     node = context.STRING_CONST();
     if (node != null)
     {
         // Remove the quotes
         String value = context.GetText();
         value = value.Substring(1, value.Length - 2);
         expr = new CodePrimitiveExpression(value);
     }
     //
     node = context.ESCAPED_STRING_CONST();
     if (node != null)
     {
         // Remove the e in front of quotes, AND the Quotes
         String value = context.GetText();
         value = value.Substring(1);
         value = value.Substring(1, value.Length - 2);
         expr = new CodePrimitiveExpression(BuildUnEscapedString(value));
     }
     //
     node = context.CHAR_CONST();
     if (node != null)
     {
         // Remove the quotes
         String value = context.GetText();
         value = value.Substring(1, value.Length - 2);
         if (value.Length >= 1)
             expr = new CodePrimitiveExpression(value[0]);
     }
     //
     node = context.NIL();
     if (node != null)
     {
         expr = new CodeSnippetExpression("NIL");
     }
     //
     node = context.NULL();
     if (node != null)
     {
         expr = new CodePrimitiveExpression(null);
     }
     //
     node = context.NULL_ARRAY();
     if (node != null)
     {
         expr = new CodeSnippetExpression("NULL_ARRAY");
     }
     //
     node = context.NULL_CODEBLOCK();
     if (node != null)
     {
         expr = new CodeSnippetExpression("NULL_CODEBLOCK");
     }
     //
     node = context.NULL_DATE();
     if (node != null)
     {
         expr = new CodeSnippetExpression("NULL_DATE");
     }
     //
     node = context.NULL_OBJECT();
     if (node != null)
     {
         expr = new CodeSnippetExpression("NULL_OBJECT");
     }
     //            
     node = context.NULL_PSZ();
     if (node != null)
     {
         expr = new CodeSnippetExpression("NULL_PSZ");
     }
     //            
     node = context.NULL_PTR();
     if (node != null)
     {
         expr = new CodeSnippetExpression("NULL_PTR");
     }
     //            
     node = context.NULL_STRING();
     if (node != null)
     {
         expr = new CodeSnippetExpression("NULL_STRING");
     }
     //            
     node = context.NULL_SYMBOL();
     if (node != null)
     {
         expr = new CodeSnippetExpression("NULL_SYMBOL");
     }
     //
     node = context.SYMBOL_CONST();
     if (node != null)
     {
         expr = new CodeSnippetExpression(context.GetText().ToUpper());
     }
     //
     node = context.DATE_CONST();
     if (node != null)
     {
         expr = new CodeSnippetExpression(context.GetText());
     }
     //
     if ( expr == null )
     {
         expr = new CodeSnippetExpression(context.GetText());
     }
     return expr;
 }