| 579 | } |
| 580 | |
| 581 | func parseNamespace(it *lex.ItemIterator) (uint64, error) { |
| 582 | nextItems, err := it.Peek(2) |
| 583 | if err != nil { |
| 584 | return 0, errors.Errorf("Unable to peek: %v", err) |
| 585 | } |
| 586 | if nextItems[0].Typ != itemNumber || nextItems[1].Typ != itemRightSquare { |
| 587 | return 0, errors.Errorf("Typed oes not match the expected") |
| 588 | } |
| 589 | ns, err := strconv.ParseUint(nextItems[0].Val, 0, 64) |
| 590 | if err != nil { |
| 591 | return 0, err |
| 592 | } |
| 593 | it.Next() |
| 594 | it.Next() |
| 595 | // We have parsed the namespace. Now move to the next item. |
| 596 | if !it.Next() { |
| 597 | return 0, errors.Errorf("No schema found after namespace. Got: %v", nextItems[0]) |
| 598 | } |
| 599 | return ns, nil |
| 600 | } |
| 601 | |
| 602 | // ParsedSchema represents the parsed schema and type updates. |
| 603 | type ParsedSchema struct { |