Compare commits

...

4 Commits

Author SHA1 Message Date
Daniel Ziltener d449ee8469
Repository URL change 2023-11-24 22:37:59 +01:00
Daniel Ziltener b637ac6cab
New repository URL 2023-11-24 22:23:50 +01:00
Daniel Ziltener 9611de7aa9 Turned a-list into parameter 2022-10-30 22:37:47 +01:00
Daniel Ziltener 23ad941e04 0.5.3 2022-02-16 00:50:46 +01:00
7 changed files with 33 additions and 28 deletions

2
.dir-locals.el Normal file
View File

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

View File

@ -22,19 +22,21 @@ Data type conversions
Missing reader functionality
----------------------------
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.
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.
API
---
* Transforming EDN into Scheme: `(read-edn <port>)`
* Transforming Scheme into EDN: `(write-edn <port> <datastructure>)`
* 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.
* 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.
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))))
;;@(heading "Reading EDN")
@(==== "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)`.")
(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)`.")
(make-parameter (list (cons _: (lambda (input) edn/omit:)))))
(define reader-handlers
(list (cons (is-char? #\() edn->list)
@ -182,10 +182,10 @@
(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 @@
(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 @@
writer-handlers))
parse-entry in))
;;@(heading "Writing EDN")
@(==== "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 "0.5.2")
(dependencies r7rs srfi-69 srfi-1 hahn)
(test-dependencies r7rs srfi-64 hahn)
(version "1.0")
(dependencies r7rs srfi-69 srfi-1 chalk)
(test-dependencies r7rs srfi-64 chalk)
(components (extension edn
(modules edn)
(csc-options "-X" "r7rs" "-R" "r7rs" "-X" "hahn")
(csc-options "-X" "r7rs" "-R" "r7rs" "-X" "chalk")
)))

View File

@ -1,3 +1,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")
(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

View File

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

View File

@ -1,4 +1,4 @@
(import r7rs)
(import r7rs chalk)
(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))
(set! tag-handlers (cons (cons keywordify:
(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")