Ejemplo n.º 1
0
        //When an error is manually thrown by a user.
        public override object VisitStat_throw([NotNull] algoParser.Stat_throwContext context)
        {
            //Evaluate the expression.
            AlgoValue throwStr = (AlgoValue)VisitExpr(context.expr());

            //Is it a string?
            if (throwStr.Type != AlgoValueType.String)
            {
                Error.Fatal(context, "Error message to throw must be a string.");
                return(null);
            }

            //Throw the error.
            Error.Fatal(context, (string)throwStr.Value);
            return(null);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Visit a parse tree produced by <see cref="algoParser.stat_throw"/>.
 /// <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 VisitStat_throw([NotNull] algoParser.Stat_throwContext context)
 {
     return(VisitChildren(context));
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Exit a parse tree produced by <see cref="algoParser.stat_throw"/>.
 /// <para>The default implementation does nothing.</para>
 /// </summary>
 /// <param name="context">The parse tree.</param>
 public virtual void ExitStat_throw([NotNull] algoParser.Stat_throwContext context)
 {
 }