go-parsekit/tokenize/tokenize.go

21 lines
343 B
Go

package tokenize
import (
"fmt"
)
type Func func(input interface{}) (*Result, error)
func New(tokenHandler Handler) Func {
return func(input interface{}) (*Result, error) {
api := NewAPI(input)
ok := tokenHandler(api)
if !ok {
err := fmt.Errorf("mismatch at %s", Cursor{})
return nil, err
}
return api.Result(), nil
}
}