Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/alexrp/ex_parsec
A parser combinator library inspired by Parsec.
https://github.com/alexrp/ex_parsec
elixir erlang parsing
Last synced: 14 days ago
JSON representation
A parser combinator library inspired by Parsec.
- Host: GitHub
- URL: https://github.com/alexrp/ex_parsec
- Owner: alexrp
- License: mit
- Archived: true
- Created: 2014-08-16T10:12:29.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2015-08-04T20:46:54.000Z (over 9 years ago)
- Last Synced: 2024-10-02T02:04:42.529Z (about 1 month ago)
- Topics: elixir, erlang, parsing
- Language: Elixir
- Homepage: https://hex.pm/packages/ex_parsec
- Size: 563 KB
- Stars: 30
- Watchers: 3
- Forks: 1
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-combinator-parsers - ex_parsec
README
# ExParsec
[![Build Status](https://travis-ci.org/alexrp/ex_parsec.png?branch=master)](https://travis-ci.org/alexrp/ex_parsec)
[![Hex Version](https://img.shields.io/hexpm/v/ex_parsec.svg)](https://hex.pm/packages/ex_parsec)
[![Hex Downloads](https://img.shields.io/hexpm/dt/ex_parsec.svg)](https://hex.pm/packages/ex_parsec)A parser combinator library inspired by Parsec.
## Usage
Add ExParsec as a dependency in your `mix.exs` file:
```elixir
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
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