示例#1
0
文件: Sequance.cs 项目: nidarg/JSN
        public IMatch Match(string text)
        {
            IMatch match = new SuccessMatch(text);

            foreach (var pattern in patterns)
            {
                match = pattern.Match(match.RemainingText());
                if (!match.Success())
                {
                    return(new FailedMatch(text));
                }
            }

            return(match);

#pragma warning disable S125 // Sections of code should not be commented out

            // string textCopy = text;

            // foreach (var pattern in patterns)
            // {
            //    var match = pattern.Match(text);
            //    if (match.Success())
            //    {

            // text = match.RemainingText();
            //    }
            //    else return new FailedMatch(textCopy);

            // }
            // return new SuccessMatch(text);
        }
示例#2
0
        public IMatch Match(string text)
        {
            IMatch match = new SuccessMatch(text);

            foreach (var pattern in patterns)
            {
                match = pattern.Match(match.RemainingText());
                if (!match.Success())
                {
                    return(new FailedMatch(text));
                }
            }
            return(match);

            //string textCopy = text;

            //foreach (var pattern in patterns)
            //{
            //    var match = pattern.Match(text);
            //    if (match.Success())
            //    {

            //        text = match.RemainingText();
            //    }
            //    else return new FailedMatch(textCopy);

            //}
            //return new SuccessMatch(text);
        }