parseSourceList parses the list of directories passed to the FROM clause. If a source is followed by the AS keyword, the following word is registered as an alias.
(sources *map[string][]string, aliases *map[string]string)
| 11 | // a source is followed by the AS keyword, the following word is registered as |
| 12 | // an alias. |
| 13 | func (p *parser) parseSourceList(sources *map[string][]string, |
| 14 | aliases *map[string]string) error { |
| 15 | for { |
| 16 | // If the next token is a hypen, exclude this directory. |
| 17 | sourceType := "include" |
| 18 | if token := p.expect(tokenizer.Hyphen); token != nil { |
| 19 | sourceType = "exclude" |
| 20 | } |
| 21 | |
| 22 | source := p.expect(tokenizer.Identifier) |
| 23 | if source == nil { |
| 24 | return p.currentError() |
| 25 | } |
| 26 | source.Raw = filepath.Clean(source.Raw) |
| 27 | (*sources)[sourceType] = append((*sources)[sourceType], source.Raw) |
| 28 | |
| 29 | if token := p.expect(tokenizer.As); token != nil { |
| 30 | alias := p.expect(tokenizer.Identifier) |
| 31 | if alias == nil { |
| 32 | return p.currentError() |
| 33 | } |
| 34 | if sourceType == "exclude" { |
| 35 | return fmt.Errorf("cannot alias excluded directory %s", source.Raw) |
| 36 | } |
| 37 | (*aliases)[alias.Raw] = source.Raw |
| 38 | } |
| 39 | |
| 40 | if p.expect(tokenizer.Comma) == nil { |
| 41 | break |
| 42 | } |
| 43 | } |
| 44 | return nil |
| 45 | } |