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

Function parseLanguageList

dql/parser.go:2747–2779  ·  view source on GitHub ↗
(it *lex.ItemIterator)

Source from the content-addressed store, hash-verified

2745}
2746
2747func parseLanguageList(it *lex.ItemIterator) ([]string, error) {
2748 item := it.Item()
2749 var langs []string
2750 for ; item.Typ == itemName || item.Typ == itemPeriod || item.Typ == itemStar; item = it.Item() {
2751 langs = append(langs, item.Val)
2752 it.Next()
2753 if it.Item().Typ == itemColon {
2754 it.Next()
2755 } else {
2756 break
2757 }
2758 }
2759 if it.Item().Typ == itemPeriod {
2760 peekIt, err := it.Peek(1)
2761 if err != nil {
2762 return nil, err
2763 }
2764 if peekIt[0].Typ == itemPeriod {
2765 return nil, it.Errorf("Expected only one dot(.) while parsing language list.")
2766 }
2767 }
2768 it.Prev()
2769
2770 for _, lang := range langs {
2771 if lang == string(star) && len(langs) > 1 {
2772 return nil, errors.Errorf(
2773 "If * is used, no other languages are allowed in the language list. Found %v",
2774 langs)
2775 }
2776 }
2777
2778 return langs, nil
2779}
2780
2781func validKeyAtRoot(k string) bool {
2782 switch k {

Callers 5

parseArgumentsFunction · 0.85
parseGroupbyFunction · 0.85
parseDirectiveFunction · 0.85
getRootFunction · 0.85
godeepFunction · 0.85

Calls 5

ItemMethod · 0.80
PrevMethod · 0.80
NextMethod · 0.45
PeekMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected