예제 #1
0
        /// <summary> a scanner with a CharPattern for sql server string literal.
        /// a sql server string literal is a string quoted by single quote,
        /// a single quote character is escaped by 2 single quotes.
        /// </summary>
        /// <returns> the scanner.
        /// </returns>
        public static Scanner IsSqlString()
        {
            /*
             * final CharPattern open = Patterns.IsChar('\'').Seq(
             * Patterns.or(Patterns.NotChar('\''), Patterns.IsString("''"))
             * .Many()
             * );
             * return isPattern(open, "'").Seq(name, isChar('\''));
             */
            Scanner q  = IsChar('\'');
            Scanner qs = IsPattern("sql string quoted", Patterns.Regex("(('')|[^'])*"), "quoted string");

            return(qs.Between(q, q).Rename("sql string"));
        }