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

Method matchSetOrMap

sup/parser-values.go:430–492  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

428}
429
430func (p *Parser) matchSetOrMap() (ast.Any, error) {
431 l := p.lexer
432 if ok, err := l.match('|'); !ok || err != nil {
433 return nil, noEOF(err)
434 }
435 isSet, err := l.matchTight('[')
436 if err != nil {
437 return nil, err
438 }
439 var val ast.Any
440 var which string
441 if isSet {
442 which = "set"
443 vals, err := p.matchValueList()
444 if err != nil {
445 return nil, err
446 }
447 ok, err := l.match(']')
448 if err != nil {
449 return nil, err
450 }
451 if !ok {
452 return nil, p.error("mismatched set value brackets")
453 }
454 val = &ast.Set{
455 Kind: "Set",
456 Elements: vals,
457 }
458 } else {
459 ok, err := l.matchTight('{')
460 if err != nil {
461 return nil, err
462 }
463 if !ok {
464 return nil, p.error("no '|[' or '|{' type bracket at '|' character")
465 }
466 which = "map"
467 entries, err := p.matchMapEntries()
468 if err != nil {
469 return nil, err
470 }
471 ok, err = l.match('}')
472 if err != nil {
473 return nil, err
474 }
475 if !ok {
476 return nil, p.error("mismatched map value brackets")
477 }
478 val = &ast.Map{
479 Kind: "Map",
480 Entries: entries,
481 }
482 }
483 ok, err := l.matchTight('|')
484 if err != nil {
485 return nil, err
486 }
487 if !ok {

Callers 1

matchValueMethod · 0.95

Calls 7

matchValueListMethod · 0.95
errorMethod · 0.95
matchMapEntriesMethod · 0.95
errorfMethod · 0.95
matchTightMethod · 0.80
noEOFFunction · 0.70
matchMethod · 0.45

Tested by

no test coverage detected