- A parser combinator is a way to turn text into structured data, such as objects. It reads a long string by chaining small parsing functions in order.
- Each parser cuts off the front part of the string, returns a value, and passes the remaining string to the next parser. The source shows an example where a number parser returns 10 and the remainder ' 20 30' from '10 20 30'.
- The author presents an example of directly parsing ping command output sent to a Cloudflare server using TypeScript. According to the author, doing the same task with regular expressions becomes harder to read as nesting increases.
- The author says regular expressions get messy for complex tasks and considers tree-sitter, a large syntax parsing library used for syntax highlighting in code editors, to be excessive. The author argues this approach fits the middle ground. This is the author's opinion, and the source contains no performance measurement results.
O: This works as an example for an operations engineer who has to read command output with a fixed format per line, like ping output, in a script, and who builds a small parser by hand with pSeq and pMap.
X: The original example is tied to one specific ping output format, so if the output language or options change, several parts of the parser would need to be fixed. It also gives no evidence for execution speed, and that should be checked first.