parseDropCommand - Return ast.DropCommand created from tokens and validate the syntax Example of input parsable to the ast.DropCommand: DROP TABLE table;
()
| 413 | // Example of input parsable to the ast.DropCommand: |
| 414 | // DROP TABLE table; |
| 415 | func (parser *Parser) parseDropCommand() (ast.Command, error) { |
| 416 | // token.DROP already at current position in parser |
| 417 | dropCommand := &ast.DropCommand{Token: parser.currentToken} |
| 418 | |
| 419 | // token.DROP no longer needed |
| 420 | parser.nextToken() |
| 421 | |
| 422 | err := validateTokenAndSkip(parser, []token.Type{token.TABLE}) |
| 423 | if err != nil { |
| 424 | return nil, err |
| 425 | } |
| 426 | |
| 427 | err = validateToken(parser.currentToken.Type, []token.Type{token.IDENT}) |
| 428 | if err != nil { |
| 429 | return nil, err |
| 430 | } |
| 431 | dropCommand.Name = ast.Identifier{Token: parser.currentToken} |
| 432 | |
| 433 | // token.IDENT no longer needed |
| 434 | parser.nextToken() |
| 435 | |
| 436 | err = validateTokenAndSkip(parser, []token.Type{token.SEMICOLON}) |
| 437 | |
| 438 | return dropCommand, err |
| 439 | } |
| 440 | |
| 441 | // parseOrderByCommand - Return ast.OrderByCommand created from tokens and validate the syntax |
| 442 | // |
no test coverage detected