Пример #1
0
        public void TryParse()
        {
            FoosMatch match;

            Assert.IsTrue(MatchParser.TryParse("@playerA @playerB 1-10", out match));
            Assert.AreEqual("@playerB", match.Winner.Id);
            Assert.AreEqual("@playerA", match.Looser.Id);
            Assert.AreEqual(10, match.GoalsWinner);
            Assert.AreEqual(1, match.GoalsLooser);
        }
Пример #2
0
        public override int VisitMatch <TOutput>(MatchParser <TInput, TOutput> parser, int start)
        {
            var len = parser.Consumer(_source, start);

            if (len >= 0)
            {
                _prevWasMissing = false;
            }

            return(len);
        }
 public override Parser <TInput> VisitMatch <TOutput>(MatchParser <TInput, TOutput> parser)
 {
     state.InputLength = parser.Consumer(source, state.InputStart);
     if (state.InputLength >= 0)
     {
         this.prevWasMissing = false;
         return(null);
     }
     else
     {
         // keep prevWasMissing the same
         return(null);
     }
 }
Пример #4
0
 public override Parser <TInput> VisitMatch <TOutput>(MatchParser <TInput, TOutput> parser)
 {
     state.InputLength = parser.Parse(source, state.InputStart, output, output.Count);
     return(null);
 }
Пример #5
0
 public override Parser <TInput> VisitMatch(MatchParser <TInput> parser)
 {
     throw new System.NotImplementedException();
 }
 public override void VisitMatch <TOutput>(MatchParser <TInput, TOutput> parser)
 {
     WriteTerm("match()");
 }
Пример #7
0
 public override Parser <TInput> VisitMatch(MatchParser <TInput> parser)
 {
     state.InputLength = parser.Scan(source, state.InputStart);
     return(null);
 }
Пример #8
0
        public static IEnumerable <FoosMatch> GetMatches(IEnumerable <Message> messages)
        {
            FoosMatch match = null;

            return(messages.Where(m => MatchParser.TryParse(m.Text, out match)).Select(m => match));
        }
Пример #9
0
 public override Parser <TInput> VisitMatch <TOutput>(MatchParser <TInput, TOutput> parser)
 {
     // not proven safe here because scan of MatchParser is user defined
     state.InputLength = parser.Scan(source, state.InputStart);
     return(null);
 }