Companion factory for creating new parser instances.
Builds a new parser based on the specified function that implements the behaviour of the parser.