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

Method VisitTemporalAnnotation

parse/parse.go:786–812  ·  view source on GitHub ↗

VisitTemporalAnnotation visits a parse tree produced by MangleParser#temporalAnnotation. Returns an *ast.Interval.

(ctx *gen.TemporalAnnotationContext)

Source from the content-addressed store, hash-verified

784// VisitTemporalAnnotation visits a parse tree produced by MangleParser#temporalAnnotation.
785// Returns an *ast.Interval.
786func (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.

Callers 1

VisitMethod · 0.95

Calls 6

VisitMethod · 0.95
NegativeInfinityFunction · 0.92
PositiveInfinityFunction · 0.92
NewIntervalFunction · 0.92
AllTemporalBoundMethod · 0.65
AddMethod · 0.65

Tested by

no test coverage detected