示例#1
0
        /// <summary>
        /// scan from the current cursor position, from line to line, until
        /// a char not equal any of the pattern chars is found.
        /// </summary>
        /// <param name="InCsr"></param>
        /// <param name="InNotEqualChars"></param>
        /// <returns></returns>
        public TextLinesScanResults ScanNotEqual(
            TextLinesCursor InCsr,
            ScanPatterns InNotEqualPatterns,
            ScannerEndOfLineConsider InEolConsider)
        {
            ScanPatternResults   res;
            TextLinesScanResults rv = new TextLinesScanResults();

            TextLinesCursor csr = Scanner_InitialCursorSetup(this, InCsr);

            while (true)
            {
                if ((csr.Position == RelativePosition.End) ||
                    (csr.Position == RelativePosition.None))
                {
                    csr.Position = RelativePosition.None;
                    rv.Pos       = csr;
                    rv.WhatFound = ScannerWhatFound.NotFound;
                    break;
                }

                int ex = csr.LinesNode.Value.LineData.Length - 1;
                res = Scanner.ScanNotEqual(
                    csr.LinesNode.Value.LineData, csr.LineOx, ex,
                    InNotEqualPatterns);

                // a char not equal to the pattern chars is found.
                if (res.FoundPos >= 0)
                {
                    csr.LineOx   = res.FoundPos;
                    rv.Pos       = csr;
                    rv.WhatFound = ScannerWhatFound.PatternChar;
                    break;
                }
                else if (InEolConsider == ScannerEndOfLineConsider.Found)
                {
                    csr.LineOx   = -1;
                    rv.Pos       = csr;
                    rv.WhatFound = ScannerWhatFound.HardLineBreak;
                    break;
                }
                else
                {
                    csr.LineAdvance(this);
                }
            }

            return(rv);
        }
示例#2
0
        /// <summary>
        /// Scan forward in TextLines until char equal any of the pattern chars.
        /// </summary>
        /// <param name="InCsr"></param>
        /// <param name="InPatternChars"></param>
        /// <param name="InEolConsider"></param>
        /// <returns></returns>
        public TextLinesScanResults ScanEqualAny(
            TextLinesCursor InCsr,
            char[] InPatternChars,
            ScannerEndOfLineConsider InEolConsider)
        {
            TextLinesScanResults rv = new TextLinesScanResults();

            Scanner.ScanCharResults res;

            TextLinesCursor csr = Scanner_InitialCursorSetup(this, InCsr);

            while (true)
            {
                if ((csr.Position == RelativePosition.End) ||
                    (csr.Position == RelativePosition.None))
                {
                    csr.Position = RelativePosition.None;
                    rv.Pos       = csr;
                    rv.WhatFound = ScannerWhatFound.NotFound;
                    break;
                }

                res = Scanner.ScanEqualAny(
                    csr.LineData, csr.LineOx, InPatternChars);

                // char is found.
                if (res.ResultPos >= 0)
                {
                    csr.LineOx   = res.ResultPos;
                    rv.Pos       = csr;
                    rv.WhatFound = ScannerWhatFound.PatternChar;
                    break;
                }

                else if (InEolConsider == ScannerEndOfLineConsider.Found)
                {
                    csr.LineOx   = -1;
                    rv.Pos       = csr;
                    rv.WhatFound = ScannerWhatFound.HardLineBreak;
                    break;
                }

                csr.LineAdvance(this);
            }

            return(rv);
        }