master
Jordan Orelli 10 years ago
parent 82ecd83bee
commit 5fa482c1d0

@ -29,6 +29,7 @@ import (
"strings" "strings"
) )
// Doc represents a Moon document.
type Doc struct { type Doc struct {
items map[string]interface{} items map[string]interface{}
} }

@ -4,6 +4,7 @@ import (
"bytes" "bytes"
"fmt" "fmt"
"io" "io"
"os"
"strings" "strings"
) )
@ -42,6 +43,16 @@ func ReadBytes(b []byte) (*Doc, error) {
return Read(bytes.NewBuffer(b)) return Read(bytes.NewBuffer(b))
} }
func ReadFile(path string) (*Doc, error) {
f, err := os.Open(path)
if err != nil {
return nil, err
}
defer f.Close()
return Read(f)
}
func parse(r io.Reader) (node, error) { func parse(r io.Reader) (node, error) {
p := &parser{ p := &parser{
root: newRootNode(), root: newRootNode(),

Loading…
Cancel
Save