Beispiel #1
0
        /// <summary>
        /// Adds the lookup.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <param name="startLocation">The start location.</param>
        /// <param name="endLocation">The end location.</param>
        /// <param name="canCoalesce">if set to <c>true</c> [can coalesce].</param>
        public void AddLookup(RegexItem item, int startLocation, int endLocation, bool canCoalesce)
        {
            if (item == null)
            {
                throw new ArgumentNullException("item", "RegexItem is null");
            }

            if (this.inseries)
            {
                // in a series, add character to the previous one...
                if (canCoalesce)
                {
                    RegexRef lastItem = (RegexRef)this.expressionLookup[this.expressionLookup.Count - 1];
                    lastItem.StringValue += item.ToString(0);
                    lastItem.Length      += endLocation - startLocation + 1;
                }
                else
                {
                    this.expressionLookup.Add(new RegexRef(item, startLocation, endLocation));
                    this.inseries = false;
                }
            }
            else
            {
                if (canCoalesce)
                {
                    this.inseries = true;
                }

                this.expressionLookup.Add(new RegexRef(item, startLocation, endLocation));
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="RegexRef"/> class.
        /// </summary>
        /// <param name="regexItem">The regex item.</param>
        /// <param name="start">The start.</param>
        /// <param name="end">The end.</param>
        public RegexRef(RegexItem regexItem, int start, int end)
        {
            if (regexItem == null)
            {
                throw new ArgumentNullException("regexItem", "RegexItem is null");
            }

            this.StringValue = regexItem.ToString(0);
            this.start = start;
            this.end = end;
        }
Beispiel #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RegexRef"/> class.
        /// </summary>
        /// <param name="regexItem">The regex item.</param>
        /// <param name="start">The start.</param>
        /// <param name="end">The end.</param>
        public RegexRef(RegexItem regexItem, int start, int end)
        {
            if (regexItem == null)
            {
                throw new ArgumentNullException(nameof(regexItem), "RegexItem is null");
            }

            this.StringValue = regexItem.ToString(0);
            this.start       = start;
            this.end         = end;
        }
        /// <summary>
        /// Adds the lookup.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <param name="startLocation">The start location.</param>
        /// <param name="endLocation">The end location.</param>
        /// <param name="canCoalesce">if set to <c>true</c> [can coalesce].</param>
        public void AddLookup(RegexItem item, int startLocation, int endLocation, bool canCoalesce)
        {
            if (item == null)
            {
                throw new ArgumentNullException("item", "RegexItem is null");
            }

            if (this.inseries)
            {
                    // in a series, add character to the previous one...
                if (canCoalesce)
                {
                    RegexRef lastItem = (RegexRef)this.expressionLookup[this.expressionLookup.Count - 1];
                    lastItem.StringValue += item.ToString(0);
                    lastItem.Length += endLocation - startLocation + 1;
                }
                else
                {
                    this.expressionLookup.Add(new RegexRef(item, startLocation, endLocation));
                    this.inseries = false;
                }
            }
            else
            {
                if (canCoalesce)
                {
                    this.inseries = true;
                }

                this.expressionLookup.Add(new RegexRef(item, startLocation, endLocation));
            }
        }