Answers
Here are the answers to this chapter’s questions:
- Parsing is the act of turning a, usually human-readable, structured text into a data structure that can be easily processed in software.
- Parser combinators are an embedded DSL for parsing. They define parsers in a compositional way, assembling primitive parsers into larger ones.
- Parser combinators have several advantages:
- They are more convenient to write than hand-rolling your own parser
- As an embedded DSL, they are easily integrated into a code base and do not hamper the development process
- They do not require learning a new language and have a low threshold for entry
- Monad parsers are very flexible and expressive; the parsing behavior can be determined dynamically
- Parser combinators also have several disadvantages compared to parser generators:
- Their performance is usually not as good as that of parser generators and can be pathologically bad if we aren’t careful (for example, in the case of left...