Walter Bright , dans le message (digitalmars.D:174360), a écrit : > On 8/6/2012 12:00 PM, Philippe Sigaud wrote: >> Yes, well we don't have a condition system. And using exceptions >> during lexing would most probably kill its efficiency. >> Errors in lexing are not uncommon. The usual D idiom of having an enum >> StopOnError { no, yes } should be enough. > > > That's why I suggested supplying a callback delegate to decide what to do > with > errors (ignore, throw exception, or quit) and have the delegate itself do > that. > That way, there is no customization of the Lexer required.
It may be easier to take into accound few cases (return error token and throwing is enough, so that is a basic static if), than to define a way to integrate a delegate (what should be the delegate's signature, what value to return to query for stopping, how to provide ways to recovers, etc).