# 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.

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;

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

{: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`:

def deps do
    {:pelecanus, "~> 0.4"}

Documentation is: [](