Skip to content
master
Go to file
Code

Latest commit

Fix String.split_at can not split "\r\n", resolves issue #19
3f33481

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
lib
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

Neotomex hex.pm version hex.pm downloads travis.ci build status

Obligatory Alpha Quality Disclaimer

A PEG implementation with an Elixir interface.

While inspired by 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:

defmodule Number do
  use Neotomex.ExGrammar

  @root true
  define :number, "digit+" do
    digits -> digits |> Enum.join |> String.to_integer
  end

  define :digit, "[0-9]"
end

42 = Number.parse! "42"

See the /examples directory for other examples, including a json grammar.

Learning More

Check out the module docs to learn more about how Neotomex specifies grammars, and how to write your own:

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

About

A PEG parser/transformer with a pleasant Elixir DSL.

Resources

License

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages

You can’t perform that action at this time.