VisitTemporalBound visits a parse tree produced by MangleParser#temporalBound. Returns an ast.TemporalBound.
(ctx *gen.TemporalBoundContext)
| 814 | // VisitTemporalBound visits a parse tree produced by MangleParser#temporalBound. |
| 815 | // Returns an ast.TemporalBound. |
| 816 | func (p Parser) VisitTemporalBound(ctx *gen.TemporalBoundContext) any { |
| 817 | if ts := ctx.TIMESTAMP(); ts != nil { |
| 818 | text := ts.GetText() |
| 819 | t, err := parseTimestamp(text) |
| 820 | if err != nil { |
| 821 | p.errors.Add(fmt.Sprintf("invalid timestamp %q: %v", text, err), ctx.GetStart().GetLine(), ctx.GetStart().GetColumn()) |
| 822 | return ast.TemporalBound{} |
| 823 | } |
| 824 | return ast.NewTimestampBound(t) |
| 825 | } |
| 826 | |
| 827 | if dur := ctx.DURATION(); dur != nil { |
| 828 | text := dur.GetText() |
| 829 | d, err := parseDuration(text) |
| 830 | if err != nil { |
| 831 | p.errors.Add(fmt.Sprintf("invalid duration %q: %v", text, err), ctx.GetStart().GetLine(), ctx.GetStart().GetColumn()) |
| 832 | return ast.TemporalBound{} |
| 833 | } |
| 834 | return ast.NewDurationBound(d) |
| 835 | } |
| 836 | |
| 837 | if v := ctx.VARIABLE(); v != nil { |
| 838 | text := v.GetText() |
| 839 | return ast.NewVariableBound(ast.Variable{Symbol: text}) |
| 840 | } |
| 841 | |
| 842 | // Check for 'now' keyword |
| 843 | if ctx.GetText() == "now" { |
| 844 | return ast.Now() |
| 845 | } |
| 846 | |
| 847 | p.errors.Add("unknown temporal bound", ctx.GetStart().GetLine(), ctx.GetStart().GetColumn()) |
| 848 | return ast.TemporalBound{} |
| 849 | } |
| 850 | |
| 851 | // VisitTemporalOperator visits a parse tree produced by MangleParser#temporalOperator. |
| 852 | // Returns an *ast.TemporalOperator. |
no test coverage detected