Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

The author is more than welcome to write the equivalent code themself, which is probably going to be more unreadable (if they derive the automaton themself) or much slower (if they are doing redundant tests or pre-processing that the automaton could have saved them from). Regular expressions are also more amenable to static analysis in both linting and optimisation than equivalent code, being more declarative in nature; a regex and an imperative matcher have a relationship like SQL and the query plan generated by a database.


Actually, I feel that the parsec syntax in Haskell, for example, is much more readable - using many, noneOf etc.

The chapter of the book "Real World Haskell" builds a simple CSV parser:

https://book.realworldhaskell.org/read/using-parsec.html

It may be adaptable for regex and for static analysis as well.


Parser combinators are one of those rare REALLY great things that almost entirely replace something else (regex). Sadly, way too verbose in many languages.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: