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...)
}
ParseReader parses the data from r using filename as information in the
error messages.
package runeerror
import (
	"bytes"
	"errors"
	"fmt"
	"io"
	"io/ioutil"
	"math"
	"os"
	"sort"
	"strconv"
	"strings"
	"sync"
	"unicode"
	"unicode/utf8"
)
func joinBytes(a interface{}) []byte {
	var A []byte
	for _, x := range a.([]interface{}) {
		A = append(A, x.([]uint8)...)
	}
	return A
}
var g = &grammar{
	rules: []*rule{
		{
			name: "Program",
			pos:  position{line: 13, col: 1, offset: 213},
			expr: &actionExpr{
				pos: position{line: 13, col: 12, offset: 224},
				run: (*parser).callonProgram1,
				expr: &seqExpr{
					pos: position{line: 13, col: 12, offset: 224},
					exprs: []interface{}{
						&litMatcher{
							pos:        position{line: 13, col: 12, offset: 224},
							val:        "\n",
							ignoreCase: false,
							want:       "\"\\n\"",
						},
						&labeledExpr{
							pos:   position{line: 13, col: 17, offset: 229},
							label: "a",
							expr: &oneOrMoreExpr{
								pos: position{line: 13, col: 19, offset: 231},
								expr: &charClassMatcher{
									pos:        position{line: 13, col: 19, offset: 231},
									val:        "[^\\n]",
									chars:      []rune{'\n'},
									ignoreCase: false,
									inverted:   true,
								},
							},
						},
						&litMatcher{
							pos:        position{line: 13, col: 26, offset: 238},
							val:        "\n",
							ignoreCase: false,
							want:       "\"\\n\"",
						},
						&labeledExpr{
							pos:   position{line: 13, col: 31, offset: 243},
							label: "b",
							expr: &anyMatcher{
								line: 13, col: 33, offset: 245,
							},
						},
						&notExpr{
							pos: position{line: 13, col: 35, offset: 247},
							expr: &anyMatcher{
								line: 13, col: 36, offset: 248,
							},
						},
					},
				},
			},
		},
	},
}
func (c *current) onProgram1(a, b interface{}) (interface{}, error) {
	return [][]byte{
		c.text, joinBytes(a), b.([]uint8),
	}, nil
}
func (p *parser) callonProgram1() (interface{}, error) {
	stack := p.vstack[len(p.vstack)-1]
	_ = stack
	return p.cur.onProgram1(stack["a"], stack["b"])
}
var (
	errNoRule = errors.New("grammar has no rule")
	errInvalidEntrypoint = errors.New("invalid entrypoint")
	errInvalidEncoding = errors.New("invalid encoding")
	errMaxExprCnt = errors.New("max number of expresssions parsed")
)
type Option func(*parser) Option
func MaxExpressions(maxExprCnt uint64) Option {
	return func(p *parser) Option {
		oldMaxExprCnt := p.maxExprCnt
		p.maxExprCnt = maxExprCnt
		return MaxExpressions(oldMaxExprCnt)
	}
}
func Entrypoint(ruleName string) Option {
	return func(p *parser) Option {
		oldEntrypoint := p.entrypoint
		p.entrypoint = ruleName
		if ruleName == "" {
			p.entrypoint = g.rules[0].name
		}
		return Entrypoint(oldEntrypoint)
	}
}
func Statistics(stats *Stats, choiceNoMatch string) Option {
	return func(p *parser) Option {
		oldStats := p.Stats
		p.Stats = stats
		oldChoiceNoMatch := p.choiceNoMatch
		p.choiceNoMatch = choiceNoMatch
		if p.Stats.ChoiceAltCnt == nil {
			p.Stats.ChoiceAltCnt = make(map[string]map[string]int)
		}
		return Statistics(oldStats, oldChoiceNoMatch)
	}
}
func Debug(b bool) Option {
	return func(p *parser) Option {
		old := p.debug
		p.debug = b
		return Debug(old)
	}
}
func Memoize(b bool) Option {
	return func(p *parser) Option {
		old := p.memoize
		p.memoize = b
		return Memoize(old)
	}
}
func AllowInvalidUTF8(b bool) Option {
	return func(p *parser) Option {
		old := p.allowInvalidUTF8
		p.allowInvalidUTF8 = b
		return AllowInvalidUTF8(old)
	}
}
func Recover(b bool) Option {
	return func(p *parser) Option {
		old := p.recover
		p.recover = b
		return Recover(old)
	}
}
func GlobalStore(key string, value interface{}) Option {
	return func(p *parser) Option {
		old := p.cur.globalStore[key]
		p.cur.globalStore[key] = value
		return GlobalStore(key, old)
	}
}
func InitState(key string, value interface{}) Option {
	return func(p *parser) Option {
		old := p.cur.state[key]
		p.cur.state[key] = value
		return InitState(key, old)
	}
}
func ParseFile(filename string, opts ...Option) (i interface{}, err error) {  
	f, err := os.Open(filename)
	if err != nil {
		return nil, err
	}
	defer func() {
		if closeErr := f.Close(); closeErr != nil {
			err = closeErr
		}
	}()
	return ParseReader(filename, f, opts...)
}