| 130 | } |
| 131 | |
| 132 | func (p *Processor) parse(path file.Path) (*ast.API, parse.ErrorList) { |
| 133 | path = p.Loader.Find(path) |
| 134 | absname := path.System() |
| 135 | p.parsedLock.Lock() |
| 136 | res, ok := p.Parsed[absname] |
| 137 | p.parsedLock.Unlock() |
| 138 | if ok { |
| 139 | return res.API, res.Errs |
| 140 | } |
| 141 | info, err := p.Loader.Load(path) |
| 142 | if err != nil { |
| 143 | return nil, parse.ErrorList{parse.Error{Message: err.Error()}} |
| 144 | } |
| 145 | api, errs := parser.Parse(absname, string(info), &p.Mappings.AST) |
| 146 | p.parsedLock.Lock() |
| 147 | p.Parsed[absname] = ParseResult{api, errs} |
| 148 | p.parsedLock.Unlock() |
| 149 | return api, errs |
| 150 | } |
| 151 | |
| 152 | // Resolve resolves the api file with a default Processor. |
| 153 | // See Processor.Resolve for details. |