Esempio n. 1
0
        public override AstNode VisitBlockExpr(StannumParser.BlockExprContext context)
        {
            var stmts = new List <Stmt>();

            for (var i = 0; i < context._Stmts.Count; i += 1)
            {
                if (!(Visit(context._Stmts[i]) is Stmt stmt))
                {
                    throw new Exception("Unrecognized statement!");
                }

                stmts.Add(stmt);
            }

            if (!(Visit(context.Value) is Expr value))
            {
                throw new Exception("Unrecognized expression!");
            }

            return(new BlockExpr(stmts, value));
        }
Esempio n. 2
0
 /// <summary>
 /// Visit a parse tree produced by <see cref="StannumParser.blockExpr"/>.
 /// <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 VisitBlockExpr([NotNull] StannumParser.BlockExprContext context)
 {
     return(VisitChildren(context));
 }