Compare commits

..

No commits in common. "master" and "0.5.2" have entirely different histories.

7 changed files with 28 additions and 33 deletions

View File

@ -1,2 +0,0 @@
((scheme-mode . ((flymake-chicken-command-args . ("-X" "r7rs" "-R" "r7rs" "-X" "chalk"))
(geiser-scheme . 'chicken))))

View File

@ -22,21 +22,19 @@ Data type conversions
Missing reader functionality
----------------------------
Should you notice missing functionality of the reader, plesase use [the issues
page](https://gitea.lyrion.ch/Chicken/edn/issues) to report it and, if possible, provide a minimal
test case.
Should you notice missing functionality of the reader, plesase use [the issues page](https://gitea.lyrion.ch/zilti/edn/issues) to report
it and, if possible, provide a minimal test case.
API
---
* Transforming EDN into Scheme: `(read-edn <port>)`
* Transforming Scheme into EDN: `(write-edn <port> <datastructure>)`
* Using reader tags: the library contains a parameter `tag-handlers` containing an a-list. To register a handler, add an a-list entry where the key is the tag without `\#` and as a keyword, and the value a one-argument procedure.
* Using reader tags: the library contains a public a-list `tag-handlers`. To register a handler, add an a-list entry where the key is the tag without `\#` and as a keyword, and the value a one-argument procedure.
Releases
--------
* **1.0**: Made the custom parsers a parameter.
* **0.5.2**: Update for Chicken 5
* **0.5.1**: Small compatibility improvements: "/" now starts a symbol as well, and "," is treated as whitespace.
* **0.5**: Reader tag support.

View File

@ -153,13 +153,13 @@
(and (char? x)
(fun x))))
@(==== "Reading EDN")
;;@(heading "Reading EDN")
(define tag-handlers
@("An a-list containing the handlers for reader tags. You can register your own reader tags by simply adding a new a-list entry.
Example for a tag \"#keywordify\": add the entry `(cons keywordify: keywordify-procedure)`.")
(make-parameter (list (cons _: (lambda (input) edn/omit:)))))
;;@("An a-list containing the handlers for reader tags. You can register your own reader tags by simply adding a new a-list entry.
;;
;;Example for a tag \"#keywordify\": add the entry `(cons keywordify: keywordify-procedure)`.")
(list (cons _: (lambda (input) edn/omit:))))
(define reader-handlers
(list (cons (is-char? #\() edn->list)
@ -182,10 +182,10 @@ Example for a tag \"#keywordify\": add the entry `(cons keywordify: keywordify-p
(contains-tag-handler? (car in))))
(define (contains-tag-handler? tag)
(assoc (cdr tag) (tag-handlers)))
(assoc (cdr tag) tag-handlers))
(define (call-tag tag data)
((cdr (assoc (cdr tag) (tag-handlers))) data))
((cdr (assoc (cdr tag) tag-handlers)) data))
(define (parse-edn state)
(lambda (in-port)
@ -204,7 +204,7 @@ Example for a tag \"#keywordify\": add the entry `(cons keywordify: keywordify-p
(cdr result)))))
(define (read-edn port)
@("Reads EDN data from given port, converts it to Chicken data and returns it. Precision suffixes for numbers get ignored, maps get converted to SRFI-69 hashtables, vectors to SRFI-4 vectors.")
;; @("Reads EDN data from given port, converts it to Chicken data and returns it. Precision suffixes for numbers get ignored, maps get converted to SRFI-69 hashtables, vectors to SRFI-4 vectors.")
(second ((parse-edn '()) port)))
;; EDN writing
@ -309,9 +309,9 @@ Example for a tag \"#keywordify\": add the entry `(cons keywordify: keywordify-p
writer-handlers))
parse-entry in))
@(==== "Writing EDN")
;;@(heading "Writing EDN")
(define (write-edn port struct)
@("Converts Chicken data structures to EDN and writes it to the given port."
(struct "A Chicken data structure consisting of atoms, lists, vectors and hashtables."))
;; @("Converts Chicken data structures to EDN and writes it to the given port."
;; (struct "A Chicken data structure consisting of atoms, lists, vectors and hashtables."))
(display (parse-entry struct) port))

View File

@ -4,10 +4,10 @@
(synopsis "EDN data reader/writer.")
(category parsing)
(license "BSD")
(version "1.0")
(dependencies r7rs srfi-69 srfi-1 chalk)
(test-dependencies r7rs srfi-64 chalk)
(version "0.5.2")
(dependencies r7rs srfi-69 srfi-1 hahn)
(test-dependencies r7rs srfi-64 hahn)
(components (extension edn
(modules edn)
(csc-options "-X" "r7rs" "-R" "r7rs" "-X" "chalk")
(csc-options "-X" "r7rs" "-R" "r7rs" "-X" "hahn")
)))

View File

@ -1,5 +1,3 @@
(repo git "https:///gitea.lyrion.ch/Chicken/edn.git")
(uri targz "https://gitea.lyrion.ch/Chicken/edn/archive/{egg-release}.tar.gz")
(release "1.0") ;; Made the custom parsers a parameter
(release "0.5.3") ;; Replaced Hahn with Chalk
(release "0.5.2") ;; Update for Chicken 5
(repo git "https:///gitea.lyrion.ch/zilti/edn.git")
(uri targz "https://gitea.lyrion.ch/zilti/edn/archive/{egg-release}.tar.gz")
(release "0.5.2")

View File

@ -1,8 +1,9 @@
@(== "EDN")
@(heading "EDN")
@("This egg provides a parser and a writer for the [[https://github.com/edn-format/edn|Extensible Data Notation]].")
@(text "This egg provides a parser and a writer for the [[https://github.com/edn-format/edn|Extensible Data Notation]].")
@(==="Documentation")
@(heading "Documentation")
@(noop)
(import r7rs)
(define-library (edn)

View File

@ -1,4 +1,4 @@
(import r7rs chalk)
(import r7rs)
(require-extension srfi-69 srfi-64 srfi-88 srfi-1)
;;(import (chicken port))
(include "../edn-impl.scm")
@ -50,9 +50,9 @@
(test-begin "Tag handling")
(test-equal (wifs "(1 2 #_ 3 4)" read-edn) '(1 2 4))
(tag-handlers (cons (cons keywordify:
(set! tag-handlers (cons (cons keywordify:
(lambda (input)
(string->keyword (symbol->string input))))
(tag-handlers)))
tag-handlers))
(test-equal (wifs "(asdf #keywordify qwertz)" read-edn) '(asdf qwertz:))
(test-end "Tag handling")