예제 #1
0
 public SupplRangeSet(AbstractCharClass cs, AbstractSet next)
 {
     this.alt   = false;
     this.chars = cs.GetInstance();
     this.alt   = cs.alt;
     this.next  = next;
 }
예제 #2
0
        public override bool First(AbstractSet set)
        {
            if (set  is  SupplCharSet)
            {
                return(ILOG.J2CsMapping.RegEx.AbstractCharClass.Intersects(chars,
                                                                           ((SupplCharSet)set).GetCodePoint()));
            }
            else if (set  is  CharSet)
            {
                return(ILOG.J2CsMapping.RegEx.AbstractCharClass.Intersects(chars,
                                                                           ((CharSet)set).GetChar()));
            }
            else if (set  is  SupplRangeSet)
            {
                return(ILOG.J2CsMapping.RegEx.AbstractCharClass.Intersects(chars,
                                                                           ((SupplRangeSet)set).chars));
            }
            else if (set  is  RangeSet)
            {
                return(ILOG.J2CsMapping.RegEx.AbstractCharClass.Intersects(chars,
                                                                           ((RangeSet)set).GetChars()));
            }

            return(true);
        }
예제 #3
0
 public AbstractSet(AbstractSet n)
 {
     this.isSecondPassVisited = false;
     this.index = ((int)(AbstractSet.counter++)).ToString();
     this.type  = 0;
     next       = n;
 }
예제 #4
0
        public override bool First(AbstractSet set)
        {
            if (set  is  CharSet)
            {
                return(((CharSet)set).GetChar() == str0[0]);
            }
            else if (set  is  RangeSet)
            {
                return(((RangeSet)set).Accepts(0, str0.Substring(0, (1) - (0))) > 0);
            }
            else if (set  is  SupplRangeSet)
            {
                return(((SupplRangeSet)set).Contains(str0[0]) ||
                       ((str0.Length > 1) && ((SupplRangeSet)set)
                        .Contains(Character.ToCodePoint(str0[0],
                                                        str0[1]))));
            }
            else if ((set  is  SupplCharSet))
            {
                return((str0.Length > 1) ? ((SupplCharSet)set).GetCodePoint() == Character
                       .ToCodePoint(str0[0], str0[1]) : false);
            }

            return(true);
        }
예제 #5
0
 public CompositeRangeSet(AbstractSet withoutSurrogates_0,
                          AbstractSet withSurrogates_1, AbstractSet next)
 {
     this.withoutSurrogates = withoutSurrogates_0;
     this.withSurrogates    = withSurrogates_1;
     SetNext(next);
 }
예제 #6
0
        /// <summary>
        /// Returns stringIndex+shift, the next position to match
        /// </summary>
        ///
        public override int Matches(int stringIndex, String testString,
                                    MatchResultImpl matchResult)
        {
            int size      = children.Count;
            int leftBound = (matchResult.HasTransparentBounds()) ? 0 : matchResult
                            .GetLeftBound();

            int shift = next.Matches(stringIndex, testString, matchResult);

            if (shift >= 0)
            {
                //fSet will take this index to check if we at the right bound
                // and return true if the current index equal to this one
                matchResult.SetConsumed(groupIndex, stringIndex);
                for (int i = 0; i < size; i++)
                {
                    AbstractSet e = (AbstractSet)children[i];
                    // find limits could be calculated though e.getCharCount()
                    // fSet will return true only if string index at fSet equal
                    // to stringIndex
                    if (e.FindBack(leftBound, stringIndex, testString, matchResult) >= 0)
                    {
                        matchResult.SetConsumed(groupIndex, -1);
                        return(shift);
                    }
                }
            }

            return(-1);
        }
예제 #7
0
        public override bool First(AbstractSet set)
        {
            if (set  is  CharSet)
            {
                return(false);
            }
            else if (set  is  RangeSet)
            {
                return(false);
            }
            else if (set  is  SupplRangeSet)
            {
                return(false);
            }
            else if (set  is  SupplCharSet)
            {
                return(false);
            }
            else if (set  is  HighSurrogateCharSet)
            {
                return(false);
            }
            else if (set  is  LowSurrogateCharSet)
            {
                return(((LowSurrogateCharSet)set).low == this.low);
            }

            return(true);
        }
예제 #8
0
        /// <summary>
        /// Returns stringIndex+shift, the next position to match
        /// </summary>
        ///
        public override int Matches(int stringIndex, String testString,
                                    MatchResultImpl matchResult)
        {
            int start = matchResult.GetConsumed(groupIndex);

            matchResult.SetConsumed(groupIndex, stringIndex);

            int size = children.Count;

            for (int i = 0; i < size; i++)
            {
                AbstractSet e     = (AbstractSet)children[i];
                int         shift = e.Matches(stringIndex, testString, matchResult);
                if (shift >= 0)
                {
                    // AtomicFset always returns true, but saves the index to run
                    // this next.match() from;
                    return(next.Matches(((AtomicFSet)fSet).GetIndex(), testString,
                                        matchResult));
                }
            }

            matchResult.SetConsumed(groupIndex, start);
            return(-1);
        }
예제 #9
0
 /// <summary>
 /// Constructs CompositeGroupQuantifierSet
 /// </summary>
 ///
 /// <param name="quant">- given composite quantifier</param>
 /// <param name="innerSet">- given group</param>
 /// <param name="next">- next set after the quantifier</param>
 public CompositeGroupQuantifierSet(Quantifier quant, AbstractSet innerSet,
                                    AbstractSet next, int type, int setCounter_0) : base(innerSet, next, type)
 {
     this.quantifier = null;
     this.quantifier = quant;
     this.setCounter = setCounter_0;
 }
 public LowHighSurrogateRangeSet(AbstractCharClass surrChars_0,
                                 AbstractSet next)
 {
     this.alt       = false;
     this.surrChars = surrChars_0.GetInstance();
     this.alt       = surrChars_0.alt;
     SetNext(next);
 }
예제 #11
0
 /// <summary>
 /// Sets an inner set.
 /// </summary>
 ///
 /// <param name="innerSet">The innerSet to set.</param>
 public override void SetInnerSet(AbstractSet innerSet)
 {
     if (!(innerSet  is  LeafSet))
     {
         throw new Exception("regex.04");                 //$NON-NLS-1$
     }
     base.SetInnerSet(innerSet);
     this.leaf = (LeafSet)innerSet;
 }
예제 #12
0
        /// <summary>
        /// Runs match starting from <c>set</c> specified against input
        /// sequence starting at <c>index</c> specified; Result of the match
        /// will be stored into matchResult instance;
        /// </summary>
        ///
        private bool RunMatch(AbstractSet set, int index,
                              MatchResultImpl matchResult_0)
        {
            if (set.Matches(index, str0, matchResult_0) >= 0)
            {
                matchResult_0.FinalizeMatch();
                return(true);
            }

            return(false);
        }
예제 #13
0
        /// <summary>
        /// This method is used for traversing nodes after the
        /// first stage of compilation.
        /// </summary>
        ///
        public override void ProcessSecondPass()
        {
            this.isSecondPassVisited = true;

            if (fSet != null && !fSet.isSecondPassVisited)
            {
                /*
                 * Add here code to do during the pass
                 */

                /*
                 * End code to do during the pass
                 */
                fSet.ProcessSecondPass();
            }

            if (children != null)
            {
                int childrenSize = children.Count;

                for (int i = 0; i < childrenSize; i++)
                {
                    AbstractSet child = (AbstractSet)children[i];

                    /*
                     * Add here code to do during the pass
                     */

                    JointSet set = child.ProcessBackRefReplacement();

                    if (set != null)
                    {
                        child.isSecondPassVisited = true;
                        ILOG.J2CsMapping.Collections.Collections.RemoveAt(children, i);
                        children.Insert(i, set);
                        child = (AbstractSet)set;
                    }

                    /*
                     * End code to do during the pass
                     */
                    if (!child.isSecondPassVisited)
                    {
                        child.ProcessSecondPass();
                    }
                }
            }

            if (next != null)
            {
                base.ProcessSecondPass();
            }
        }
예제 #14
0
        public override bool First(AbstractSet set)
        {
            if (children != null)
            {
                for (IIterator i = new ILOG.J2CsMapping.Collections.IteratorAdapter(children.GetEnumerator()); i.HasNext();)
                {
                    if (((AbstractSet)i.Next()).First(set))
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
예제 #15
0
        /// <summary>
        /// This method is used for traversing nodes after the
        /// first stage of compilation.
        /// </summary>
        ///
        public virtual void ProcessSecondPass()
        {
            this.isSecondPassVisited = true;

            if (next != null)
            {
                if (!next.isSecondPassVisited)
                {
                    /*
                     * Add here code to do during the pass
                     */
                    JointSet set = next.ProcessBackRefReplacement();

                    if (set != null)
                    {
                        next.isSecondPassVisited = true;
                        next = (AbstractSet)set;
                    }

                    /*
                     * End code to do during the pass
                     */
                    next.ProcessSecondPass();
                }
                else
                {
                    /*
                     * We reach node through next but it is already traversed.
                     * You can see this situation for AltGroupQuantifierSet.next
                     * when we reach this node through
                     * AltGroupQuantifierSet.innerset. ... .next
                     */

                    /*
                     * Add here code to do during the pass
                     */
                    if (next  is  SingleSet &&
                        ((FSet)((JointSet)next).fSet).isBackReferenced)
                    {
                        next = next.next;
                    }

                    /*
                     * End code to do during the pass
                     */
                }
            }
        }
예제 #16
0
        /// <summary>
        /// Returns stringIndex+shift, the next position to match
        /// </summary>
        ///
        public override int Matches(int stringIndex, String testString,
                                    MatchResultImpl matchResult)
        {
            int size = children.Count;

            for (int i = 0; i < size; i++)
            {
                AbstractSet e = (AbstractSet)children[i];
                if (e.Matches(stringIndex, testString, matchResult) >= 0)
                {
                    return(-1);
                }
            }

            return(next.Matches(stringIndex, testString, matchResult));
        }
예제 #17
0
        /// @com.intel.drl.spec_ref
        public Matcher UsePattern(Pattern pat_0)
        {
            if (pat_0 == null)
            {
                throw new ArgumentException("regex.1B");
            }
            int startIndex = matchResult.GetPreviousMatchEnd();
            int mode       = matchResult.Mode();

            this.pat    = pat_0;
            this.start  = pat_0.start;
            matchResult = new MatchResultImpl(this.str0, leftBound, rightBound,
                                              pat_0.GroupCount(), pat_0.CompCount(), pat_0.ConsCount());
            matchResult.SetStartIndex(startIndex);
            matchResult.SetMode(mode);
            return(this);
        }
예제 #18
0
        /// <summary>
        /// Returns stringIndex+shift, the next position to match
        /// </summary>
        ///
        public override int Matches(int stringIndex, String testString,
                                    MatchResultImpl matchResult)
        {
            int size = children.Count;

            for (int i = 0; i < size; i++)
            {
                AbstractSet e     = (AbstractSet)children[i];
                int         shift = e.Matches(stringIndex, testString, matchResult);
                if (shift >= 0)
                {
                    // PosLookaheadFset always returns true, position remains the
                    // same
                    // next.match() from;
                    return(next.Matches(stringIndex, testString, matchResult));
                }
            }

            return(-1);
        }
예제 #19
0
 internal Matcher(Pattern pat_0, String cs)
 {
     this.pat              = null;
     this.start            = null;
     this.str0             = null;
     this.matchResult      = null;
     this.leftBound        = -1;
     this.rightBound       = -1;
     this.appendPos        = 0;
     this.replacement      = null;
     this.processedRepl    = null;
     this.replacementParts = null;
     this.pat              = pat_0;
     this.start            = pat_0.start;
     this.str0             = cs;
     this.leftBound        = 0;
     this.rightBound       = str0.Length;
     matchResult           = new MatchResultImpl(cs, leftBound, rightBound,
                                                 pat_0.GroupCount(), pat_0.CompCount(), pat_0.ConsCount());
 }
예제 #20
0
        public override bool First(AbstractSet set)
        {
            if (set  is  SupplCharSet)
            {
                return(((SupplCharSet)set).GetCodePoint() == ch);
            }
            else if (set  is  SupplRangeSet)
            {
                return(((SupplRangeSet)set).Contains(ch));
            }
            else if (set  is  CharSet)
            {
                return(false);
            }
            else if (set  is  RangeSet)
            {
                return(false);
            }

            return(true);
        }
예제 #21
0
        /// <summary>
        /// Returns stringIndex+shift, the next position to match
        /// </summary>
        ///
        public override int Matches(int stringIndex, String testString,
                                    MatchResultImpl matchResult)
        {
            int start = matchResult.GetConsumed(groupIndex);

            matchResult.SetConsumed(groupIndex, stringIndex);

            int size = children.Count;

            for (int i = 0; i < size; i++)
            {
                AbstractSet e     = (AbstractSet)children[i];
                int         shift = e.Matches(stringIndex, testString, matchResult);
                if (shift >= 0)
                {
                    return(shift);
                }
            }
            matchResult.SetConsumed(groupIndex, start);
            return(-1);
        }
예제 #22
0
        public override bool First(AbstractSet set)
        {
            if (set  is  CharSet)
            {
                return(((CharSet)set).GetChar() == ch);
            }
            else if (set  is  RangeSet)
            {
                return(((RangeSet)set).Accepts(0, System.Char.ToString(ch)) > 0);
            }
            else if (set  is  SupplRangeSet)
            {
                return(((SupplRangeSet)set).Contains(ch));
            }
            else if (set  is  SupplCharSet)
            {
                return(false);
            }

            return(true);
        }
        public override bool First(AbstractSet set)
        {
            if (set  is  CharSet)
            {
                return(false);
            }
            else if (set  is  RangeSet)
            {
                return(false);
            }
            else if (set  is  SupplRangeSet)
            {
                return(false);
            }
            else if (set  is  SupplCharSet)
            {
                return(false);
            }

            return(true);
        }
예제 #24
0
        /// <summary>
        /// This method is used for traversing nodes after the
        /// first stage of compilation.
        /// </summary>
        ///
        public override void ProcessSecondPass()
        {
            this.isSecondPassVisited = true;

            if (fSet != null && !fSet.isSecondPassVisited)
            {
                /*
                 * Add here code to do during the pass
                 */

                /*
                 * End code to do during the pass
                 */
                fSet.ProcessSecondPass();
            }

            if (kid != null && !kid.isSecondPassVisited)
            {
                /*
                 * Add here code to do during the pass
                 */
                JointSet set = kid.ProcessBackRefReplacement();

                if (set != null)
                {
                    kid.isSecondPassVisited = true;
                    kid = (AbstractSet)set;
                }

                /*
                 * End code to do during the pass
                 */

                kid.ProcessSecondPass();
            }
        }
예제 #25
0
 public override bool First(AbstractSet set)
 {
     return((set  is  DecomposedCharSet) ? ((DecomposedCharSet)set)
            .GetDecomposedChar().Equals(GetDecomposedChar()) : true);
 }
예제 #26
0
 public UnifiedQuantifierSet(LeafSet innerSet, AbstractSet next, int type) : base(innerSet, next, type)
 {
 }
예제 #27
0
 public PossessiveAltQuantifierSet(LeafSet innerSet, AbstractSet next,
                                   int type) : base(innerSet, next, type)
 {
 }
예제 #28
0
 public override void SetNext(AbstractSet next)
 {
     this.next = next;
 }
 public RelAltGroupQuantifierSet(AbstractSet innerSet, AbstractSet next,
                                 int type) : base(innerSet, next, type)
 {
 }
예제 #30
0
 public RangeSet(AbstractCharClass cs, AbstractSet next) : base(next)
 {
     this.alt   = false;
     this.chars = cs.GetInstance();
     this.alt   = cs.alt;
 }