func bodyParserExt(env Env) p.Parser { return func(st p.ParseState) (interface{}, error) { value, err := p.Many(p.Bind(ValueParserExt(env), func(x interface{}) p.Parser { return p.Bind_(Skip, p.Return(x)) }))(st) return value, err } }
} else { return nil, err } }) var RuneParser = p.Bind( p.Between(p.Rune('\''), p.Rune('\''), p.Either(p.Try(EscapeCharr), p.NoneOf("'"))), func(x interface{}) p.Parser { return p.Return(Rune(x.(rune))) }, ) var StringParser = p.Bind( p.Between(p.Rune('"'), p.Rune('"'), p.Many(p.Either(p.Try(EscapeChars), p.NoneOf("\"")))), p.ReturnString) func bodyParser(st p.ParseState) (interface{}, error) { value, err := p.SepBy(ValueParser, p.Many1(Space))(st) return value, err } func bodyParserExt(env Env) p.Parser { return func(st p.ParseState) (interface{}, error) { value, err := p.Many(p.Bind(ValueParserExt(env), func(x interface{}) p.Parser { return p.Bind_(Skip, p.Return(x)) }))(st) return value, err } }
return nil, ParsexSignErrorf( "Many1 Arg Error:except 1 parser arg but %v.", reflect.TypeOf(param)) } }, "many": func(env Env, args ...interface{}) (Lisp, error) { if len(args) != 1 { return nil, ParsexSignErrorf("Parsec Parser Many Error: only accept one Parsec Parser as arg but %v", args) } param, err := Eval(env, args[0]) if err != nil { return nil, err } switch parser := param.(type) { case Parsecer: return ParsecBox(p.Many(parser.Parser)), nil default: return nil, ParsexSignErrorf( "Many Arg Error:except 1 parser arg but %v.", reflect.TypeOf(param)) } }, "failed": func(env Env, args ...interface{}) (Lisp, error) { if len(args) != 1 { return nil, ParsexSignErrorf("Parsec Parser Failed Error: only accept one string as arg but %v", args) } param, err := Eval(env, args[0]) if err != nil { return nil, err } var str string