forked from go-llvm/llgo
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparser.go
More file actions
29 lines (25 loc) · 714 Bytes
/
parser.go
File metadata and controls
29 lines (25 loc) · 714 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// Copyright 2013 The llgo Authors.
// Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file.
package llgo
import (
"fmt"
"go/ast"
"go/parser"
"go/token"
)
func parseFile(fset *token.FileSet, filename string) (*ast.File, error) {
mode := parser.DeclarationErrors | parser.ParseComments
return parser.ParseFile(fset, filename, nil, mode)
}
func parseFiles(fset *token.FileSet, filenames []string) ([]*ast.File, error) {
files := make([]*ast.File, len(filenames))
for i, filename := range filenames {
file, err := parseFile(fset, filename)
if err != nil {
return nil, fmt.Errorf("%q: %v", filename, err)
}
files[i] = file
}
return files, nil
}