Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jtmoulia/neotomex
A PEG parser/transformer with a pleasant Elixir DSL.
https://github.com/jtmoulia/neotomex
Last synced: about 1 month ago
JSON representation
A PEG parser/transformer with a pleasant Elixir DSL.
- Host: GitHub
- URL: https://github.com/jtmoulia/neotomex
- Owner: jtmoulia
- License: bsd-3-clause
- Created: 2014-07-17T06:52:16.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2021-11-01T17:03:51.000Z (about 3 years ago)
- Last Synced: 2024-08-08T19:57:08.191Z (4 months ago)
- Language: Elixir
- Homepage:
- Size: 65.4 KB
- Stars: 68
- Watchers: 5
- Forks: 10
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- freaking_awesome_elixir - Elixir - A [PEG](http://bford.info/packrat/) implementation with a pleasant Elixir DSL. (Text and Numbers)
- fucking-awesome-elixir - neotomex - A [PEG](http://bford.info/packrat/) implementation with a pleasant Elixir DSL. (Text and Numbers)
- awesome-elixir - neotomex - A [PEG](http://bford.info/packrat/) implementation with a pleasant Elixir DSL. (Text and Numbers)
README
# Neotomex [![hex.pm version](https://img.shields.io/hexpm/v/neotomex.svg?style=flat)](https://hex.pm/packages/neotomex) [![hex.pm downloads](https://img.shields.io/hexpm/dt/neotomex.svg?style=flat)](https://hex.pm/packages/neotomex) [![travis.ci build status](https://img.shields.io/travis/jtmoulia/neotomex.svg?style=flat)](https://travis-ci.org/jtmoulia/neotomex)
**Obligatory Alpha Quality Disclaimer**
A [PEG](http://bford.info/packrat/) implementation with an Elixir
interface.While inspired by [neotoma](https://github.com/seancribbs/neotoma),
Neotomex doesn't use functional composition. Instead, it creates
a data structure representing a grammar, and then applies the
data structure to an input.NB: For now, Neotomex is a recursive rather than packrat parser.
## Usage
By taking advantage of pattern matching and Elixir's macros,
Neotomex provides a fresh DSL for specifying grammars.Here's a simple grammar for parsing a number:
```elixir
defmodule Number do
use Neotomex.ExGrammar@root true
define :number, "digit+" do
digits -> digits |> Enum.join |> String.to_integer
enddefine :digit, "[0-9]"
end42 = Number.parse! "42"
```See the `/examples` directory for other examples, including a
[json grammar](https://github.com/jtmoulia/neotomex/blob/master/examples/json.exs).## Learning More
Check out the module docs to learn more about how Neotomex
specifies grammars, and how to write your own:```elixir
iex> h Neotomex.Grammar
iex> h Neotomex.ExGrammar
```Look in `examples/` for existing usage.
## Roadmap
- Packrat parsing
- Match labels a la neotoma (e.g. a:match)Copyright (c) Thomas Moulia, 2014