예제 #1
0
        /// <summary>
        /// Unwraps the specified context.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <returns></returns>
        public static string Unwrap(this TSQLParser.TypeContext context)
        {
            if (context.qualifiedName() != null)
            {
                return(context.qualifiedName().Unwrap());
            }
            if (context.typeInBracket() != null)
            {
                return(context.typeInBracket().type().Unwrap());
            }

            return(Unwrap(context.GetText()));
        }
        /// <summary>
        /// Visit a parse tree produced by <see cref="TSQLParser.type" />.
        /// </summary>
        /// <param name="context">The parse tree.</param>
        /// <returns></returns>
        /// <return>The visitor result.</return>
        public override Type VisitType(TSQLParser.TypeContext context)
        {
            if (context.qualifiedName() != null)
            {
                return(typeof(object));
            }
            if (context.characterStringType() != null)
            {
                return(typeof(string));
            }
            if (context.numericType() != null)
            {
                return(typeof(decimal));
            }
            if (context.identityType() != null)
            {
                return(typeof(int));
            }
            if (context.integerType() != null)
            {
                return(typeof(int));
            }
            if (context.XML() != null)
            {
                return(typeof(string));
            }
            if (context.CURSOR() != null)
            {
                return(typeof(void));
            }
            if (context.typeInBracket() != null)
            {
                return(VisitType(context.typeInBracket().type()));
            }

            throw new ArgumentException("invalid type");
        }