parse parses a statement from the given scanned tokens.
( depth int, sql string, tokens []sqlSymType, nakedIntType *types.T, )
| 171 | |
| 172 | // parse parses a statement from the given scanned tokens. |
| 173 | func (p *Parser) parse( |
| 174 | depth int, sql string, tokens []sqlSymType, nakedIntType *types.T, |
| 175 | ) (Statement, error) { |
| 176 | p.lexer.init(sql, tokens, nakedIntType) |
| 177 | defer p.lexer.cleanup() |
| 178 | if p.parserImpl.Parse(&p.lexer) != 0 { |
| 179 | if p.lexer.lastError == nil { |
| 180 | // This should never happen -- there should be an error object |
| 181 | // every time Parse() returns nonzero. We're just playing safe |
| 182 | // here. |
| 183 | p.lexer.Error("syntax error") |
| 184 | } |
| 185 | err := p.lexer.lastError |
| 186 | |
| 187 | //// Compatibility with 19.1 telemetry: prefix the telemetry keys |
| 188 | //// with the "syntax." prefix. |
| 189 | //// TODO(knz): move the auto-prefixing of feature names to a |
| 190 | //// higher level in the call stack. |
| 191 | //tkeys := errors.GetTelemetryKeys(err) |
| 192 | //if len(tkeys) > 0 { |
| 193 | // for i := range tkeys { |
| 194 | // tkeys[i] = "syntax." + tkeys[i] |
| 195 | // } |
| 196 | // err = errors.WithTelemetry(err, tkeys...) |
| 197 | //} |
| 198 | |
| 199 | return Statement{}, err |
| 200 | } |
| 201 | return Statement{ |
| 202 | AST: p.lexer.stmt, |
| 203 | SQL: sql, |
| 204 | NumPlaceholders: p.lexer.numPlaceholders, |
| 205 | NumAnnotations: p.lexer.numAnnotations, |
| 206 | }, nil |
| 207 | } |
| 208 | |
| 209 | // unaryNegation constructs an AST node for a negation. This attempts |
| 210 | // to preserve constant NumVals and embed the negative sign inside |
no test coverage detected