public override int VisitBlock(BRAQParser.BlockContext context) { var prev_outer = outer_scope; var prev_local = local_scope; outer_scope = outer_scope.Concat(local_scope) .GroupBy(x => x.Key) .ToDictionary(x => x.Key, x => x.Last().Value); // создаём словарь, в котором происходит объединение локальных и внешних переменных с возможным замещением local_scope = new Dictionary <string, BRAQParser.Var_stmtContext>(); //для блока пока нет локальных переменных base.VisitBlock(context); //scope = outer_scope; local_scope = prev_local; outer_scope = prev_outer; return(0); }
/// <summary> /// Visit a parse tree produced by <see cref="BRAQParser.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] BRAQParser.BlockContext context) { return(VisitChildren(context)); }
/// <summary> /// Exit a parse tree produced by <see cref="BRAQParser.block"/>. /// <para>The default implementation does nothing.</para> /// </summary> /// <param name="context">The parse tree.</param> public virtual void ExitBlock([NotNull] BRAQParser.BlockContext context) { }