(it *lex.ItemIterator, typeName string, ns uint64)
| 525 | } |
| 526 | |
| 527 | func parseTypeField(it *lex.ItemIterator, typeName string, ns uint64) (*pb.SchemaUpdate, error) { |
| 528 | field := &pb.SchemaUpdate{Predicate: x.NamespaceAttr(ns, it.Item().Val)} |
| 529 | var list bool |
| 530 | it.Next() |
| 531 | |
| 532 | // Simplified type definitions only require the field name. If a new line is found, |
| 533 | // proceed to the next field in the type. |
| 534 | if it.Item().Typ == itemNewLine { |
| 535 | return field, nil |
| 536 | } |
| 537 | |
| 538 | // For the sake of backwards-compatibility, process type definitions in the old format, |
| 539 | // but ignore the information after the colon. |
| 540 | if it.Item().Typ != itemColon { |
| 541 | return nil, it.Item().Errorf("Missing colon in type declaration. Got %v", it.Item().Val) |
| 542 | } |
| 543 | |
| 544 | it.Next() |
| 545 | if it.Item().Typ == itemLeftSquare { |
| 546 | list = true |
| 547 | it.Next() |
| 548 | } |
| 549 | |
| 550 | if it.Item().Typ != itemText { |
| 551 | return nil, it.Item().Errorf("Missing field type in type declaration. Got %v", |
| 552 | it.Item().Val) |
| 553 | } |
| 554 | |
| 555 | it.Next() |
| 556 | if it.Item().Typ == itemExclamationMark { |
| 557 | it.Next() |
| 558 | } |
| 559 | |
| 560 | if list { |
| 561 | if it.Item().Typ != itemRightSquare { |
| 562 | return nil, it.Item().Errorf("Expected matching square bracket. Got %v", it.Item().Val) |
| 563 | } |
| 564 | it.Next() |
| 565 | |
| 566 | if it.Item().Typ == itemExclamationMark { |
| 567 | it.Next() |
| 568 | } |
| 569 | } |
| 570 | |
| 571 | if it.Item().Typ != itemNewLine { |
| 572 | return nil, it.Item().Errorf("Expected new line after field declaration. Got %v", |
| 573 | it.Item().Val) |
| 574 | } |
| 575 | |
| 576 | glog.Warningf("Type declaration for type %s includes deprecated information about field type "+ |
| 577 | "for field %s which will be ignored.", typeName, x.ParseAttr(field.Predicate)) |
| 578 | return field, nil |
| 579 | } |
| 580 | |
| 581 | func parseNamespace(it *lex.ItemIterator) (uint64, error) { |
| 582 | nextItems, err := it.Peek(2) |
no test coverage detected