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

Function parseListItemNames

dql/parser.go:1116–1139  ·  view source on GitHub ↗

parses till rightSquare is found (parses [a, b]) excluding leftSquare This function can be reused for query later

(it *lex.ItemIterator)

Source from the content-addressed store, hash-verified

1114// parses till rightSquare is found (parses [a, b]) excluding leftSquare
1115// This function can be reused for query later
1116func parseListItemNames(it *lex.ItemIterator) ([]string, error) {
1117 var items []string
1118 for it.Next() {
1119 item := it.Item()
1120 switch item.Typ {
1121 case itemRightSquare:
1122 return items, nil
1123 case itemName:
1124 val := collectName(it, item.Val)
1125 items = append(items, val)
1126 case itemComma:
1127 it.Next()
1128 item = it.Item()
1129 if item.Typ != itemName {
1130 return items, item.Errorf("Invalid scheam block")
1131 }
1132 val := collectName(it, item.Val)
1133 items = append(items, val)
1134 default:
1135 return items, item.Errorf("Invalid schema block")
1136 }
1137 }
1138 return items, it.Errorf("Expecting ] to end list but none was found")
1139}
1140
1141// parseSchemaPredsOrTypes parses till rightround is found
1142func parseSchemaPredsOrTypes(it *lex.ItemIterator, s *pb.SchemaRequest) error {

Callers 1

parseSchemaPredsOrTypesFunction · 0.85

Calls 4

collectNameFunction · 0.85
ItemMethod · 0.80
NextMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected