private bool extractPattern(int index, int[] next)
        {
            int start     = index;
            int end       = index;
            int indicator = index;

            if (expr_[index] == '(')
            {
                ++index;
                index     = extractSubPattern('(', ')', index);
                indicator = index;
                end       = extractRepetition(index);
                if (indicator == end)
                {
                    NdnRegexMatcherBase matcher = new NdnRegexBackrefMatcher(
                        expr_.Substring(start, (end) - (start)), backrefManager_);
                    backrefManager_.pushRef(matcher);
                    ((NdnRegexBackrefMatcher)matcher).lateCompile();

                    ILOG.J2CsMapping.Collections.Collections.Add(matchers_, matcher);
                }
                else
                {
                    ILOG.J2CsMapping.Collections.Collections.Add(matchers_, new NdnRegexRepeatMatcher(expr_.Substring(start, (end) - (start)), backrefManager_, indicator - start));
                }
            }
            else if (expr_[index] == '<')
            {
                ++index;
                index     = extractSubPattern('<', '>', index);
                indicator = index;
                end       = extractRepetition(index);
                ILOG.J2CsMapping.Collections.Collections.Add(matchers_, new NdnRegexRepeatMatcher(
                                                                 expr_.Substring(start, (end) - (start)), backrefManager_, indicator
                                                                 - start));
            }
            else if (expr_[index] == '[')
            {
                ++index;
                index     = extractSubPattern('[', ']', index);
                indicator = index;
                end       = extractRepetition(index);
                ILOG.J2CsMapping.Collections.Collections.Add(matchers_, new NdnRegexRepeatMatcher(
                                                                 expr_.Substring(start, (end) - (start)), backrefManager_, indicator
                                                                 - start));
            }
            else
            {
                throw new NdnRegexMatcherBase.Error("Unexpected syntax");
            }

            next[0] = end;

            return(true);
        }
Example #2
0
        /// <summary>
        /// Compile the regular expression to generate more matchers when necessary.
        /// </summary>
        ///
        protected internal override void compile()
        {
            NdnRegexMatcherBase matcher;

            if ('(' == expr_[0])
            {
                matcher = new NdnRegexBackrefMatcher(
                    expr_.Substring(0, (indicator_) - (0)), backrefManager_);
                backrefManager_.pushRef(matcher);
                ((NdnRegexBackrefMatcher)matcher).lateCompile();
            }
            else
            {
                matcher = new NdnRegexComponentSetMatcher(expr_.Substring(0, (indicator_) - (0)), backrefManager_);
            }

            ILOG.J2CsMapping.Collections.Collections.Add(matchers_, matcher);

            parseRepetition();
        }