private static UnifiedExpression CreateDstr(XElement node)
 {
     Contract.Requires(node != null);
     Contract.Requires(node.Name() == "dstr");
     // TODO: Implement
     return(UnifiedStringLiteral.Create(""));
 }
        public static UnifiedLiteral CreateStringLiteral(XElement node)
        {
            Contract.Requires(node != null);
            Contract.Requires(node.Name() == "STRING_LITERAL");

            /*
             * STRING_LITERAL
             * :  '"' ( EscapeSequence | ~('\\'|'"') )* '"'	;
             */
            // TODO ダブルクォーテーションの中だけ取得するのか確認
            return
                (UnifiedStringLiteral.Create(
                     node.Value.Substring(1, node.Value.Length - 2)));
        }
Beispiel #3
0
 public UnifiedElement VisitPrimitiveExpression(
     PrimitiveExpression prim, object data)
 {
     if (prim.Value == null)
     {
         return(UnifiedNullLiteral.Create());
     }
     if (prim.Value is bool)
     {
         return(UnifiedBooleanLiteral.Create((bool)prim.Value));
     }
     if (prim.Value is Int32)
     {
         return(UnifiedIntegerLiteral.CreateInt32((Int32)prim.Value));
     }
     if (prim.Value is UInt32)
     {
         return(UnifiedIntegerLiteral.CreateUInt32((UInt32)prim.Value));
     }
     if (prim.Value is Int64)
     {
         return(UnifiedIntegerLiteral.CreateInt64((Int64)prim.Value));
     }
     if (prim.Value is UInt64)
     {
         return(UnifiedIntegerLiteral.CreateUInt64((UInt64)prim.Value));
     }
     if (prim.Value is Single)
     {
         return(UnifiedFractionLiteral.Create(
                    (Single)prim.Value, UnifiedFractionLiteralKind.Single));
     }
     if (prim.Value is double)
     {
         return(UnifiedFractionLiteral.Create(
                    (double)prim.Value, UnifiedFractionLiteralKind.Double));
     }
     if (prim.Value is char)
     {
         return(UnifiedCharLiteral.Create(((char)prim.Value).ToString()));
     }
     if (prim.Value is string)
     {
         return(UnifiedStringLiteral.Create(prim.LiteralValue));
     }
     throw new NotImplementedException(
               "value type is " + prim.Value.GetType());
 }
 public override bool Visit(
         UnifiedStringLiteral element, VisitorArgument arg)
 {
     Writer.Write(element.Value);
     return false;
 }
 private static UnifiedExpression CreateStringConstPhrase(StringConstPhrase phrase)
 {
     return(UnifiedStringLiteral.Create(phrase.Text));
 }
 public static UnifiedStringLiteral CreateStr(XElement node)
 {
     Contract.Requires(node != null);
     Contract.Requires(node.Name() == "str");
     return(UnifiedStringLiteral.Create(node.Value));
 }
 public override bool Visit(
     UnifiedStringLiteral element, VisitorArgument arg)
 {
     Writer.Write(element.Value);
     return(false);
 }