VisitProgram visits a parse tree produced by MangleParser#program.
(ctx *gen.ProgramContext)
| 226 | |
| 227 | // VisitProgram visits a parse tree produced by MangleParser#program. |
| 228 | func (p Parser) VisitProgram(ctx *gen.ProgramContext) any { |
| 229 | var decls []ast.Decl |
| 230 | if packageDeclCtx := ctx.PackageDecl(); packageDeclCtx != nil { |
| 231 | decls = append(decls, p.Visit(packageDeclCtx).(ast.Decl)) |
| 232 | } else { |
| 233 | decls = append(decls, emptyPackage) |
| 234 | } |
| 235 | for _, u := range ctx.AllUseDecl() { |
| 236 | decls = append(decls, p.Visit(u).(ast.Decl)) |
| 237 | } |
| 238 | for _, d := range ctx.AllDecl() { |
| 239 | decls = append(decls, p.Visit(d).(ast.Decl)) |
| 240 | } |
| 241 | var clauses []ast.Clause |
| 242 | for _, c := range ctx.AllClause() { |
| 243 | clauses = append(clauses, p.Visit(c).(ast.Clause)) |
| 244 | } |
| 245 | return SourceUnit{decls, clauses} |
| 246 | } |
| 247 | |
| 248 | // VisitPackageDecl visits a parse tree produced by MangleParser#packageDecl. |
| 249 | func (p Parser) VisitPackageDecl(ctx *gen.PackageDeclContext) any { |
no test coverage detected