| 2571 | } |
| 2572 | |
| 2573 | func parseVarList(it *lex.ItemIterator, gq *GraphQuery) (int, error) { |
| 2574 | count := 0 |
| 2575 | expectArg := true |
| 2576 | it.Next() |
| 2577 | item := it.Item() |
| 2578 | if item.Typ != itemLeftRound { |
| 2579 | return count, item.Errorf("Expected a left round after var") |
| 2580 | } |
| 2581 | |
| 2582 | loop: |
| 2583 | for it.Next() { |
| 2584 | item := it.Item() |
| 2585 | switch item.Typ { |
| 2586 | case itemRightRound: |
| 2587 | break loop |
| 2588 | case itemComma: |
| 2589 | if expectArg { |
| 2590 | return count, item.Errorf("Expected a variable but got comma") |
| 2591 | } |
| 2592 | expectArg = true |
| 2593 | case itemName: |
| 2594 | if !expectArg { |
| 2595 | return count, item.Errorf("Expected a variable but got %s", item.Val) |
| 2596 | } |
| 2597 | count++ |
| 2598 | gq.NeedsVar = append(gq.NeedsVar, VarContext{ |
| 2599 | Name: item.Val, |
| 2600 | Typ: UidVar, |
| 2601 | }) |
| 2602 | expectArg = false |
| 2603 | } |
| 2604 | } |
| 2605 | if expectArg { |
| 2606 | return count, item.Errorf("Unnecessary comma in val()") |
| 2607 | } |
| 2608 | return count, nil |
| 2609 | } |
| 2610 | |
| 2611 | func parseTypeList(it *lex.ItemIterator, gq *GraphQuery) error { |
| 2612 | typeList := it.Item().Val |