@ -29,6 +29,7 @@ import (
"strings"
)
// Doc represents a Moon document.
type Doc struct {
items map[string]interface{}
}
@ -4,6 +4,7 @@ import (
"bytes"
"fmt"
"io"
"os"
@ -42,6 +43,16 @@ func ReadBytes(b []byte) (*Doc, error) {
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) {
p := &parser{
root: newRootNode(),