MCPcopy Create free account
hub / github.com/brimdata/super / matchTypeSetOrMap

Method matchTypeSetOrMap

sup/parser-types.go:195–253  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

193}
194
195func (p *Parser) matchTypeSetOrMap() (ast.Type, error) {
196 l := p.lexer
197 if ok, err := l.match('|'); !ok || err != nil {
198 return nil, err
199 }
200 isSet, err := l.matchTight('[')
201 if err != nil {
202 return nil, err
203 }
204 var typ ast.Type
205 var which string
206 if isSet {
207 which = "set"
208 inner, err := p.parseType()
209 if err != nil {
210 return nil, err
211 }
212 ok, err := l.match(']')
213 if err != nil {
214 return nil, err
215 }
216 if !ok {
217 return nil, p.error("mismatched set-brackets while parsing set type")
218 }
219 typ = &ast.TypeSet{
220 Kind: "TypeSet",
221 Type: inner,
222 }
223 } else {
224 ok, err := l.matchTight('{')
225 if err != nil {
226 return nil, err
227 }
228 if !ok {
229 return nil, p.error("no '|[' or '|{' type token at '|' character")
230 }
231 which = "map"
232 typ, err = p.parseTypeMap()
233 if err != nil {
234 return nil, err
235 }
236 ok, err = l.match('}')
237 if err != nil {
238 return nil, err
239 }
240 if !ok {
241 return nil, p.error("mismatched set-brackets while parsing map type")
242 }
243 }
244 ok, err := l.matchTight('|')
245 if err != nil {
246 return nil, err
247 }
248 if !ok {
249 return nil, p.errorf("mismatched closing bracket while parsing type %q", which)
250 }
251 return typ, nil
252

Callers 1

matchTypeComponentMethod · 0.95

Calls 6

parseTypeMethod · 0.95
errorMethod · 0.95
parseTypeMapMethod · 0.95
errorfMethod · 0.95
matchTightMethod · 0.80
matchMethod · 0.45

Tested by

no test coverage detected