Nom is a powerful parser/combinator library written in Rust for binary and text streams. Its applications are similar to that of regular expressions, but Nom offers better performance, type safety, and error handling. This tutorial supplements the official documentation for the newly-released version 5 of the library.
Nom's official documentation includes trivially simple examples (e.g. how to parse a hexadecimal RGB color code) and very complicated examples (e.g. how to parse json). When I first learned nom I found a steep learning curve in between the simple and complex examples. Furthermore, versions of nom prior to 5 (along with most of the existing documentation) make heavy use macros. From nom 5.0 onward macros are soft-deprecated in favor of functions. This tutorial aims to fill the gap between simple and complex parsers by parsing the contents of
/proc/mounts, and it demonstrates the use of functions instead of macros.