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()));
        }