Пример #1
0
        public override IAstNode VisitBlock([NotNull] FifthParser.BlockContext context)
        {
            var statements = new List <Statement>();

            foreach (var e in context.statement())
            {
                var node = base.Visit(e);
                if (node is Expression exp)
                {
                    node = new ExpressionStatement(exp);
                }

                statements.Add((Statement)node);
            }

            return(new Block(new StatementList(statements)).CaptureLocation(context.Start));
        }
Пример #2
0
 /// <summary>
 /// Visit a parse tree produced by <see cref="FifthParser.block"/>.
 /// <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 VisitBlock([NotNull] FifthParser.BlockContext context)
 {
     return(VisitChildren(context));
 }