3 ms·
The article mentions that doing it better would require lots of nonstandard extensions, but not that it's struggling in the first place because it's the wrong t
by silentbicycle 16y ago
The article mentions that doing it better would require lots of nonstandard extensions, but not that it's struggling in the first place because it's the wrong tool for the job. If more developers realized the limitations of using just REs for these tasks, languages would be better integrated with actual parsing tools.
I think that tools like LPEG (http://www.inf.puc-rio.br/~roberto/lpeg/lpeg.html http://www.inf.puc-rio.br/~roberto/lpeg/lpeg.html) are a step in the right direction - it's a small Lua library* which provides a PEG-based parsing library. It's very powerful, but also scales down to use as a more efficient, more expressive PCRE replacement. There are various trade-offs in using PEGs rather than LALR(1), LL(1), etc., but the integration with the rest of the language is very good. It feels like using a better form of REs, rather than "adding a bunch of parsing machinery".
* Though nothing about its design is Lua-specific. There's a paper which explains its underlying mechanism, and it's just a small C library (2258 loc for v. 0.9) - porting it wouldn't be that difficult.
I agree with you about an actual markdown grammar, though it's useful enough that I have a hard time complaining. (I particularly like Discount (http://www.pell.portland.or.us/~orc/Code/discount/ http://www.pell.portland.or.us/~orc/Code/discount/).)