Jacob Carlborg , dans le message (digitalmars.D:174421), a écrit : > On 2012-08-07 12:06, Jonathan M Davis wrote: > >> It's easier to see where in the range of tokens the errors occur. A delegate >> is disconnected from the point where the range is being consumed, whereas if >> tokens are used for errors, then the function consuming the range can see >> exactly where in the range of tokens the error is (and potentially handle it >> differently based on that information). > > Just pass the same token to the delegate that you would have returned > otherwise?
That's what I would do. If you have to define a way to return error information as a token, better use it again when using delegates. Personnaly, I would have the delegate be: int delegate(Token); A return value of 0 means: continue parsing. Any other value is an error number and stops the parser (makes it empty). The error number can be retrieved from the empty parser with a specific function. If you want to throw, just throw in the delegate. No need to return a specific value for that. But a bool return value may be enough too...