VisitDecl visits a parse tree produced by MangleParser#decl.
(ctx *gen.DeclContext)
| 271 | |
| 272 | // VisitDecl visits a parse tree produced by MangleParser#decl. |
| 273 | func (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. |
| 301 | func (p Parser) VisitDescrBlock(ctx *gen.DescrBlockContext) any { |
no test coverage detected