lfedn
is a parser for the edn specification, implemented using leex and yecc
and tested with eunit.
This is a low-level parser from edn to LFE data structures. You have to decide on how, specifically, to represent them, since each user may have a different need. There is no imposition here.
This project assumes you have rebar3 installed somwhere in your $PATH
.
This project depends upon the follow, which are installed to the
_build/default/lib
directory of this project when you run rebar3 compile
.
- LFE (Lisp Flavored Erlang; needed only to compile)
{deps, [{lfe, {git, "[email protected]/rvirding/lfe.git", {tag, "0.10.1"}}},
- ltest (needed only to run the tests)
{ltest, {git, "[email protected]/lfex/ltest.git", {tag, "0.7.0"}}}]}.
Just add it to your rebar.config
deps:
{deps,
[% ...
{lfedn,
{git, "[email protected]:quasiquoting/lfedn.git",
{tag, "1.2.0"}}}]}.
$ rebar3 compile
$ rebar3 eunit -v
edn | LFE |
---|---|
boolean | boolean |
char | string |
float | float |
integer | integer |
keyword¹ | atom |
list | list |
map | tagged list ⇒ `#(map [#(,key1 ,val1) ...]) |
nil (symbol) | nil (atom) |
set² | tagged list ⇒ #(set [...]) |
string | binary string (utf-8) |
symbol | atom |
tagged literal | tagged tuple ⇒ `#(tag ,symbol ,value) |
vector | tagged list ⇒ #(vector [...]) |
¹: Although keyword ↦ atom, :nil
↦ #(keyword nil)
.
²: Uniqueness is not checked at parse time.
The to-lfe
function transforms incoming data structures to be more
LFE-friendly, but the results can’t be converted back to string without
transforming again. The default mappings are:
edn | LFE |
---|---|
boolean | boolean |
char | string |
float | float |
integer | integer |
keyword | atom |
list | list |
map | dict |
nil (symbol) | nil (atom) |
set | set |
string | binary string |
symbol | atom |
tagged literal | call registered handler for tag or fail if not found |
vector | list |
Mariano Guerra (@marianoguerra) | erldn (Erlang) |
Eric Bailey (@yurrriq) | lfedn (LFE) |
The MIT License (MIT)
Copyright (c) 2013 Mariano Guerra
Copyright (c) 2015 Eric Bailey
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.