Beispiel #1
0
        public override string VisitLine([NotNull] BasicParser.LineContext context)
        {
            string lineMark = "";

            if (context.number() != null)
            {
                lineMark = Visit(context.number());
            }
            if (!string.IsNullOrWhiteSpace(SubProg))
            {
                definedSubs[SubProg] += Environment.NewLine + TAB + Visit(context.statement()).Replace(Environment.NewLine + TAB, Environment.NewLine + TAB + TAB); // Add extra TAB for if statement in the subproc
                return("");
            }
            if (!string.IsNullOrWhiteSpace(lineMark) && subsMarks.Contains(lineMark))
            {
                SubProg = lineMark;
                definedSubs[SubProg] = $"def f{lineMark}():" +
                                       Environment.NewLine + TAB + Visit(context.statement()).Replace(Environment.NewLine + TAB, Environment.NewLine + TAB + TAB); // Add extra TAB for if statement in the subproc
                return("");
            }
            return(Visit(context.statement()));
        }
 /// <summary>
 /// Visit a parse tree produced by <see cref="BasicParser.line"/>.
 /// <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 VisitLine([NotNull] BasicParser.LineContext context)
 {
     return(VisitChildren(context));
 }
 /// <summary>
 /// Exit a parse tree produced by <see cref="BasicParser.line"/>.
 /// <para>The default implementation does nothing.</para>
 /// </summary>
 /// <param name="context">The parse tree.</param>
 public virtual void ExitLine([NotNull] BasicParser.LineContext context)
 {
 }