parseWhereCommand - Return ast.WhereCommand created from tokens and validate the syntax Example of input parsable to the ast.WhereCommand: WHERE colName EQUAL 'potato'
()
| 351 | // Example of input parsable to the ast.WhereCommand: |
| 352 | // WHERE colName EQUAL 'potato' |
| 353 | func (parser *Parser) parseWhereCommand() (ast.Command, error) { |
| 354 | // token.WHERE already at current position in parser |
| 355 | whereCommand := &ast.WhereCommand{Token: parser.currentToken} |
| 356 | expressionIsValid := false |
| 357 | |
| 358 | // Ignore token.WHERE |
| 359 | parser.nextToken() |
| 360 | var err error |
| 361 | expressionIsValid, whereCommand.Expression, err = parser.getExpression() |
| 362 | if err != nil { |
| 363 | return nil, err |
| 364 | } |
| 365 | |
| 366 | if !expressionIsValid { |
| 367 | return nil, &LogicalExpressionParsingError{} |
| 368 | } |
| 369 | |
| 370 | err = validateToken(parser.currentToken.Type, []token.Type{token.SEMICOLON, token.ORDER}) |
| 371 | if err != nil { |
| 372 | return nil, err |
| 373 | } |
| 374 | |
| 375 | parser.skipIfCurrentTokenIsSemicolon() |
| 376 | |
| 377 | return whereCommand, nil |
| 378 | } |
| 379 | |
| 380 | // parseDeleteCommand - Return ast.DeleteCommand created from tokens and validate the syntax |
| 381 | // |
no test coverage detected