View Source Cogito (Cogito v1.0.0)

A module that build parsers and parses a string.

Known parsers:

  • json
  • maths expressions

In progress:

  • nginx logs

But you can easily build your own.

Summary

Types

parser()

@type parser() :: (String.t() -> {:ok, any(), String.t()} | {:err, any()})

parser!()

@type parser!() :: (String.t() -> any() | Exception.t())

Functions

json_parser()

@spec json_parser() :: parser()

json_parser!()

@spec json_parser!() :: parser!()

maths_parser(vars \\ %{})

@spec maths_parser(map()) :: parser()

maths_parser!(vars \\ %{})

@spec maths_parser!(map()) :: parser!()

parse(parser, input)

@spec parse(parser() | parser!(), String.t()) :: any()