Beispiel #1
0
        /// <summary>
        /// Compare if this non word pattern is equal to the substring starting at
        /// pos InBx.
        /// </summary>
        /// <param name="InBoundedString"></param>
        /// <param name="InBx"></param>
        /// <returns></returns>
        public bool IsEqual(Scanner.ScanBoundedString InBoundedString, int InBx)
        {
            int remLx = InBoundedString.Ex - InBx + 1;

            if (remLx < mValue.Length)
            {
                return(false);
            }
            else
            {
                int Lx = mValue.Length;
                return(InBoundedString.Substring(InBx, Lx) == mValue);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Return the ScannerNonWord which fully matches the non word pattern
        /// located at pos InIx in the string being searched. When the pattern is a
        /// single char, then this NonWord object is the matching object. When the
        /// pattern is a string, have to check each non word string as the pattern in
        /// the string.
        /// </summary>
        /// <param name="InStart"></param>
        /// <param name="InBoundedString"></param>
        /// <param name="InIx"></param>
        /// <returns></returns>
        public static ScannerNonWord FindInLookupChain(
            ScannerNonWord InStart, Scanner.ScanBoundedString InBoundedString, int InIx)
        {
            ScannerNonWord snw             = InStart;
            ScannerNonWord found           = null;
            ScannerNonWord foundSingleChar = null;

            // use the single linked list chaining structure of ScannerNonWord to
            // compare each nonword string to the char sequence in the scanned string.
            while (snw != null)
            {
                // this ScannerNonWord consists of a single char. there is no string of chars
                // that the char is the leading char of.
                // ( When the single char word is found have to continue looking. Rule is that
                //   matching delim strings take precedence over matching single char. )
                if (snw.IsNonWordChar == true)
                {
                    foundSingleChar = snw;
                }

                else if (snw.IsEqual(InBoundedString, InIx) == true)
                {
                    found = snw;
                    break;
                }

                snw = snw.NextLookup;
            }

            if (found != null)
            {
                return(found);
            }
            else
            {
                return(foundSingleChar);
            }
        }