public override object VisitFunction_decl([NotNull] xmllangParser.Function_declContext context)
        {
            var functionName = context.ID().ToString();

            Functions.TryGetValue(functionName, out var function);

            if (function != null)
            {
                throw new Exception(VisitorExceptionMessages.AlreadyDefinedFunction);
            }

            CurrentFunction = new Function
            {
                Name    = functionName,
                Content = new StringBuilder($"public static void {functionName}(")
            };
            CurrentVarScope = new VarScope(CurrentFunction.Name);

            return(VisitChildren(context));
        }
 /// <summary>
 /// Exit a parse tree produced by <see cref="xmllangParser.function_decl"/>.
 /// <para>The default implementation does nothing.</para>
 /// </summary>
 /// <param name="context">The parse tree.</param>
 public virtual void ExitFunction_decl([NotNull] xmllangParser.Function_declContext context)
 {
 }
Beispiel #3
0
 /// <summary>
 /// Visit a parse tree produced by <see cref="xmllangParser.function_decl"/>.
 /// <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 VisitFunction_decl([NotNull] xmllangParser.Function_declContext context)
 {
     return(VisitChildren(context));
 }