MCPcopy
hub / github.com/kashav/fsql / parseAttrs

Method parseAttrs

parser/attribute.go:22–48  ·  view source on GitHub ↗

parseAttrs parses the list of attributes passed to the SELECT clause.

(attributes *[]string, modifiers *map[string][]query.Modifier)

Source from the content-addressed store, hash-verified

20
21// parseAttrs parses the list of attributes passed to the SELECT clause.
22func (p *parser) parseAttrs(attributes *[]string, modifiers *map[string][]query.Modifier) error {
23 for {
24 ident := p.expect(tokenizer.Identifier)
25 if ident == nil {
26 return p.currentError()
27 }
28
29 if ident.Raw == "*" || ident.Raw == "all" {
30 *attributes = allAttributes
31 } else {
32 p.current = ident
33
34 attrModifiers := make([]query.Modifier, 0)
35 attribute, err := p.parseAttr(&attrModifiers)
36 if err != nil {
37 return err
38 }
39 *attributes = append(*attributes, attribute.Raw)
40 (*modifiers)[attribute.Raw] = attrModifiers
41 }
42
43 if p.expect(tokenizer.Comma) == nil {
44 break
45 }
46 }
47 return nil
48}
49
50// parseAttr recursively parses an attribute's modifiers and returns the
51// associated attribute.

Calls 3

expectMethod · 0.95
currentErrorMethod · 0.95
parseAttrMethod · 0.95