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

            Functions.TryGetValue(functionName, out var function);

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

            CurrentFunction.Content.Append($"{functionName}(");
            var argsCount = context.function_call_arg().Length;
            var result    = VisitChildren(context);

            if (argsCount > 0)
            {
                CurrentFunction.Content.Remove(CurrentFunction.Content.Length - 2, 2);
            }
            CurrentFunction.Content.Append($");\n");

            return(result);
        }
 /// <summary>
 /// Exit a parse tree produced by the <c>function_call</c>
 /// labeled alternative in <see cref="xmllangParser.statement"/>.
 /// <para>The default implementation does nothing.</para>
 /// </summary>
 /// <param name="context">The parse tree.</param>
 public virtual void ExitFunction_call([NotNull] xmllangParser.Function_callContext context)
 {
 }
예제 #3
0
 /// <summary>
 /// Visit a parse tree produced by the <c>function_call</c>
 /// labeled alternative in <see cref="xmllangParser.statement"/>.
 /// <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_call([NotNull] xmllangParser.Function_callContext context)
 {
     return(VisitChildren(context));
 }