Skip to content

anuragsoni/angstrom-examples

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Angstrom Examples

Examples of parsers written using Angstrom.

Build

  1. Install angstrom (opam install angstrom)
  2. dune build

Explore via repl

  1. dune utop src

Example list

  1. Hex color parser. Link.
  2. Bencode (.torrent file 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
    List and Dict contain 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 using fix from Angstrom. We define our parsers for List and Dict within the function passed to fix, which gives us access to a parser we can use to parse bencode values as a whole.

Releases

No releases published

Packages

No packages published

Languages