public override ExecutionContext VisitColorier(Cosmos.ColorierContext context) { var dark = ""; var translatedColor = ""; if (context.dark != null) { dark = "Dark"; } if (context.blue != null) { translatedColor = "Blue"; } else if (context.green != null) { translatedColor = "Green"; } else if (context.red != null) { translatedColor = "Red"; } else if (context.white != null) { translatedColor = "White"; } else if (context.black != null) { translatedColor = "Black"; } else { throw new UnHandledColorException("La couleur indiquée n'est pas encore prise en charge"); } var newColor = ConsoleColor.Gray; bool parse = ConsoleColor.TryParse($"{dark}{translatedColor}", out newColor); if (parse) { if (context.background != null) { executionConsole.SetBackColorTo(newColor.ToString()); } else { executionConsole.SetFrontColorTo(newColor.ToString()); } } return(null); }
/// <summary> /// Visit a parse tree produced by <see cref="Cosmos.colorier"/>. /// <para> /// The default implementation returns the result of calling <see cref="AbstractParseTreeVisitor{Result}.VisitChildren(IRuleNode)"/> /// on <paramref name="context"/>. /// </para> /// </summary> /// <param name="context">The parse tree.</param> /// <return>The visitor result.</return> public virtual Result VisitColorier([NotNull] Cosmos.ColorierContext context) { return(VisitChildren(context)); }
/// <summary> /// Exit a parse tree produced by <see cref="Cosmos.colorier"/>. /// <para>The default implementation does nothing.</para> /// </summary> /// <param name="context">The parse tree.</param> public virtual void ExitColorier([NotNull] Cosmos.ColorierContext context) { }