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

Method VisitDecl

parse/parse.go:273–298  ·  view source on GitHub ↗

VisitDecl visits a parse tree produced by MangleParser#decl.

(ctx *gen.DeclContext)

Source from the content-addressed store, hash-verified

271
272// VisitDecl visits a parse tree produced by MangleParser#decl.
273func (p Parser) VisitDecl(ctx *gen.DeclContext) any {
274 atom := p.Visit(ctx.Atom()).(ast.Atom)
275 var descrAtoms []ast.Atom
276 if ctx.DescrBlock() != nil {
277 descrAtoms = p.Visit(ctx.DescrBlock()).([]ast.Atom)
278 }
279 // Check for 'temporal' keyword (T__0 corresponds to 'temporal' in the grammar)
280 if ctx.GetToken(gen.MangleParserT__0, 0) != nil {
281 descrAtoms = append(descrAtoms, ast.NewAtom(ast.DescrTemporal))
282 }
283 var bounds []ast.BoundDecl
284 for _, b := range ctx.AllBoundsBlock() {
285 bounds = append(bounds, p.Visit(b).(ast.BoundDecl))
286 }
287 var incl *ast.InclusionConstraint
288 if ctx.ConstraintsBlock() != nil {
289 gotIncl := p.Visit(ctx.ConstraintsBlock()).(ast.InclusionConstraint)
290 incl = &gotIncl
291 }
292 decl, err := ast.NewDecl(atom, descrAtoms, bounds, incl)
293 if err != nil {
294 p.errors.Add(err.Error(), ctx.GetStart().GetLine(), ctx.GetStart().GetColumn())
295 return ast.Decl{DeclaredAtom: atom}
296 }
297 return decl
298}
299
300// VisitDescrBlock visits a parse tree produced by MangleParser#descrBlock.
301func (p Parser) VisitDescrBlock(ctx *gen.DescrBlockContext) any {

Callers 1

VisitMethod · 0.95

Calls 9

VisitMethod · 0.95
NewAtomFunction · 0.92
NewDeclFunction · 0.92
ErrorMethod · 0.80
AtomMethod · 0.65
DescrBlockMethod · 0.65
AllBoundsBlockMethod · 0.65
ConstraintsBlockMethod · 0.65
AddMethod · 0.65

Tested by

no test coverage detected