anqiansong 4 years ago committed by GitHub
parent a5962f677f
commit d28ac35ff7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -18,6 +18,7 @@ type (
debug bool
log console.Console
antlr.DefaultErrorListener
src string
}
// ParserOption defines an function with argument Parser
@ -94,7 +95,8 @@ func (p *Parser) parse(filename, content string) (*Api, error) {
var apiAstList []*Api
apiAstList = append(apiAstList, root)
for _, imp := range root.Import {
path := imp.Value.Text()
dir := filepath.Dir(p.src)
path := filepath.Join(dir, imp.Value.Text())
data, err := p.readContent(path)
if err != nil {
return nil, err
@ -420,6 +422,7 @@ func (p *Parser) readContent(filename string) (string, error) {
return "", err
}
p.src = abs
data, err := ioutil.ReadFile(abs)
if err != nil {
return "", err

Loading…
Cancel
Save