コード例 #1
0
ファイル: Markup.cs プロジェクト: ericmargules/SmidgenParser
        public void Digest(char input)
        {
            // Digest does the following
            // Checks provided input against failure conditions
            // Checks if input matches current milestone
            // If input matches
            //   Adds input to charCache
            //   Determines if complete
            //   Determines if changes to milestones are required
            // If input !matches
            //   Checks if repeating pattern is found
            //   Fails markup and resets

            if (_currentMilestone > 0)
            {
                if (CheckFailures(input))
                {
                    Reset();
                    return;
                }
            }

            Milestone  current = _milestones[_currentMilestone];
            MatchTypes matched = current.Match(input);

            if (matched != MatchTypes.none && current.Satisfied)
            {
                if (!current.Repeating || (current.Repeating && current.RequiredReps > 0))
                {
                    AdvanceMilestone();
                }
            }
            else if (current.Satisfied && current.Repeating)
            {
                MatchTypes nextMatched = CheckMilestone(_currentMilestone + 1, input);
                if (nextMatched != MatchTypes.none)
                {
                    AdvanceMilestone();
                    if (!Successful)
                    {
                        AdvanceMilestone();
                    }
                }
            }
            else
            {
                Reset();
            }
        }
コード例 #2
0
ファイル: Markup.cs プロジェクト: ericmargules/SmidgenParser
        protected MatchTypes CheckMilestone(int milestoneIdx, char input)
        {
            Milestone milestone = _milestones[milestoneIdx];

            return(milestone.Match(input));
        }