go-parsekit/statehandler_expects.go

19 lines
721 B
Go

package parsekit
// Expects is used to let a StateHandler function describe what input it is expecting.
// This expectation is used in error messages to make them more descriptive.
//
// When defining an expectation inside a StateHandler, you do not need to
// handle unexpected input yourself. When the end of the function is reached
// without setting the next state, an automatic error will be emitted.
// This error can differentiate between the following issues:
//
// 1) there is valid data on input, but it was not accepted by the function
//
// 2) there is an invalid UTF8 character on input
//
// 3) the end of the file was reached.
func (p *ParseAPI) Expects(description string) {
p.expecting = description
}