Example #1
0
func bodyParser(st p.ParseState) (interface{}, error) {
	value, err := p.SepBy(ValueParser, p.Many1(Space))(st)
	return value, err
}
Example #2
0
		},
		"sepby1": func(env Env, args ...interface{}) (Lisp, error) {
			ptype := reflect.TypeOf((*Parsecer)(nil)).Elem()
			params, err := GetArgs(env, px.UnionAll(TypeAs(ptype), TypeAs(ptype), px.Eof), args)
			if err != nil {
				return nil, err
			}
			return ParsecBox(p.SepBy1(params[0].(Parsecer).Parser, params[1].(Parsecer).Parser)), nil
		},
		"sepby": func(env Env, args ...interface{}) (Lisp, error) {
			ptype := reflect.TypeOf((*Parsecer)(nil)).Elem()
			params, err := GetArgs(env, px.UnionAll(TypeAs(ptype), TypeAs(ptype), px.Eof), args)
			if err != nil {
				return nil, err
			}
			return ParsecBox(p.SepBy(params[0].(Parsecer).Parser, params[1].(Parsecer).Parser)), nil
		},
		"manytil": func(env Env, args ...interface{}) (Lisp, error) {
			ptype := reflect.TypeOf((*Parsecer)(nil)).Elem()
			params, err := GetArgs(env, px.UnionAll(TypeAs(ptype), TypeAs(ptype), px.Eof), args)
			if err != nil {
				return nil, err
			}
			return ParsecBox(p.ManyTil(params[0].(Parsecer).Parser, params[1].(Parsecer).Parser)), nil
		},
		"maybe": func(env Env, args ...interface{}) (Lisp, error) {
			if len(args) != 1 {
				return nil, ParsexSignErrorf("Parsec Parser Maybe Error: only accept one parsec parser as arg but %v", args)
			}
			param, err := Eval(env, args[0])
			if err != nil {