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

Method matchField

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

Source from the content-addressed store, hash-verified

324}
325
326func (p *Parser) matchField() (*ast.Field, error) {
327 l := p.lexer
328 name, ok, err := p.matchSymbol()
329 if err != nil {
330 return nil, err
331 }
332 if !ok {
333 return nil, nil
334 }
335 var opt bool
336 opt, err = l.match('?')
337 if err != nil {
338 return nil, err
339 }
340 ok, err = l.match(':')
341 if err != nil {
342 return nil, err
343 }
344 if !ok {
345 return nil, p.errorf("no type name found for field %q", name)
346 }
347 var val ast.Value
348 none, err := p.matchNone()
349 if err != nil {
350 return nil, err
351 }
352 if none != nil {
353 val = none
354 if !opt {
355 return nil, p.errorf("_ cannot appear in non-optional field %q", name)
356 }
357 } else {
358 val, err = p.ParseValue()
359 if err != nil {
360 return nil, err
361 }
362 }
363 return &ast.Field{
364 Name: name,
365 Value: val,
366 Opt: opt,
367 }, nil
368}
369
370func (p *Parser) matchSymbol() (string, bool, error) {
371 s, ok, err := p.matchString()

Callers 1

matchFieldsMethod · 0.95

Calls 5

matchSymbolMethod · 0.95
errorfMethod · 0.95
matchNoneMethod · 0.95
ParseValueMethod · 0.95
matchMethod · 0.45

Tested by

no test coverage detected