MCPcopy
hub / github.com/google/mangle / VisitProgram

Method VisitProgram

parse/parse.go:228–246  ·  view source on GitHub ↗

VisitProgram visits a parse tree produced by MangleParser#program.

(ctx *gen.ProgramContext)

Source from the content-addressed store, hash-verified

226
227// VisitProgram visits a parse tree produced by MangleParser#program.
228func (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.
249func (p Parser) VisitPackageDecl(ctx *gen.PackageDeclContext) any {

Callers 1

VisitMethod · 0.95

Calls 5

VisitMethod · 0.95
PackageDeclMethod · 0.65
AllUseDeclMethod · 0.65
AllDeclMethod · 0.65
AllClauseMethod · 0.65

Tested by

no test coverage detected