Open makenowjust opened 2 weeks ago
This PR introduces BadNode and ErrorList.
BadNode
ErrorList
*memefish.Error
Example:
$ go run ./tools/parse/main.go 'select (1 +) * (% 2)' --- Error syntax error: :1:12: unexpected token: ) 1: select (1 +) * (% 2) ^ syntax error: :1:17: unexpected token: % 1: select (1 +) * (% 2) ^ --- AST &ast.QueryStatement{ Hint: (*ast.Hint)(nil), With: (*ast.With)(nil), Query: &ast.Select{ Select: 0, Distinct: false, As: nil, Results: []ast.SelectItem{ &ast.ExprSelectItem{ Expr: &ast.BinaryExpr{ Op: "*", Left: &ast.ParenExpr{ Lparen: 7, Rparen: 11, Expr: &ast.BadNode{ NodePos: 8, NodeEnd: 11, Raw: "1 +", }, }, Right: &ast.ParenExpr{ Lparen: 15, Rparen: 19, Expr: &ast.BadNode{ NodePos: 16, NodeEnd: 19, Raw: "% 2", }, }, }, }, }, From: (*ast.From)(nil), Where: (*ast.Where)(nil), GroupBy: (*ast.GroupBy)(nil), Having: (*ast.Having)(nil), OrderBy: (*ast.OrderBy)(nil), Limit: (*ast.Limit)(nil), }, } --- SQL SELECT (1 +) * (% 2)
This PR introduces
BadNode
andErrorList
.BadNode
is a placeholder node for a source fragment containing syntax errors.ErrorList
is an error consisting of a list of*memefish.Error
.Example: