public override int VisitOnDiv([NotNull] GrammarParser.OnDivContext context) { int l = Left(context), r = Right(context); int ans = 0; if (r == 0) { var ex = new Exception(); ex.Data.Add("Type", "div on null"); throw ex; } else { ans = l / r; } Console.WriteLine($"div {ans}"); return(ans); }
/// <summary> /// Visit a parse tree produced by the <c>OnDiv</c> /// labeled alternative in <see cref="GrammarParser.expression"/>. /// <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 VisitOnDiv([NotNull] GrammarParser.OnDivContext context) { return(VisitChildren(context)); }
/// <summary> /// Exit a parse tree produced by the <c>OnDiv</c> /// labeled alternative in <see cref="GrammarParser.expression"/>. /// <para>The default implementation does nothing.</para> /// </summary> /// <param name="context">The parse tree.</param> public virtual void ExitOnDiv([NotNull] GrammarParser.OnDivContext context) { }