MCPcopy Index your code
hub / github.com/google/mangle / VisitTemporalBound

Method VisitTemporalBound

parse/parse.go:816–849  ·  view source on GitHub ↗

VisitTemporalBound visits a parse tree produced by MangleParser#temporalBound. Returns an ast.TemporalBound.

(ctx *gen.TemporalBoundContext)

Source from the content-addressed store, hash-verified

814// VisitTemporalBound visits a parse tree produced by MangleParser#temporalBound.
815// Returns an ast.TemporalBound.
816func (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.

Callers 1

VisitMethod · 0.95

Calls 10

NewTimestampBoundFunction · 0.92
NewDurationBoundFunction · 0.92
NewVariableBoundFunction · 0.92
NowFunction · 0.92
parseTimestampFunction · 0.85
parseDurationFunction · 0.85
TIMESTAMPMethod · 0.65
AddMethod · 0.65
DURATIONMethod · 0.65
VARIABLEMethod · 0.65

Tested by

no test coverage detected