Created by: bopjesvla
Takes a syntax type or grammar production, a value and an error callback. All arguments are optional, although the type is necessary to check the value. Returns the next syntax object.
Passes a SyntaxError to the callback if the type or value doesn't match, a TypeError if the syntax type doesn't exist, and a ReferenceError* if the end of the context is reached. If no callback is given, errors are thrown.
* a SyntaxError might make more sense, but this keeps error handling simple
This could also be implemented as an extension of the "next" method.