Overview
Parser combinators represent grammar pieces as functions that can be sequenced, alternated, repeated, and transformed directly in code.
Builds parsers by composing small parser functions into larger grammar rules.
Compact metadata for implementation and discovery.
Parser combinators represent grammar pieces as functions that can be sequenced, alternated, repeated, and transformed directly in code.
Quick facts
Runtime and memory behavior at a glance.
Best
O(n)
Average
O(n * rules)
Worst
O(exponential)
Space
O(parse state)
parse(A then B) = parse(B, parse(A, input).rest)Runs the second parser on the remaining input from the first parser.
Show grammar items, parser states, and consumed input as parsing progresses.
Parser Combinators should be used with the assumptions and tradeoffs of composable Parsing in mind.
What each reference supports for this entry.
Parsing reference for Parser Combinators's control flow, grammar assumptions, and parser construction tradeoffs.
Open sourceSpecific reference for parser combinators as first-class parsers with sequencing, choice, repetition, and monadic composition.
Open sourceGood next jumps from the relationship graph, ranked for useful discovery.
Parser combinators and recursive descent both build parsers directly from grammar-like structure.