func ExampleBind() { var r interface{} var ok bool prt := func() { if ok { fmt.Printf("Result: %s\n", r) } else { fmt.Printf("Error: %v\n", r) } } lower := kern.Regexp(`\p{Ll}`) intNum := kern.Regexp(`\p{Nd}*`) p := kern.Bind(lower, func(c interface{}) kern.Parser { return kern.Bind(intNum, func(d interface{}) kern.Parser { return kern.Bind(lower, func(e interface{}) kern.Parser { return kern.Return(utf88.Surr(c.(utf88.Text)) + "," + utf88.Surr(d.(utf88.Text)) + "," + utf88.Surr(e.(utf88.Text))) }) }) }) t := utf88.Text("e789fg") r, ok = kern.ParseText(p, t) prt() // Output: // Result: e,789,f }
func ExampleReturn() { p := kern.Return(1234567890) t := utf88.Text("anything") r, ok := kern.ParseText(p, t) if ok { fmt.Printf("Result: %v\n", r) } else { fmt.Printf("Error: %v\n", r) } // Output: // Result: 1234567890 }