Examples of parsers written using Angstrom.
- Install
angstrom(opam install angstrom) dune build
dune utop src
- Hex color parser. Link.
- Bencode (
.torrentfile format) parser. Link. We use the following type for representing bencode:type t = | Integer of int | String of string | List of t list | Dict of (string * t) list
ListandDictcontain values that are themselves bencode values, so we need a parser that will accept bencode list and dictionary but we don't yet have access to a parser for bencode values as a whole. We get around the issue by usingfixfromAngstrom. We define our parsers forListandDictwithin the function passed tofix, which gives us access to a parser we can use to parse bencode values as a whole.