We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Running this code produces a ParseError (as expected), but the error doesn't have position information:
package main import ( "fmt" "time" "github.com/alecthomas/participle/v2" "github.com/alecthomas/participle/v2/lexer" ) type Expression struct { Alias string `@Ident "="` Timestamp *Timestamp `@Number` } type Timestamp int64 func (ts *Timestamp) Capture(values []string) error { t, err := time.Parse("2006", values[0]) if err != nil { return err } *ts = Timestamp(t.Unix()) return nil } var exprLexer = lexer.MustSimple([]lexer.Rule{ {"Whitespace", `\s+`, nil}, {"String", `"(\\"|[^"])*"`, nil}, {"Number", `[-+]?(\d*\.)?\d+`, nil}, {"Ident", `[a-zA-Z_]\w*`, nil}, {"Punct", `[-[!@#$%^&*()+_={}\|:;"'<,>.?/]|]`, nil}, }) func main() { parser := participle.MustBuild(&Expression{}, participle.Lexer(exprLexer), participle.Unquote(), participle.Elide("Whitespace")) expr := &Expression{} err := parser.ParseString("", "foo = 03", expr) if err != nil { parseErr := err.(participle.Error) fmt.Println("error at position", parseErr.Position(), parseErr) return } fmt.Println("success:", expr.Alias, "=", *expr.Timestamp) }
The output is:
error at position 0:0 Expression.Timestamp: parsing time "03" as "2006": cannot parse "03" as "2006"
(using github.com/alecthomas/participle/v2 v2.0.0-alpha7)
The text was updated successfully, but these errors were encountered:
I did a bit of digging and this is definitely a bug. Unfortunately the fix is non-trivial so it might take a little while.
Sorry, something went wrong.
alecthomas
No branches or pull requests
Running this code produces a ParseError (as expected), but the error doesn't have position information:
The output is:
(using github.com/alecthomas/participle/v2 v2.0.0-alpha7)
The text was updated successfully, but these errors were encountered: