예제 #1
0
        public override string VisitRoot(VeeParser.RootContext context)
        {
            var    declarations = context.declarations();
            string declarationStrs;

            if (declarations != null)
            {
                declarationStrs = Visit(declarations) + " ";
            }
            else
            {
                declarationStrs = "";
            }
            return($" {declarationStrs}return {Visit(context.expression())}; ");
        }
예제 #2
0
        public override Node VisitRoot([NotNull] VeeParser.RootContext context)
        {
            var declarations = context.declarations();
            IEnumerable <Node> children;

            if (declarations != null)
            {
                children = declarations.declaration().Select(Visit);
            }
            else
            {
                children = Enumerable.Empty <Node>();
            }

            return(new Node("root", NodeType.Root, children.Concat(new[] { Visit(context.expression()) }).ToArray()));
        }
예제 #3
0
 /// <summary>
 /// Visit a parse tree produced by <see cref="VeeParser.root"/>.
 /// <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 VisitRoot([NotNull] VeeParser.RootContext context)
 {
     return(VisitChildren(context));
 }