public SyntaxNode VisitExpr([NotNull] QtParser.ExprContext context) { if (context.parenthesized != null) { return(context.parenthesized.Accept(this)); } if (context.let != null) { return(context.let.Accept(this)); } if (context.id != null) { return(context.id.Accept(this)); } if (context.elim != null) { return(context.elim.Accept(this)); } if (context.op != null) { string name = context.op.Text switch { "+" => "plus", "=" => "id", _ => throw new Exception("Unhandled") }; List <Expr> args = new List <Expr> { (Expr)context.left.Accept(this), (Expr)context.right.Accept(this) }; return(new AppExpr(name, args)); } if (context.num != null) { return(ExpandNum(context.num)); } Debug.Assert(context.fun != null && context._args.Count > 0); return(new AppExpr(context.fun.Text, context._args.Select(a => (Expr)a.Accept(this)).ToList())); }
/// <summary> /// Enter a parse tree produced by <see cref="QtParser.expr"/>. /// <para>The default implementation does nothing.</para> /// </summary> /// <param name="context">The parse tree.</param> public virtual void EnterExpr([NotNull] QtParser.ExprContext context) { }
/// <summary> /// Visit a parse tree produced by <see cref="QtParser.expr"/>. /// <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 VisitExpr([NotNull] QtParser.ExprContext context) { return(VisitChildren(context)); }