override protected List <PossibleMatch> ImplementMatch(PossibleMatch State, MatchContext Context) { var R = new List <PossibleMatch>(); R.AddRange(Sub.Match(State, Context)); if (R.Count == 0) { throw new CommandParser.MatchAborted(Message); } return(R); }
public List <PossibleMatch> Match(PossibleMatch State, MatchContext Context) { var R = new List <PossibleMatch>(); R.AddRange(Sub.Match(State, Context)); if (R.Count == 0) { R.Add(State); } return(R); }
override protected List <PossibleMatch> ImplementMatch(PossibleMatch State, MatchContext Context) { var R = new List <PossibleMatch>(); if (String.IsNullOrEmpty(BooleanProperty)) { R.AddRange(Sub.Match(State, Context)); if (R.Count == 0) { R.Add(State); } } else { R.AddRange(Sub.Match(State, Context).Select(s => s.With(BooleanProperty, true))); if (R.Count == 0) { R.Add(State.With(BooleanProperty, false)); } } return(R); }
public List <PossibleMatch> Match(PossibleMatch State, MatchContext Context) { var r = Sub.Match(State, Context); var highestScoreFound = MatchPreference.VeryUnlikely; foreach (var match in r) { var score = GetScore(match, ScoreArgument); if (score > highestScoreFound) { highestScoreFound = score; } } return(new List <PossibleMatch>(r.Where(m => highestScoreFound == GetScore(m, ScoreArgument)))); }