(first ast.Type)
| 318 | } |
| 319 | |
| 320 | func (p *Parser) matchTypeUnion(first ast.Type) (*ast.TypeUnion, error) { |
| 321 | l := p.lexer |
| 322 | var types []ast.Type |
| 323 | if first != nil { |
| 324 | types = append(types, first) |
| 325 | } |
| 326 | for { |
| 327 | typ, err := p.matchTypeComponent() |
| 328 | if err != nil { |
| 329 | return nil, err |
| 330 | } |
| 331 | if typ == nil { |
| 332 | break |
| 333 | } |
| 334 | types = append(types, typ) |
| 335 | ok, err := l.match('|') |
| 336 | if noEOF(err) != nil { |
| 337 | return nil, err |
| 338 | } |
| 339 | if !ok { |
| 340 | break |
| 341 | } |
| 342 | } |
| 343 | if len(types) < 2 { |
| 344 | if ok, _ := l.match(','); ok { |
| 345 | return nil, errors.New("union components are separated by pipe symbol (|) not comma") |
| 346 | } |
| 347 | return nil, errors.New("union type must include two or more types") |
| 348 | } |
| 349 | return &ast.TypeUnion{ |
| 350 | Kind: "TypeUnion", |
| 351 | Types: types, |
| 352 | }, nil |
| 353 | } |
| 354 | |
| 355 | func (p *Parser) matchTypeEnumBody() (*ast.TypeEnum, error) { |
| 356 | l := p.lexer |
no test coverage detected