internal static XbRule ParseRule(string line, string[] text, ref int i, bool for_each) { if (i + 1 < text.Length) { XbCondition guard = null; string ctx; do { var newguard = ParseCondition(line); ctx = newguard.GetContext(); guard = CombineConditions(guard, newguard); i++; line = text[i].Trim(); } while (IsCondition(line)); var act = ParseAction(line, ctx); i++; if (for_each) { return(new XrIterativeAction(ctx, guard, act)); } else { return(new XrGuardedAction(guard, act)); } } else { throw new NotImplementedException("wrong xbib command: " + line); } }
internal XcNegation(XbCondition cond) { Inner = cond; if (Config.Debug) { Console.WriteLine($"[DEBUG] XcNegation of {cond} is created"); } }
public XrGuardedAction(XbCondition guard, XbAction act) { Guard = guard; Act = act; if (Config.Debug) { Console.WriteLine($"[DEBUG] XrGuardedAction of {Guard} => {Act}"); } }
public XrIterativeAction(string focus, XbCondition guard, XbAction act) { Focus = focus; Guard = guard; Act = act; if (Config.Debug) { Console.WriteLine($"[DEBUG] XrIterativeAction of {Focus} in {Guard} => {Act}"); } }
internal XcConjunction(XbCondition left, XbCondition right) { X = left; Y = right; }
private static XbCondition CombineConditions(XbCondition guard, XbCondition newguard) => guard == null ? newguard : new XcConjunction(guard, newguard);