MCPcopy
hub / github.com/dgraph-io/dgraph / parseVarList

Function parseVarList

dql/parser.go:2573–2609  ·  view source on GitHub ↗
(it *lex.ItemIterator, gq *GraphQuery)

Source from the content-addressed store, hash-verified

2571}
2572
2573func 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
2582loop:
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
2611func parseTypeList(it *lex.ItemIterator, gq *GraphQuery) error {
2612 typeList := it.Item().Val

Callers 3

parseArgumentsFunction · 0.85
getRootFunction · 0.85
godeepFunction · 0.85

Calls 3

ItemMethod · 0.80
NextMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected