// ParseRDLFile parses the specified file to produce a Schema object.
514755
func ParseRDLFile(path string, verbose bool, pedantic bool, nowarn bool) (*Schema, error) {
	return parseRDLFile(path, nil, verbose, pedantic, nowarn)
}
1100487
func ParseFile(path string, unmarshal func([]byte, interface{}) error) (*Config, error) {
	bs, err := ioutil.ReadFile(path)
	if err != nil {
		return nil, err
	}

	conf := &Config{}
	if err := unmarshal(bs, conf); err != nil {
		return nil, err
	}

	if err := conf.Sanitize(); err != nil {
		return nil, err
	}
	return conf, nil
}
1295716
func (r *Rules) parseRule(rule string) error {
	rule = strings.TrimSpace(rule)

	// Ignore blank lines
	if rule == "" {
		return nil
	}
	// Comment
	if strings.HasPrefix(rule, "#") {
		return nil
	}

	// Fail any rules that contain **
	if strings.Contains(rule, "**") {
		return errors.New("double-star (**) syntax is not supported")
	}

	// Fail any patterns that can't compile. A non-empty string must be
	// given to Match() to avoid optimization that skips rule evaluation.
	if _, err := filepath.Match(rule, "abc"); err != nil {
		return err
	}

	p := &pattern{raw: rule}

	// Negation is handled at a higher level, so strip the leading ! from the
	// string.
	if strings.HasPrefix(rule, "!") {
		p.negate = true
		rule = rule[1:]
	}

	// Directory verification is handled by a higher level, so the trailing /
	// is removed from the rule. That way, a directory named "foo" matches,
	// even if the supplied string does not contain a literal slash character.
	if strings.HasSuffix(rule, "/") {
		p.mustDir = true
		rule = strings.TrimSuffix(rule, "/")
	}

	if strings.HasPrefix(rule, "/") {
		// Require path matches the root path.
		p.match = func(n string, fi os.FileInfo) bool {
			rule = strings.TrimPrefix(rule, "/")
			ok, err := filepath.Match(rule, n)
			if err != nil {
				log.Printf("Failed to compile %q: %s", rule, err)
				return false
			}
			return ok
		}
	} else if strings.Contains(rule, "/") {
		// require structural match.
		p.match = func(n string, fi os.FileInfo) bool {
			ok, err := filepath.Match(rule, n)
			if err != nil {
				log.Printf("Failed to compile %q: %s", rule, err)
				return false
			}
			return ok
		}
	} else {
		p.match = func(n string, fi os.FileInfo) bool {
			// When there is no slash in the pattern, we evaluate ONLY the
			// filename.
			n = filepath.Base(n)
			ok, err := filepath.Match(rule, n)
			if err != nil {
				log.Printf("Failed to compile %q: %s", rule, err)
				return false
			}
			return ok
		}
	}

	r.patterns = append(r.patterns, p)
	return nil
}
415793
func ParseFile(filePath string) (*Template, error) {
	b, err := ioutil.ReadFile(filePath)
	if err != nil {
		return nil, err
	}

	return Parse(string(b))
}
948612
func (ns *Namespace) ReadFile(i interface{}) (string, error) {
	s, err := cast.ToStringE(i)
	if err != nil {
		return "", err
	}

	return readFile(ns.readFileFs, s)
}
1317112
func ParseFile(filename string) (string, error) {
	bs, err := ioutil.ReadFile(filename)
	if err != nil {
		return "", err
	}
	return Parse(filepath.Base(filename), bs)
}
988999
func (i *IniParser) ParseFile(filename string) error {
	ini, err := readIniFromFile(filename)

	if err != nil {
		return err
	}

	return i.parse(ini)
}
887622
func ParseProcfile(b []byte) (Procfile, error) {
	p, err := parseStandardProcfile(b)
	if err != nil {
		p, err = parseExtendedProcfile(b)
	}
	return p, err
}
1012116
func ParseFile(f string) (*File, error) {
	fs := token.NewFileSet()
	if !strings.HasSuffix(f, ".go") {
		return nil, errors.New("Invalid file, file suffix not .go")
	}
	parsed, err := parser.ParseFile(fs, f, nil, parser.ParseComments)
	if err != nil {
		//log.Fatalf("parsing file: %s: %s", f, err)
		return nil, errors.New(fmt.Sprintf("go/parser.ParseFile error \"%v\"", err))
	}
	file := File{ast: parsed, pathName: f, fs: fs}
	file.Check()
	return &file, nil
}
1191760
func ParseReadFile(workDir, fileName string, root Root) ([]byte, error) {
	if strings.HasSuffix(fmt.Sprint(reflect.TypeOf(root)), "APIDefinition") { // when we parse for APIDefinition, we reset ramlFileDir
		ramlFileDir = workDir
	}

	// Read original file contents into a byte array
	mainFileBytes, err := readFileOrURL(workDir, fileName)

	if err != nil {
		return []byte{}, err
	}

	// Get the contents of the main file
	mainFileBuffer := bytes.NewBuffer(mainFileBytes)

	// Verify the YAML version
	var ramlVersion string
	firstLine, err := mainFileBuffer.ReadString('\n')
	if err != nil {
		return []byte{}, fmt.Errorf("Problem reading RAML file (Error: %s)", err.Error())
	}

	// We read some data...
	if len(firstLine) >= 10 {
		ramlVersion = firstLine[:10]
	}
	if ramlVersion != "#%RAML 1.0" {
		return []byte{}, errors.New("Input file is not a RAML 1.0 file. Make " +
			"sure the file starts with #%RAML 1.0")
	}

	// Pre-process the original file, following !include directive
	preprocessedContentsBytes, err :=
		preProcess(mainFileBuffer, workDir)

	if err != nil {
		return []byte{},
			fmt.Errorf("Error preprocessing RAML file (Error: %s)", err.Error())
	}

	if log.GetLevel() == log.DebugLevel {
		pretty.Println(string(preprocessedContentsBytes))
	}

	// Unmarshal into an APIDefinition value

	// Go!
	err = yaml.Unmarshal(preprocessedContentsBytes, root)

	// Any errors?
	if err != nil {

		// Create a RAML error value
		ramlError := new(Error)

		// Copy the YAML errors into it..
		if yamlErrors, ok := err.(*yaml.TypeError); ok {
			populateRAMLError(ramlError, yamlErrors)
		} else {
			// Or just any other error, though this shouldn't happen.
			ramlError.Errors = append(ramlError.Errors, err.Error())
		}

		return []byte{}, ramlError
	}

	if err := root.PostProcess(workDir, fileName); err != nil {
		return preprocessedContentsBytes, err
	}

	// Good.
	return preprocessedContentsBytes, nil
}
1072333
func ParseReader(filename string, r io.Reader, opts ...Option) (interface{}, error) {
	b, err := ioutil.ReadAll(r)
	if err != nil {
		return nil, err
	}

	return Parse(filename, b, opts...)
}
1312817
func (p *Parser) Parse() (*ast.File, error) {
	f := &ast.File{}
	var err, scerr error
	p.sc.Error = func(pos token.Pos, msg string) {
		scerr = fmt.Errorf("%s: %s", pos, msg)
	}

	// The root must be an object in JSON
	object, err := p.object()
	if scerr != nil {
		return nil, scerr
	}
	if err != nil {
		return nil, err
	}

	// We make our final node an object list so it is more HCL compatible
	f.Node = object.List

	// Flatten it, which finds patterns and turns them into more HCL-like
	// AST trees.
	flattenObjects(f.Node)

	return f, nil
}
1180259
func (mo *Mo) ParseFile(f string) {
	// Check if file exists
	info, err := os.Stat(f)
	if err != nil {
		return
	}

	// Check that isn't a directory
	if info.IsDir() {
		return
	}

	// Parse file content
	data, err := ioutil.ReadFile(f)
	if err != nil {
		return
	}

	mo.Parse(data)
}
217860
func Parse(name, filename string, r io.Reader) (*File, error) {
	// sanitize data first (ensure file ends with '\n')
	buf, err := fixEnding(r)
	if err != nil {
		return nil, err
	}

	// pass through ini/parser package
	f, err := parser.Parse(name, buf)
	if err != nil {
		return nil, &ParseError{name, parser.LastError()}
	}

	// convert to *parser.File
	inifile, ok := f.(*parser.File)
	if !ok {
		return nil, &ParseError{name, parser.LastError()}
	}

	return &File{
		File:     inifile,
		Filename: filename,
	}, nil
}
1003286
func (p *parser) parseFile() *File {
	var stmts []Stmt
	for p.tok != EOF {
		if p.tok == NEWLINE {
			p.nextToken()
			continue
		}
		stmts = p.parseStmt(stmts)
	}
	return &File{Stmts: stmts}
}
314327
func (dt *DbfTable) SaveFile(filename string) error {
	// don't forget to add dbase end of file marker which is 1Ah
	dt.dataStore = appendSlice(dt.dataStore, []byte{0x1A})
	f, err := os.Create(filename)
	if err != nil {
		return err
	}
	defer f.Close()

	_, err = f.Write(dt.dataStore)
	if err != nil {
		return err
	}
	return nil
}
180438
func (l *Ledis) DumpFile(path string) error {
	f, err := os.Create(path)
	if err != nil {
		return err
	}
	defer f.Close()

	return l.Dump(f)
}