joetjen.net
EN DE
← All libraries
Elixir

ichor

Compiles grammar definitions into working language implementations.

Intention

Most grammar tools stop at a recognizer or a parse tree. Ichor goes one step further: write a grammar once in Aether — or import ABNF, BNF, EBNF or PEG — and you get a lexer, a parser, and an executor through your own Actions module, with no hand-written parsing code.

Example
use Ichor, grammar_source: """
@grammar "calculator"
@root expr
expr := term (op:("+" | "-") term)*
""", actions: Calculator.Actions

Calculator.run("2 + 3 * 4")
#=> {:ok, 14}
Install
{:ichor_runtime, "~> 0.2"},
{:ichor, "~> 0.2", only: :dev, runtime: false}
ElixirGrammar compilerPEG / LR / GLR