private void ParseDataType(KayleeParser.DtypeContext dtype)
 {
     if (dtype.DTYPE_BIT() != null)
     {
         Field.Type = FieldType.BIT;
     }
     else if (dtype.DTYPE_TINYINT() != null)
     {
         Field.Type = FieldType.TINYINT;
     }
     else if (dtype.DTYPE_INT() != null)
     {
         Field.Type          = FieldType.INT;
         Field.AutoIncrement = dtype.dtypeIntAutoIncrement() != null;
     }
     else if (dtype.DTYPE_BIGINT() != null)
     {
         Field.Type          = FieldType.BIGINT;
         Field.AutoIncrement = dtype.dtypeBigintAutoIncrement() != null;
     }
     else if (dtype.DTYPE_DECIMAL() != null)
     {
         Field.Type = FieldType.DECIMAL;
         var size      = dtype.dTypeDecimalSize().GetText();
         var precision = dtype.dtypeDecimalPrecision().GetText();
         Field.Size = FieldSize.ForSize(long.Parse(size), long.Parse(precision));
     }
     else if (dtype.DTYPE_CHAR() != null)
     {
         Field.Type = FieldType.CHAR;
     }
     else if (dtype.DTYPE_TEXT() != null)
     {
         Field.Type = FieldType.TEXT;
         var size = dtype.dtypeTextSize().GetText();
         if (size == "MAX")
         {
             Field.Size = FieldSize.ForMax();
         }
         else
         {
             Field.Size = FieldSize.ForSize(long.Parse(size));
         }
     }
     else if (dtype.DTYPE_GUID() != null)
     {
         Field.Type = FieldType.GUID;
     }
     else if (dtype.DTYPE_DATE() != null)
     {
         Field.Type = FieldType.DATE;
     }
     else if (dtype.DTYPE_VARBINARY() != null)
     {
         Field.Type = FieldType.VARBINARY;
         var size = dtype.dtypeVarbinarySize().GetText();
         if (size == "MAX")
         {
             Field.Size = FieldSize.ForMax();
         }
         else
         {
             Field.Size = FieldSize.ForSize(long.Parse(size));
         }
     }
     else if (dtype.DTYPE_BINARY() != null)
     {
         Field.Type = FieldType.BINARY;
         var size = dtype.dtypeBinarySize().GetText();
         Field.Size = FieldSize.ForSize(long.Parse(size));
     }
     else if (dtype.DTYPE_ROWVERSION() != null)
     {
         Field.Type = FieldType.ROWVERSION;
     }
 }
Beispiel #2
0
 /// <summary>
 /// Exit a parse tree produced by <see cref="KayleeParser.dtype"/>.
 /// <para>The default implementation does nothing.</para>
 /// </summary>
 /// <param name="context">The parse tree.</param>
 public virtual void ExitDtype([NotNull] KayleeParser.DtypeContext context)
 {
 }