()
| 586 | } |
| 587 | |
| 588 | func (p *Parser) parseTableColumns() ([]Expr, error) { |
| 589 | columns := make([]Expr, 0) |
| 590 | for !p.lexer.isEOF() { |
| 591 | switch { |
| 592 | case p.matchKeyword(KeywordIndex): |
| 593 | indexPos := p.Pos() |
| 594 | _ = p.lexer.consumeToken() |
| 595 | index, err := p.parseTableIndex(indexPos) |
| 596 | if err != nil { |
| 597 | return nil, err |
| 598 | } |
| 599 | columns = append(columns, index) |
| 600 | case p.matchKeyword(KeywordConstraint): |
| 601 | constraintPos := p.Pos() |
| 602 | _ = p.lexer.consumeToken() |
| 603 | ident, err := p.parseIdent() |
| 604 | if err != nil { |
| 605 | return nil, err |
| 606 | } |
| 607 | if err := p.expectKeyword(KeywordCheck); err != nil { |
| 608 | return nil, err |
| 609 | } |
| 610 | expr, err := p.parseExpr(p.Pos()) |
| 611 | if err != nil { |
| 612 | return nil, err |
| 613 | } |
| 614 | columns = append(columns, &ConstraintClause{ |
| 615 | ConstraintPos: constraintPos, |
| 616 | Constraint: ident, |
| 617 | Expr: expr, |
| 618 | }) |
| 619 | case p.matchKeyword(KeywordProjection): |
| 620 | projection, err := p.parseTableProjection(p.Pos(), true) |
| 621 | if err != nil { |
| 622 | return nil, err |
| 623 | } |
| 624 | columns = append(columns, projection) |
| 625 | default: |
| 626 | column, err := p.tryParseTableColumnExpr(p.Pos()) |
| 627 | if err != nil { |
| 628 | return nil, err |
| 629 | } |
| 630 | if column == nil { |
| 631 | break |
| 632 | } |
| 633 | columns = append(columns, column) |
| 634 | } |
| 635 | if p.tryConsumeTokenKind(TokenKindComma) == nil { |
| 636 | break |
| 637 | } |
| 638 | } |
| 639 | // end of column definitions |
| 640 | return columns, nil |
| 641 | } |
| 642 | |
| 643 | func (p *Parser) tryParseTableColumnExpr(pos Pos) (*ColumnDef, error) { |
| 644 | if !p.matchTokenKind(TokenKindIdent) { |
no test coverage detected