talira

NimbleParsec

A simple and fast library for text-based parser combinators

open sourceApache-2.0free

NimbleParsec is an Elixir library for text-based parser combinators. Combinators are composed as ordinary functions and compiled by defparsec into function clauses with binary matching, so the generated parsers are fast, use little memory and have no runtime dependency on NimbleParsec itself, which lets a library ship a parser without adding a dependency for its users. It focuses on a small set of efficient primitives to build higher-level combinators from; low-level binary parsing is left to Elixir's bitstring syntax. Made by Dashbit under Apache-2.0.

Problems it solves

  • write a fast parser for a text format in Elixir
  • parse a date or a small language in Elixir without regular expressions
  • ship a parser in my Elixir library without adding a runtime dependency

Features

  • parser combinators composed as plain functions, without macros
  • compiles parsers into binary-matching function clauses
  • no runtime dependency on NimbleParsec in the generated code
  • defparsec and defparsecp to emit public or private parsers
  • primitives for building higher-level combinators

Alternatives

The same job

These do what NimbleParsec does.

  1. nom A Rust parser combinator library for fast, safe binary and text parsers
  2. peg Packrat parser generator for Go from Parsing Expression Grammars

Compare NimbleParsec with the top 3