2 ms·
> GCC's experience of moving toward a hand-written C++ parser was very positive. Fom what I see here, the measured improvement was 1.5% -- http://gcc.gnu.org/w
by haberman 13y ago
> GCC's experience of moving toward a hand-written C++ parser was very positive.
Fom what I see here, the measured improvement was 1.5% -- http://gcc.gnu.org/wiki/New_C_Parser http://gcc.gnu.org/wiki/New_C_Parser
> I don't believe hand-written parsers have an inherent speed advantage, but it does seems that it'd always be easier for a hand-written parser to produce more informative error messages
From what I can see, this is the major shortcoming of parser tools at the moment. I haven't looked into this problem too deeply yet, but at the moment I suspect that it isn't possible to get good enough error messages automatically.
But to me this doesn't mean "parsing tools will never have good error messages", it means "parsing tools need to evolve to give users the right hooks to produce good error messages themselves."
This would let the algorithms do the part that they do well (analyzing the grammar and creating state machines) while letting the human do the part that can't be done automatically (creating good error messages).
- quotemstr 13y agoSure, things might change. I'd be happy with better error messages from automatically-built parsers. There's a lot of potential, I think, in methods that take advantage of having a formal description of the language grammar --- you could, for example, automatically generate a sentence that "fits in" at the point at which an error occurs. There's still a lot of progress to be made in the area, though, and for now, hand-generated error messages do seem to be more useful to people.
- sanxiyn 13y agoGetting good error messages from the parser generator is a solved problem, but it seems that solution is not widely known. As you said, it isn't possible to get good error messages automatically. The solution is to include error cases in the grammar. No hooking is necessary. If people often miss semicolons, include missing semicolon case in the grammar! Mono C# compiler uses this technique (including error cases in the grammar) to the great effect. I wonder why people don't do that and resort to hand-written parsers instead.
- mattfenwick 13y agoExcellent, this -- information on other people's strategies for generating good error messages -- is exactly what I've been looking for. Could you direct me to more resources/papers/tools that describe and apply this approach in practice? Thanks!