parsePeriodDefinition parses: PERIOD FOR name (start_col, end_col) The caller positions the parser at the PERIOD keyword; this function advances past it.
()
| 438 | // parsePeriodDefinition parses: PERIOD FOR name (start_col, end_col) |
| 439 | // The caller positions the parser at the PERIOD keyword; this function advances past it. |
| 440 | func (p *Parser) parsePeriodDefinition() (*ast.PeriodDefinition, error) { |
| 441 | // current token is PERIOD; advance past it |
| 442 | p.advance() |
| 443 | if !strings.EqualFold(p.currentToken.Token.Value, "FOR") { |
| 444 | return nil, p.expectedError("FOR") |
| 445 | } |
| 446 | p.advance() |
| 447 | |
| 448 | // Use parseColumnName so that reserved-keyword period names like SYSTEM_TIME are accepted. |
| 449 | name := p.parseColumnName() |
| 450 | if name == nil || name.Name == "" { |
| 451 | return nil, p.expectedError("period name") |
| 452 | } |
| 453 | |
| 454 | if !p.isType(models.TokenTypeLParen) { |
| 455 | return nil, p.expectedError("(") |
| 456 | } |
| 457 | p.advance() |
| 458 | |
| 459 | startCol := p.parseIdent() |
| 460 | if startCol == nil || startCol.Name == "" { |
| 461 | return nil, p.expectedError("start column name") |
| 462 | } |
| 463 | |
| 464 | if !p.isType(models.TokenTypeComma) { |
| 465 | return nil, p.expectedError(",") |
| 466 | } |
| 467 | p.advance() |
| 468 | |
| 469 | endCol := p.parseIdent() |
| 470 | if endCol == nil || endCol.Name == "" { |
| 471 | return nil, p.expectedError("end column name") |
| 472 | } |
| 473 | |
| 474 | if !p.isType(models.TokenTypeRParen) { |
| 475 | return nil, p.expectedError(")") |
| 476 | } |
| 477 | p.advance() |
| 478 | |
| 479 | return &ast.PeriodDefinition{Name: name, StartCol: startCol, EndCol: endCol}, nil |
| 480 | } |
no test coverage detected