Added tests and fixed timestamp handling
All checks were successful
/ publish (push) Successful in 47s

This commit is contained in:
Leon Mika 2025-11-19 22:33:10 +11:00
parent 5c89c44ff7
commit e74906e0c4
4 changed files with 164 additions and 34 deletions

View file

@ -8,17 +8,19 @@ import (
)
var basicLexer = lexer.MustSimple([]lexer.SimpleRule{
{"Identifier", `[a-zA-Z_][a-zA-Z0-9_]*`},
{"Identifier", `[a-z][a-zA-Z0-9_]*`},
{"Date", `\d{4}-\d{2}-\d{2}`},
{"Timestamp", `\d{4}-\d{2}-\d{2}T?\d{2}:\d{2}:\d{2}Z?`},
{"Time", `\d{2}:\d{2}:\d{2}Z?`},
{"Time", `\d{2}:\d{2}:\d{2}`},
{"Int", `\d+`},
{"T", `T`},
{"Z", `Z`},
{"Whitespace", `[ ]+`},
})
var parser = participle.MustBuild[Atom](
participle.Lexer(basicLexer),
participle.Elide("Whitespace"),
participle.UseLookahead(2),
)
func Parse(expr string) (TimeResult, error) {