README.md

# Pelecanus

Pelecanus is simple parser combinator for elixir.

## Usage
In Pelecanus, parsers are just (anonymous) pure function
`(state -> {:ok, state, value} | {:ok, state} | {:error, reason})`.
Useful functions that return parser are provided.

```elixir
use Pelecanus, sigil_p: true

# create parser state
init = %State{str: "pelican come!"}

# Terminal Symbols can be written almost regex
parser = ~p(\w+)
{:ok, _state, matched} = parser.(init)

# PEG like operators can be used
parser = sequence [~p(\w+), ~p( ), ~p(\w+), option ~p(!)]
{:ok, _state, list} = parser.(init)
```

You can simply define custom parser;

```elixir
int =
  fn state -> 
    with {:ok, s, v} <- ~p(\d+).(state),
         do: {:ok, s, String.to_integer v}
  end

{:ok, _state, 1758} = int.(%State{str: "1758"})
```

passing state contain context field.
You can use this as you like.

## Installation
Pelecanus can be installed
by adding `pelecanus` to your list of dependencies in `mix.exs`:

```elixir
def deps do
  [
    {:pelecanus, "~> 0.4"}
  ]
end
```

Documentation is: [https://hexdocs.pm/pelecanus](https://hexdocs.pm/pelecanus).