Пример #1
0
        public override AstNode VisitLambdaWithExpr(StannumParser.LambdaWithExprContext context)
        {
            var @params = new List <string>();

            for (var i = 0; i < context._Params.Count; i += 1)
            {
                @params.Add(context._Params[i].GetText());
            }

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

            var body = new BlockStmt(new List <Stmt> {
                new ExprStmt(new ReturnExpr(value))
            });

            return(new LambdaExpr(@params, body));
        }
Пример #2
0
 /// <summary>
 /// Visit a parse tree produced by <see cref="StannumParser.lambdaWithExpr"/>.
 /// <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 VisitLambdaWithExpr([NotNull] StannumParser.LambdaWithExprContext context)
 {
     return(VisitChildren(context));
 }