VisitTemporalAnnotation visits a parse tree produced by MangleParser#temporalAnnotation. Returns an *ast.Interval.
(ctx *gen.TemporalAnnotationContext)
| 784 | // VisitTemporalAnnotation visits a parse tree produced by MangleParser#temporalAnnotation. |
| 785 | // Returns an *ast.Interval. |
| 786 | func (p Parser) VisitTemporalAnnotation(ctx *gen.TemporalAnnotationContext) any { |
| 787 | bounds := ctx.AllTemporalBound() |
| 788 | if len(bounds) == 0 { |
| 789 | p.errors.Add("temporal annotation requires at least one bound", ctx.GetStart().GetLine(), ctx.GetStart().GetColumn()) |
| 790 | return nil |
| 791 | } |
| 792 | |
| 793 | start := p.Visit(bounds[0]).(ast.TemporalBound) |
| 794 | |
| 795 | var end ast.TemporalBound |
| 796 | if len(bounds) > 1 { |
| 797 | end = p.Visit(bounds[1]).(ast.TemporalBound) |
| 798 | } else { |
| 799 | // Point interval: @[t] means @[t, t] |
| 800 | end = start |
| 801 | } |
| 802 | |
| 803 | if start.Type == ast.VariableBound && start.Variable.Symbol == "_" { |
| 804 | start = ast.NegativeInfinity() |
| 805 | } |
| 806 | if end.Type == ast.VariableBound && end.Variable.Symbol == "_" { |
| 807 | end = ast.PositiveInfinity() |
| 808 | } |
| 809 | |
| 810 | interval := ast.NewInterval(start, end) |
| 811 | return &interval |
| 812 | } |
| 813 | |
| 814 | // VisitTemporalBound visits a parse tree produced by MangleParser#temporalBound. |
| 815 | // Returns an ast.TemporalBound. |
no test coverage detected