Parser Combinator

by Rebecca Parsons

Create a top-down parser by a composition of parser objects.

Even though our premise is that Parser Generator are not nearly as difficult to work with as they are perceived to be, there are legitimate reasons to avoid them if possible. The most obvious issue is the additional steps in the build process required to first generate the parser and then build it. While Parser Generator are still the right choice for more complex context-free grammars, particularly if the grammar is ambiguous or performance is crucial, directly implementing a parser in a general-purpose language is a viable option.

A Parser Combinator implements a grammar using a structure of parser objects. Recognizers for the symbols in the production rules are combined using Composite , which are referred to as combinators. Effectively, parser combinators represent a Semantic Model of a grammar.

For more details see chapter 22 of the DSL book

| Catalog of DSL patterns |