O'Reilly logo

Mastering Rust by Vesa Kaihlavirta

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chomp

Another parser combinator library is Chomp. It differs from nom by being designed around the monad pattern, which makes it a bit more concise and simple than nom but also slightly less efficient and powerful.

Being based on the monad pattern simply means that the parsers are built up by sequencing parsers with optional binding of return values and possibly returning early in the case of a parsing failure. This pattern enables flexible composition of functions, which in the case of Chomp are parsers. More in-depth understanding of monads is not required to use Chomp; the following examples should make it all clear.

Chomp parsers take custom input values (that fulfill the Input trait) and return custom output structs (ParseResult or ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required