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. Asked for it, the same parser also gives a lossless tree: every byte of the input, comments and whitespace included, which is what a formatter or an editor needs.
Example
defmodule Calculator do
use Ichor, grammar_source: """
@grammar "calculator"
@root expr
@skip SPACE
NUMBER := DIGIT+ ("." DIGIT+)?
expr := term (op:("+" | "-") term)*
term := factor (op:("*" | "/") factor)*
factor := NUMBER | "(" expr ")"
""", actions: Calculator.Actions
end
Calculator.run("2 + 3 * 4")
#=> {:ok, 14}Install
{:ichor_runtime, "~> 0.6.3"},
{:ichor, "~> 0.7.3", only: :dev, runtime: false}