A parser combinator library inspired by Parsec.
Elixir
Permalink
Failed to load latest commit information.
bench Add some foundations for using Benchfella. Aug 24, 2014
lib Fix position backtracking in `FileInput`. Aug 28, 2014
test Fix a test warning. Aug 26, 2014
.gitignore Add some foundations for using Benchfella. Aug 24, 2014
.travis.yml Update .travis.yml. Aug 17, 2014
LICENSE Initial source check-in. Aug 16, 2014
README.md Add Hex badges to README.md. Aug 19, 2014
docs.exs Code style in the docs script. Aug 22, 2014
mix.exs Add a `wipe` alias to clean the workspace. Aug 26, 2014
mix.lock

README.md

ExParsec

Build Status Hex Version Hex Downloads

A parser combinator library inspired by Parsec.

Usage

Add ExParsec as a dependency in your mix.exs file:

def deps do
  [ {:ex_parsec, "~> x.y.z"} ]
end

Replace x.y.z with whatever released version you would like to depend on.

After you are done, run mix deps.get in your shell to fetch and compile ExParsec. Start an interactive Elixir shell with iex -S mix.

iex> import ExParsec.Base; import ExParsec.Text
nil
iex> ExParsec.parse_value "foo", many(any_char())
{:ok, nil, ["f", "o", "o"]}
iex> ExParsec.parse_value "[x]", between(char("["), char("x"), char("]"))
{:ok, nil, "x"}
iex> ExParsec.parse_value "  spa ces  ",
                          sequence([skip(spaces),
                                    times(any_char(), 3),
                                    skip(space),
                                    times(any_char(), 3),
                                    skip(spaces),
                                    eof])
{:ok, nil, [nil, ["s", "p", "a"], nil, ["c", "e", "s"], nil, nil]}

Features

  • Can parse context-sensitive grammars.
  • High-quality, customizable error messages.
  • Full UTF-8 string support.
  • Non-text input such as binary data and tokens.
  • Support for theoretically infinitely large files.
  • Monadic parse blocks based on Elixir macros.
  • Simple, extensible API surface.

Examples