ExParsec
A parser combinator library inspired by Parsec.
Usage
Add ExParsec as a dependency in your mix.exs file:
def deps do
[ {:ex_parsec, "~> 0.0.0"} ]
end
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
nil
iex> ExParsec.parse_string "foo", many(any_char())
{:ok, nil, ["f", "o", "o"]}
iex> ExParsec.parse_string "[x]", between(char("["), char("x"), char("]"))
{:ok, nil, "x"}
iex> ExParsec.parse_string " spa ces ",
sequence([skip_many(space),
times(any_char(), 3),
skip(space),
times(any_char(), 3),
skip_many(space),
eof])
{:ok, nil, [nil, ["s", "p", "a"], nil, ["c", "e", "s"], nil, nil]}Features
- Can parse context-sensitive grammars.
- High-quality error messages readable by humans.
- Full UTF-8 string support.
- Non-text input can be parsed (e.g. tokens).
- Support for theoretically infinitely large files.
- Simple, extensible API surface.