Esempio n. 1
0
        /// <summary>
        /// 返回表示行的起始位置的正则表达式。
        /// </summary>
        /// <param name="innerExp">内部的正则表达式。</param>
        /// <returns>表示行的起始位置的正则表达式。</returns>
        /// <overloads>
        /// <summary>
        /// 返回表示行的起始位置的正则表达式。
        /// </summary>
        /// </overloads>
        public static Regex BeginningOfLine(Regex innerExp)
        {
            AnchorExp anchorExp = innerExp as AnchorExp;

            if (anchorExp == null)
            {
                anchorExp = new AnchorExp(innerExp);
            }
            anchorExp.BeginningOfLine = true;
            return(anchorExp);
        }
Esempio n. 2
0
        /// <summary>
        /// 返回表示向前看的正则表达式。
        /// </summary>
        /// <param name="innerExp">内部的正则表达式。</param>
        /// <param name="regex">要向前看的正则表达式。</param>
        /// <returns>表示向前看的正则表达式。</returns>
        /// <overloads>
        /// <summary>
        /// 返回表示向前看的正则表达式。
        /// </summary>
        /// </overloads>
        public static Regex Trailing(Regex innerExp, Regex regex)
        {
            AnchorExp anchorExp = innerExp as AnchorExp;

            if (anchorExp == null)
            {
                anchorExp = new AnchorExp(innerExp);
            }
            anchorExp.TrailingExpression = regex;
            return(anchorExp);
        }
Esempio n. 3
0
        /// <summary>
        /// 检查正则表达式是否可以被嵌套。
        /// </summary>
        /// <param name="regex">要检查的正则表达式。</param>
        protected static void CheckRegex(Regex regex)
        {
            AnchorExp anchor = regex as AnchorExp;

            if (anchor != null)
            {
                if (anchor.BeginningOfLine)
                {
                    throw CompilerCommonExceptions.NestedBeginningOfLine("regex");
                }
                if (anchor.TrailingExpression == AnchorExp.EndOfLine)
                {
                    throw CompilerCommonExceptions.NestedEndOfLine("regex");
                }
                throw CompilerCommonExceptions.NestedTrailing("regex");
            }
            if (regex is EndOfFileExp)
            {
                throw CompilerCommonExceptions.NestedEndOfFile("regex");
            }
        }
Esempio n. 4
0
		/// <summary>
		/// 返回表示向前看的正则表达式。
		/// </summary>
		/// <param name="innerExp">内部的正则表达式。</param>
		/// <param name="regex">要向前看的正则表达式。</param>
		/// <returns>表示向前看的正则表达式。</returns>
		/// <overloads>
		/// <summary>
		/// 返回表示向前看的正则表达式。
		/// </summary>
		/// </overloads>
		public static Regex Trailing(Regex innerExp, Regex regex)
		{
			AnchorExp anchorExp = innerExp as AnchorExp;
			if (anchorExp == null)
			{
				anchorExp = new AnchorExp(innerExp);
			}
			anchorExp.TrailingExpression = regex;
			return anchorExp;
		}
Esempio n. 5
0
		/// <summary>
		/// 返回表示行的起始位置的正则表达式。
		/// </summary>
		/// <param name="innerExp">内部的正则表达式。</param>
		/// <returns>表示行的起始位置的正则表达式。</returns>
		/// <overloads>
		/// <summary>
		/// 返回表示行的起始位置的正则表达式。
		/// </summary>
		/// </overloads>
		public static Regex BeginningOfLine(Regex innerExp)
		{
			AnchorExp anchorExp = innerExp as AnchorExp;
			if (anchorExp == null)
			{
				anchorExp = new AnchorExp(innerExp);
			}
			anchorExp.BeginningOfLine = true;
			return anchorExp;
		}