func ParseDeclList(fset *token.FileSet, filename string, src interface{}, scope *ast.Scope, pathToName ImportPathToName) ([]ast.Decl, error) {
	data, err := readSource(filename, src)
	if err != nil {
		return nil, err
	}
	var p parser
	p.init(fset, filename, data, 0, scope, pathToName)
	p.pkgScope = scope
	p.fileScope = scope
	return p.parseDeclList(), p.parseEOF()
}
ParseDeclList parses a list of Go declarations and returns the list
of corresponding AST nodes. The fset, filename, and src arguments have the same
interpretation as for ParseFile. If there is an error, the node
list may be nil or contain partial ASTs.

If scope is non-nil, it will be used for declarations.
package parser
import (
	"bytes"
	"errors"
	"io"
	"io/ioutil"
	"os"
	"path/filepath"
	"github.com/rogpeppe/godef/go/ast"
	"github.com/rogpeppe/godef/go/scanner"
	"github.com/rogpeppe/godef/go/token"
)
type ImportPathToName func(path string, fromDir string) (string, error)
func readSource(filename string, src interface{}) ([]byte, error) {
	if src != nil {
		switch s := src.(type) {
		case string:
			return []byte(s), nil
		case []byte:
			return s, nil
		case *bytes.Buffer:
			if s != nil {
				return s.Bytes(), nil
			}
		case io.Reader:
			var buf bytes.Buffer
			_, err := io.Copy(&buf, s)
			if err != nil {
				return nil, err
			}
			return buf.Bytes(), nil
		default:
			return nil, errors.New("invalid source")
		}
	}
	return ioutil.ReadFile(filename)
}
func (p *parser) parseEOF() error {
	p.expect(token.EOF)
	return p.GetError(scanner.Sorted)
}
func ParseExpr(fset *token.FileSet, filename string, src interface{}, scope *ast.Scope, pathToName ImportPathToName) (ast.Expr, error) {
	data, err := readSource(filename, src)
	if err != nil {
		return nil, err
	}
	var p parser
	p.init(fset, filename, data, 0, scope, pathToName)
	x := p.parseExpr()
	if p.tok == token.SEMICOLON {
		p.next()  
	}
	return x, p.parseEOF()
}
func ParseStmtList(fset *token.FileSet, filename string, src interface{}, scope *ast.Scope, pathToName ImportPathToName) ([]ast.Stmt, error) {
	data, err := readSource(filename, src)
	if err != nil {
		return nil, err
	}
	var p parser
	p.init(fset, filename, data, 0, scope, pathToName)
	return p.parseStmtList(), p.parseEOF()
}