Beispiel #1
0
        public override string VisitProgram([NotNull] BasicParser.ProgramContext context)
        {
            string result = "";

            for (int i = 0; i < context.ChildCount; i++)
            {
                if (context.line(i) == null) // Empty lines
                {
                    continue;
                }
                string transedLine = Visit(context.line(i));
                if (string.IsNullOrWhiteSpace(transedLine))
                {
                    continue;
                }
#if DEBUG
                Console.WriteLine(transedLine);
#endif
                result += transedLine + Environment.NewLine;
            }

            if (definedSubs.Count > 0)
            {
                result = string.Join(Environment.NewLine, definedSubs.Values.ToArray()) + Environment.NewLine + result;
            }
            if (imports.Count > 0)
            {
                result = string.Join(Environment.NewLine, imports.ToArray()) + Environment.NewLine + result;
            }

            return(result);
        }
 /// <summary>
 /// Visit a parse tree produced by <see cref="BasicParser.program"/>.
 /// <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 VisitProgram([NotNull] BasicParser.ProgramContext context)
 {
     return(VisitChildren(context));
 }
 /// <summary>
 /// Exit a parse tree produced by <see cref="BasicParser.program"/>.
 /// <para>The default implementation does nothing.</para>
 /// </summary>
 /// <param name="context">The parse tree.</param>
 public virtual void ExitProgram([NotNull] BasicParser.ProgramContext context)
 {
 }