parseDeleteCommand - Return ast.DeleteCommand created from tokens and validate the syntax Example of input parsable to the ast.DeleteCommand: DELETE FROM table;
()
| 382 | // Example of input parsable to the ast.DeleteCommand: |
| 383 | // DELETE FROM table; |
| 384 | func (parser *Parser) parseDeleteCommand() (ast.Command, error) { |
| 385 | // token.DELETE already at current position in parser |
| 386 | deleteCommand := &ast.DeleteCommand{Token: parser.currentToken} |
| 387 | |
| 388 | // token.DELETE no longer needed |
| 389 | parser.nextToken() |
| 390 | |
| 391 | err := validateTokenAndSkip(parser, []token.Type{token.FROM}) |
| 392 | if err != nil { |
| 393 | return nil, err |
| 394 | } |
| 395 | |
| 396 | err = validateToken(parser.currentToken.Type, []token.Type{token.IDENT}) |
| 397 | if err != nil { |
| 398 | return nil, err |
| 399 | } |
| 400 | deleteCommand.Name = ast.Identifier{Token: parser.currentToken} |
| 401 | |
| 402 | // token.IDENT no longer needed |
| 403 | parser.nextToken() |
| 404 | |
| 405 | // expect WHERE |
| 406 | err = validateToken(parser.currentToken.Type, []token.Type{token.WHERE}) |
| 407 | |
| 408 | return deleteCommand, err |
| 409 | } |
| 410 | |
| 411 | // parseDropCommand - Return ast.DropCommand created from tokens and validate the syntax |
| 412 | // |
no test coverage detected