private static bool TryTakeMatch(RuleTokenKeeper tokenKeeper, out ApplyIfRuleClause clause) { var next = tokenKeeper.Next; if (next.TokenType == ApplyIfTokenType.Match) { var work = new RuleTokenKeeper(tokenKeeper); work.Take(); if (work.Next.TokenType == ApplyIfTokenType.OpenParen) { work.Take(); if (EntityReferenceParser.TryTakeEntityReference(work, out var entityReference)) { if (work.Next.TokenType == ApplyIfTokenType.CloseParen) { work.Take(); } tokenKeeper.Swap(work); clause = new MatchClause(entityReference); return(true); } } } clause = null; return(false); }
private static bool TryTakeRuleSequence(RuleTokenKeeper tokenKeeper, out ApplyIfRuleClause clause) { var work = new RuleTokenKeeper(tokenKeeper); if (TryTakeRuleClause(work, out var left)) { if (work.Next.TokenType == ApplyIfTokenType.Comma) { ApplyIfRuleClause right; work.Take(); if (TryTakeRuleSequence(work, out right) || TryTakeRuleClause(work, out right)) { if (work.Finished) { tokenKeeper.Swap(work); clause = new RuleSequenceClause(left, right); return(true); } } } } clause = null; return(false); }
public ApplyIfRule(ApplyIfRuleClause clause) { Valid = true; Root = clause; RequireFirstError = clause.GetRequireFirstError(); RequireCleanInput = clause.GetRequireCleanInput(); _matches = clause.GetMatches() .Select(m => new FieldReference(m.Entity, m.Field)) .ToList(); }
private static bool TryTakeRuleClause(RuleTokenKeeper tokenKeeper, out ApplyIfRuleClause clause) { if (TryTakeCleanInput(tokenKeeper, out clause) || TryTakeFirstError(tokenKeeper, out clause) || TryTakeMatch(tokenKeeper, out clause)) { return(true); } clause = null; return(false); }
private static bool TryTakeFirstError(RuleTokenKeeper tokenKeeper, out ApplyIfRuleClause clause) { var next = tokenKeeper.Next; if (next.TokenType == ApplyIfTokenType.FirstError) { clause = new FirstErrorClause(); tokenKeeper.Take(); return(true); } clause = null; return(false); }
private static bool TryTakeCleanInput(RuleTokenKeeper tokenKeeper, out ApplyIfRuleClause clause) { var next = tokenKeeper.Next; if (next.TokenType == ApplyIfTokenType.CleanInput) { clause = new CleanInputClause(); tokenKeeper.Take(); return(true); } clause = null; return(false); }
public RuleSequenceClause(ApplyIfRuleClause left, ApplyIfRuleClause right) { Left = left; Right = right; }