Esempio n. 1
0
File: math.go Progetto: zy02636/gisp
func xEof(x interface{}) px.Parser {
	return px.Bind_(px.Eof, px.Return(x))
}
Esempio n. 2
0
					parsers[idx] = parser.Parser
				}
				return nil, ParsexSignErrorf("Choice Args Error:except parsec parsers but %v is %v",
					prs, reflect.TypeOf(prs))
			}
			return ParsexBox(px.Choice(parsers...)), nil
		},
		"return": func(env Env, args ...interface{}) (Lisp, error) {
			if len(args) != 1 {
				return nil, ParsexSignErrorf("Parsex Parser Return Error: only accept one parsex parser as arg but %v", args)
			}
			param, err := Eval(env, args[0])
			if err != nil {
				return nil, err
			}
			return ParsexBox(px.Return(param)), nil
		},
		"option": func(env Env, args ...interface{}) (Lisp, error) {
			if len(args) != 2 {
				return nil, ParsexSignErrorf("Parsex Parser Option Error: only accept two parsex parser as arg but %v", args)
			}
			data, err := Eval(env, args[0])
			if err != nil {
				return nil, err
			}
			param, err := Eval(env, args[1])
			if err != nil {
				return nil, err
			}
			switch parser := param.(type) {
			case Parsexer: