Re:A Peek at Emacs 24
by drdaeman on Sunday September 11, 2011 @11:35AM
(#2983944)
Does GNU Emacs have standardized (out-of-the-box) parser generating facilities, or every package still has to hack their own?
[ Parent
| on HN ]
But keep in mind that parsers are designed to parse well-formed documents, not to parse non-well-formed documents pretending that they are well-formed. When you are typing in code, you are often in an invalid state that a formal grammar would reject. Hence, syntax highlighters try to guess what a piece of text is in based on as little state (previous lines of the document) as possible. Yes, you lose absolute accuracy, but the heuristics get a lot right, run extremely quickly, and are tolerant of errors.
As an example, nobody has a formal grammar that will parse Perl 5, but cperl-mode highlights (and indents, etc.) almost everything you throw at it correctly. In fact, I can't think of anything that doesn't highlight correctly!
(Also, CEDET is in core now, and it has a library for writing parsers. Never seems to work for me, though.)