VisitTransform visits a parse tree produced by MangleParser#transform.
(ctx *gen.TransformContext)
| 366 | |
| 367 | // VisitTransform visits a parse tree produced by MangleParser#transform. |
| 368 | func (p Parser) VisitTransform(ctx *gen.TransformContext) any { |
| 369 | var stmts []ast.TransformStmt |
| 370 | if ctx.DO() != nil { |
| 371 | term := p.Visit(ctx.Term()).(ast.Term) |
| 372 | apply, ok := term.(ast.ApplyFn) |
| 373 | if !ok { |
| 374 | p.errors.Add(fmt.Sprintf("expected fn application got %v", term), ctx.Term().GetStart().GetLine(), ctx.Term().GetStart().GetColumn()) |
| 375 | return ast.Transform{} |
| 376 | } |
| 377 | stmts = append(stmts, ast.TransformStmt{nil, apply}) |
| 378 | } |
| 379 | for _, l := range ctx.AllLetStmt() { |
| 380 | stmts = append(stmts, p.Visit(l).(ast.TransformStmt)) |
| 381 | } |
| 382 | return ast.Transform{stmts, nil} |
| 383 | } |
| 384 | |
| 385 | // VisitLetStmt visits a parse tree produced by MangleParser#letStmt. |
| 386 | func (p Parser) VisitLetStmt(ctx *gen.LetStmtContext) any { |