public override AstNode VisitCall(StannumParser.CallContext context) { if (!(Visit(context.Callee) is Expr callee)) { throw new Exception("Unrecognized expression!"); } var arguments = new List <Expr>(); for (var i = 0; i < context._Args.Count; i += 1) { if (!(Visit(context._Args[i]) is Expr argument)) { throw new Exception("Unrecognized expression!"); } arguments.Add(argument); } return(new CallExpr(callee, arguments)); }
/// <summary> /// Visit a parse tree produced by the <c>Call</c> /// labeled alternative in <see cref="StannumParser.accessOrCall"/>. /// <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 VisitCall([NotNull] StannumParser.CallContext context) { return(VisitChildren(context)); }