[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/parseclj c32017ecc9 143/185: Merge pull request #20 from c
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/parseclj c32017ecc9 143/185: Merge pull request #20 from clojure-emacs/remove-parseedn |
Date: |
Tue, 28 Dec 2021 14:05:30 -0500 (EST) |
branch: elpa/parseclj
commit c32017ecc98a005aa4f67dedb20420d05cdcdbc2
Merge: a82f229014 7fba1624e0
Author: Arne Brasseur <arne.brasseur@gmail.com>
Commit: GitHub <noreply@github.com>
Merge pull request #20 from clojure-emacs/remove-parseedn
Remove parseedn files
---
DESIGN.md | 32 +++--
README.md | 35 +----
benchmark/speed-comparison.el | 26 ----
parseclj-ast.el | 1 -
parseedn.el | 188 --------------------------
test/parseedn-el-parity-test.el | 286 ----------------------------------------
test/parseedn-test.el | 77 -----------
7 files changed, 27 insertions(+), 618 deletions(-)
diff --git a/DESIGN.md b/DESIGN.md
index 8e5b88acef..2bf318818b 100644
--- a/DESIGN.md
+++ b/DESIGN.md
@@ -1,8 +1,8 @@
# parseclj Design Goals / Roadmap
-parseclj is an Emacs Lisp library for parsing Clojure code and EDN data. It
-supports several input and output formats, all powered by the same shift-reduce
-parser function.
+parseclj is an Emacs Lisp library for parsing Clojure code and [EDN
+data](https://github.com/edn-format/edn). It supports several input and output
+formats, all powered by the same shift-reduce parser function.
This documents describes the design goals for parseclj, and as such may
describe features which are not implemented yet.
@@ -39,7 +39,7 @@ On the other hand Emacs supports strings/buffers with
arbitrary encoding, on the
## Architecture
-The implementation is implemented in three parts: a lexer, a parser, and
multiple reducers.
+The implementation is implemented in three parts: a lexer, a parser, and
[multiple reducers](#multiple-reducers).
### Lexer
@@ -214,7 +214,17 @@ Unmatched closing delimiter:
In many cases it will be desirable to "fail fast", and raise an error as soon
as a syntax error is encountered. A `reduce-branch` function can do so if it
wishes by checking its input sequence for raw tokens, and raising an error if
any are present.
-## EDN vs Clojure
+## Multiple Reducers
+
+While the shift-reduce parser parses input, it reduces parsed values (leafs
tokens and collections) using "reducing functions". These functions are in
charge of giving actual meaning to the parsed data.
+
+Currently, there are two sets of reducing functions implemented: one set that
reduces parsed values to AST data structures, and another one that reduces to
Emacs Lisp values.
+
+The AST reducing functions are part of
[`parseclj`](https://github.com/clojure-emacs/parseclj), while the Emacs Lisp
reducing functions are separated into a differente package called
[`parseedn`](https://github.com/clojure-emacs/parseedn).
+
+To understand why these two set of reducing functions are separated, it's
important to look at the difference between EDN and Clojure, and also between
Emacs Lisp elements and EDN elements.
+
+### EDN vs Clojure
EDN syntax is a subset of Clojure syntax used for representing data (as
opposed to code).
@@ -223,7 +233,7 @@ Several constructs that are common in Clojure code are not
valid in EDN. This in
- quoting, syntax quoting, syntax quote splicing, etc.
- read time evaluation with `#=(,,,)`
-## Dealing with tagged literals
+### Dealing with tagged literals
EDN/Clojure syntax is extensible. Values can be prefixed with user-provided
tags, which indicates they need to be transformed after reading by a registered
handler function.
@@ -233,7 +243,7 @@ The EDN parser functions will take an optional tag handler
function. This functi
When parsing code to an AST the situation is different, here tags simply
become part of the AST, without caring about their semantics.
-## Representing EDN as Emacs Lisp values
+### Representing EDN as Emacs Lisp values
See also the section at the top regarding differences between Clojure's data
types vs those available in Emacs Lisp.
@@ -246,11 +256,11 @@ These are the choices that the edn.el library has made:
- represent characters as integers, *but* parse `\newline` `\return` `\space`
and `\tab` as the symbols `'newline` `'return` etc.
- parse `true` as `t`, `nil` and `false` as `nil`.
-### Differences with EDN.el
+#### Differences with EDN.el
At the moment the `parseedn-*` copy the parsing behavior of edn.el, *except*
that the character literals `\newline`, `\return`, `\space`, and `\tab` are
parsed to their character code (10, 13, 32, and 9 respectively), instead of to
symbols.
-## AST
+### AST
An AST (abstract syntax tree) is a tree structure made up of nodes. A node
looks like this
@@ -274,6 +284,8 @@ Non-leaf nodes contain a list of `:children`.
## Public API
+> Disclaimer: outdated information -- this API has been deprecated in favor of
[Alternative Package Layout](#alternative-package-layout), and it's only kept
here for historical purposes.
+
parseclj provides three "parse modes"
- `edn` meant for parsing data, it parses EDN to emacs lisp data
@@ -432,7 +444,7 @@ corresponding type in Emacs. `nil' and `false' form a
particularly poignant case, both are converted to `nil'.")
```
-**Package**: parseedn
+**Package**: [parseedn](https://github.com/clojure-emacs/parseedn)
- file: parseedn.el
diff --git a/README.md b/README.md
index 1b930c937e..bcadcf9eb1 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
[![Build
Status](https://travis-ci.org/clojure-emacs/parseclj.svg?branch=master)](https://travis-ci.org/clojure-emacs/parseclj)
-# EDN reader and Clojure parser for Emacs Lisp
+# Clojure parser for Emacs Lisp
`parseclj` is an Emacs Lisp library for parsing Clojure code and [EDN
data](https://github.com/edn-format/edn). It supports several input and output
@@ -25,12 +25,9 @@ You can just copy-paste this code into your Emacs init file:
## Usage
-`parseclj` is actually a compound of two libraries:
-
-- `parseedn`: An EDN reader that transforms EDN to Emacs Lisp data structures.
-- `parseclj`: A Clojure parser that returns an
- [AST](https://en.wikipedia.org/wiki/Abstract_syntax_tree) that, for example,
- given as input `(1 2 [:a :b :c])`, it looks like this:
+`parseclj` contains function that return an
+[AST](https://en.wikipedia.org/wiki/Abstract_syntax_tree) that, for example,
+given as input `(1 2 [:a :b :c])`, it looks like this:
``` emacs-lisp
((:node-type . :root)
@@ -61,7 +58,7 @@ You can just copy-paste this code into your Emacs init file:
(:value . :c))))))))
```
-In order to use any of them, you first need to require it:
+In order to use any of these functions, you first need to require it:
```emacs-lisp
(require 'parseclj)
@@ -71,8 +68,6 @@ In order to use any of them, you first need to require it:
And then you will have the following functions at your disposal:
-### parseclj
-
- `parseclj-parse-clojure` &rest string-and-options
When no arguments, parses Clojure source code into an AST and returns it.
@@ -107,26 +102,6 @@ And then you will have the following functions at your
disposal:
Transfrom the given AST into Clojure source code and returns it as a
string.
-### parseedn
-
-- `parseedn-read`
-
- Read content from the current buffer as EDN and transforms it into an Emacs
- Lisp value.
-
-- `parseedn-read-str` str
-
- Read STR as EDN and transfroms it into an Emacs Lisp value.
-
-- `parseedn-print` datum
-
- Inserts DATUM as EDN Into the current buffer. DATUM can be any Emacs Lisp
- value.
-
-- `parseedn-print-str` datum
-
- Returns a string containing DATUM as EDN. DATUM can be any Emacs Lisp
- value.
## License
diff --git a/benchmark/speed-comparison.el b/benchmark/speed-comparison.el
deleted file mode 100644
index 12682112d2..0000000000
--- a/benchmark/speed-comparison.el
+++ /dev/null
@@ -1,26 +0,0 @@
-;; takes a file containing edn file names, one per line
-;;
-;; locate *.edn > edn.list
-;;
-;; results end up as edn in *edn-parse-time-results*
-(with-current-buffer (find-file-noselect "edn.list")
- (goto-char 1)
- (while (and (< (point) (point-max)))
- (end-of-line)
- (let* ((fn (buffer-substring-no-properties (line-beginning-position)
(point)))
- (buff (find-file-noselect fn))
- (edn-time 0)
- (clj-time 0))
- ;;(message fn)
- (with-current-buffer buff
- (let ((start (time-to-seconds (current-time))))
- (parseedn-read)
- (setq clj-time (+ clj-time (- (time-to-seconds (current-time))
start))))
- (goto-char 1)
- (let ((start (time-to-seconds (current-time))))
- (edn-read)
- (setq edn-time (+ edn-time (- (time-to-seconds (current-time))
start)))))
- (kill-buffer buff)
- (when (< (point) (point-max)) (right-char))
- (with-current-buffer "*edn-parse-time-results*"
- (insert "{:file \"" fn "\", :edn-time " (number-to-string edn-time) ",
:clj-time " (number-to-string clj-time) "}\n")))))
diff --git a/parseclj-ast.el b/parseclj-ast.el
index 88a8727a1a..eaab13e5d9 100644
--- a/parseclj-ast.el
+++ b/parseclj-ast.el
@@ -29,7 +29,6 @@
(require 'subr-x)
(require 'parseclj-lex)
-(require 'parseedn)
;; AST helper functions
diff --git a/parseedn.el b/parseedn.el
deleted file mode 100644
index 9e2e1e915e..0000000000
--- a/parseedn.el
+++ /dev/null
@@ -1,188 +0,0 @@
-;;; parseedn.el --- EDN reader/writer -*- lexical-binding: t; -*-
-
-;; Copyright (C) 2017-2018 Arne Brasseur
-
-;; Author: Arne Brasseur <arne@arnebrasseur.net>
-
-;; This file is not part of GNU Emacs.
-
-;; This file is free software; you can redistribute it and/or modify
-;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 3, or (at your option)
-;; any later version.
-
-;; This file is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-;; GNU General Public License for more details.
-
-;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING. If not, write to
-;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-;; Boston, MA 02110-1301, USA.
-
-;;; Commentary:
-
-;; The EDN <-> Elisp reader and printer
-
-;;; Code:
-
-;; The EDN spec is not clear about wether \u0123 and \o012 are supported in
-;; strings. They are described as character literals, but not as string escape
-;; codes. In practice all implementations support them (mostly with broken
-;; surrogate pair support), so we do the same. Sorry, emoji 🙁.
-;;
-;; Note that this is kind of broken, we don't correctly detect if \u or \o
forms
-;; don't have the right forms.
-
-(require 'a)
-(require 'parseclj-parser)
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; Reader
-
-(defvar parseedn-default-tag-readers
- (a-list 'inst (lambda (s)
- (cl-list* 'edn-inst (date-to-time s)))
- 'uuid (lambda (s)
- (list 'edn-uuid s)))
- "Default reader functions for handling tagged literals in EDN.
-These are the ones defined in the EDN spec, #inst and #uuid. It
-is not recommended you change this variable, as this globally
-changes the behavior of the EDN reader. Instead pass your own
-handlers as an optional argument to the reader functions.")
-
-(defun parseedn-reduce-leaf (stack token _options)
- "Put in the STACK an elisp value representing TOKEN.
-
-OPTIONS is an association list. See `parseclj-parse' for more information
-on available options."
- (if (member (parseclj-lex-token-type token) (list :whitespace :comment))
- stack
- (cons (parseclj-lex--leaf-token-value token) stack)))
-
-(defun parseedn-reduce-branch (stack opening-token children options)
- "Reduce STACK with an sequence containing a collection of other elisp values.
-Ignores discard tokens.
-
-OPENING-TOKEN is a lex token representing an opening paren, bracket or
-brace.
-CHILDREN is a collection elisp values to be reduced into an elisp
-sequence.
-OPTIONS is an association list. See `parseclj-parse' for more information
-on available options."
- (let ((tag-readers (a-merge parseedn-default-tag-readers (a-get options
:tag-readers)))
- (token-type (parseclj-lex-token-type opening-token)))
- (if (eq token-type :discard)
- stack
- (cons
- (cl-case token-type
- (:root children)
- (:lparen children)
- (:lbracket (apply #'vector children))
- (:set (list 'edn-set children))
- (:lbrace (let* ((kvs (seq-partition children 2))
- (hash-map (make-hash-table :test 'equal :size (length
kvs))))
- (seq-do (lambda (pair)
- (puthash (car pair) (cadr pair) hash-map))
- kvs)
- hash-map))
- (:tag (let* ((tag (intern (substring (a-get opening-token :form) 1)))
- (reader (a-get tag-readers tag :missing)))
- (when (eq :missing reader)
- (user-error "No reader for tag #%S in %S" tag (a-keys
tag-readers)))
- (funcall reader (car children)))))
- stack))))
-
-(defun parseedn-read (&optional tag-readers)
- "Read content from current buffer and parse it as EDN source.
-Returns an Emacs Lisp value.
-
-TAG-READERS is an optional association list where keys are symbols
-identifying *tags*, and values are tag handler functions that receive one
-argument: *the tagged element*, and specify how to interpret it."
- (parseclj-parser #'parseedn-reduce-leaf
- #'parseedn-reduce-branch
- (a-list :tag-readers tag-readers)))
-
-(defun parseedn-read-str (s &optional tag-readers)
- "Parse string S as EDN.
-Returns an Emacs Lisp value.
-
-TAG-READERS is an optional association list. For more information, see
-`parseedn-read'."
- (with-temp-buffer
- (insert s)
- (goto-char 1)
- (car (parseedn-read tag-readers))))
-
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; Printer
-
-(defun parseedn-print-seq (coll)
- "Insert sequence COLL as EDN into the current buffer."
- (parseedn-print (elt coll 0))
- (let ((next (seq-drop coll 1)))
- (when (not (seq-empty-p next))
- (insert " ")
- (parseedn-print-seq next))))
-
-(defun parseedn-print-kvs (map)
- "Insert hash table MAP as an EDN map into the current buffer."
- (let ((keys (a-keys map)))
- (parseedn-print (car keys))
- (insert " ")
- (parseedn-print (a-get map (car keys)))
- (let ((next (cdr keys)))
- (when (not (seq-empty-p next))
- (insert ", ")
- (parseedn-print-kvs next)))))
-
-(defun parseedn-print (datum)
- "Insert DATUM as EDN into the current buffer.
-DATUM can be any Emacs Lisp value."
- (cond
- ((or (null datum) (numberp datum))
- (prin1 datum (current-buffer)))
-
- ((stringp datum)
- (insert "\"")
- (seq-doseq (char datum)
- (insert (cl-case char
- (?\t "\\t")
- (?\f "\\f")
- (?\" "\\\"")
- (?\r "\\r")
- (?\n"foo\t" "\\n")
- (?\\ "\\\\")
- (t (char-to-string char)))))
- (insert "\""))
-
- ((eq t datum)
- (insert "true"))
-
- ((symbolp datum)
- (insert (symbol-name datum)))
-
- ((vectorp datum) (insert "[") (parseedn-print-seq datum) (insert "]"))
-
- ((consp datum)
- (cond
- ((eq 'edn-set (car datum))
- (insert "#{") (parseedn-print-seq (cadr datum)) (insert "}"))
- (t (insert "(") (parseedn-print-seq datum) (insert ")"))))
-
- ((hash-table-p datum)
- (insert "{") (parseedn-print-kvs datum) (insert "}"))))
-
-(defun parseedn-print-str (datum)
- "Return a string containing DATUM as EDN.
-DATUM can be any Emacs Lisp value."
- (with-temp-buffer
- (parseedn-print datum)
- (buffer-substring-no-properties (point-min) (point-max))))
-
-(provide 'parseedn)
-
-;;; parseedn.el ends here
diff --git a/test/parseedn-el-parity-test.el b/test/parseedn-el-parity-test.el
deleted file mode 100644
index c58641a4f3..0000000000
--- a/test/parseedn-el-parity-test.el
+++ /dev/null
@@ -1,286 +0,0 @@
-;;; edn-el-parity.el --- Tests from edn.el
-
-;; Author: Lars Andersen <expez@expez.com>, Arne Brasseur
<arne@arnebrasseur.net>
-
-;; Copyright (C) 2015 Lars Andersen
-
-;; This file is not part of GNU Emacs.
-
-;; This file is free software; you can redistribute it and/or modify
-;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 3, or (at your option)
-;; any later version.
-
-;; This file is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-;; GNU General Public License for more details.
-
-;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING. If not, write to
-;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-;; Boston, MA 02110-1301, USA.
-
-;;; Commentary:
-
-;; These tests are copied verbatim from the edn.el source, and adapted to use
-;; our API. This way we assure that parseclj can act as a drop-in replacement
-;; for edn.el.
-
-;;; Code:
-
-(require 'ert)
-(require 'parseclj)
-(eval-when-compile (require 'subr-x)) ;; for things like hash-table-keys
-
-(ert-deftest whitespace ()
- (should (null (parseedn-read-str "")))
- (should (null (parseedn-read-str " ")))
- (should (null (parseedn-read-str " ")))
- (should (null (parseedn-read-str " ")))
- (should (null (parseedn-read-str " ")))
- (should (null (parseedn-read-str ",")))
- (should (null (parseedn-read-str ",,,,")))
- (should (null (parseedn-read-str " , ,\n")))
- (should (null (parseedn-read-str "\n ,, ")))
- (should (equal [a b c d] (parseedn-read-str "[a ,,,,,, b,,,,,c ,d]"))))
-
-(ert-deftest symbols ()
- :tags '(edn symbol)
- (should (equal 'foo (parseedn-read-str "foo")))
- (should (equal 'foo\. (parseedn-read-str "foo.")))
- (should (equal '%foo\. (parseedn-read-str "%foo.")))
- (should (equal 'foo/bar (parseedn-read-str "foo/bar")))
- (equal 'some\#sort\#of\#symbol (parseedn-read-str "some#sort#of#symbol"))
- (equal 'truefalse (parseedn-read-str "truefalse"))
- (equal 'true. (parseedn-read-str "true."))
- (equal '/ (parseedn-read-str "/"))
- (should (equal '.true (parseedn-read-str ".true")))
- (should (equal 'some:sort:of:symbol (parseedn-read-str
"some:sort:of:symbol")))
- (equal 'foo-bar (parseedn-read-str "foo-bar"))
- (should (equal '+some-symbol (parseedn-read-str "+some-symbol")))
- (should (equal '-symbol (parseedn-read-str "-symbol"))))
-
-(ert-deftest booleans ()
- :tags '(edn boolean)
- (should (equal t (parseedn-read-str "true")))
- (should (equal nil (parseedn-read-str "false "))))
-
-(ert-deftest characters ()
- :tags '(edn characters)
- (should (equal 97 (parseedn-read-str "\\a")))
- (should (equal 960 (parseedn-read-str "\\u03C0")))
- ;;(should (equal 'newline (parseedn-read-str "\\newline")))
- )
-
-(ert-deftest elision ()
- :tags '(edn elision)
- (should-not (parseedn-read-str "#_foo"))
- (should-not (parseedn-read-str "#_ 123"))
- (should-not (parseedn-read-str "#_:foo"))
- (should-not (parseedn-read-str "#_ \\a"))
- (should-not (parseedn-read-str "#_
-\"foo\""))
- (should-not (parseedn-read-str "#_ (1 2 3)"))
- (should (equal '(1 3) (parseedn-read-str "(1 #_ 2 3)")))
- (should (equal '[1 2 3 4] (parseedn-read-str "[1 2 #_[4 5 6] 3 4]")))
- (should (map-equal (make-seeded-hash-table :foo :bar)
- (parseedn-read-str "{:foo #_elided :bar}")))
- (should (equal '(edn-set (1 2 3 4))
- (parseedn-read-str "#{1 2 #_[1 2 3] 3 #_ (1 2) 4}")))
- (should (equal [a d] (parseedn-read-str "[a #_ ;we are discarding what comes
next
- c d]"))))
-
-(ert-deftest string ()
- :tags '(edn string)
- (should (equal "this is a string" (parseedn-read-str "\"this is a
string\"")))
- (should (equal "this has an escaped \"quote in it"
- (parseedn-read-str "\"this has an escaped \\\"quote in
it\"")))
- (should (equal "foo\tbar" (parseedn-read-str "\"foo\\tbar\"")))
- (should (equal "foo\nbar" (parseedn-read-str "\"foo\\nbar\"")))
- (should (equal "this is a string \\ that has an escaped backslash"
- (parseedn-read-str "\"this is a string \\\\ that has an
escaped backslash\"")))
- (should (equal "[" (parseedn-read-str "\"[\""))))
-
-(ert-deftest keywords ()
- :tags '(edn keywords)
- (should (equal :namespace\.of\.some\.length/keyword-name
- (parseedn-read-str ":namespace.of.some.length/keyword-name")))
- (should (equal :\#/\# (parseedn-read-str ":#/#")))
- (should (equal :\#/:a (parseedn-read-str ":#/:a")))
- (should (equal :\#foo (parseedn-read-str ":#foo"))))
-
-(ert-deftest integers ()
- :tags '(edn integers)
- (should (= 0 (parseedn-read-str "0")))
- (should (= 0 (parseedn-read-str "+0")))
- (should (= 0 (parseedn-read-str "-0")))
- (should (= 100 (parseedn-read-str "100")))
- (should (= -100 (parseedn-read-str "-100"))))
-
-(ert-deftest floats ()
- :tags '(edn floats)
- (should (= 12.32 (parseedn-read-str "12.32")))
- (should (= -12.32 (parseedn-read-str "-12.32")))
- (should (= 9923.23 (parseedn-read-str "+9923.23")))
- (should (= 4.5e+044 (parseedn-read-str "45e+43")))
- (should (= -4.5e-042 (parseedn-read-str "-45e-43")))
- (should (= 4.5e+044 (parseedn-read-str "45E+43"))))
-
-(ert-deftest lists ()
- :tags '(edn lists)
- (should-not (parseedn-read-str "()"))
- (should (equal '(1 2 3) (parseedn-read-str "( 1 2 3)")))
- (should (equal '(12.1 ?a foo :bar) (parseedn-read-str "(12.1 \\a foo
:bar)")))
- (should (equal '((:foo bar :bar 12)) (parseedn-read-str "( (:foo bar :bar
12))")))
- (should (equal
- '(defproject com\.thortech/data\.edn "0.1.0-SNAPSHOT")
- (parseedn-read-str "(defproject com.thortech/data.edn
\"0.1.0-SNAPSHOT\")"))))
-
-(ert-deftest vectors ()
- :tags '(edn vectors)
- (should (equal [] (parseedn-read-str "[]")))
- (should (equal [] (parseedn-read-str "[ ]")))
- (should (equal '[1 2 3] (parseedn-read-str "[ 1 2 3 ]")))
- (should (equal '[12.1 ?a foo :bar] (parseedn-read-str "[ 12.1 \\a foo
:bar]")))
- (should (equal '[[:foo bar :bar 12]] (parseedn-read-str "[[:foo bar :bar
12]]")))
- (should (equal '[( :foo bar :bar 12 ) "foo"]
- (parseedn-read-str "[(:foo bar :bar 12) \"foo\"]")))
- (should (equal '[/ \. * ! _ \? $ % & = - +]
- (parseedn-read-str "[/ . * ! _ ? $ % & = - +]")))
- (should (equal
- ;;[99 newline return space tab]
- [99 10 13 32 9]
- (parseedn-read-str "[\\c \\newline \\return \\space \\tab]"))))
-
-(defun map-equal (m1 m2)
- (and (and (hash-table-p m1) (hash-table-p m2))
- (eq (hash-table-test m1) (hash-table-test m2))
- (= (hash-table-count m1) (hash-table-count m2))
- (equal (hash-table-keys m1) (hash-table-keys m2))
- (equal (hash-table-values m1) (hash-table-values m2))))
-
-(defun make-seeded-hash-table (&rest keys-and-values)
- (let ((m (make-hash-table :test #'equal)))
- (while keys-and-values
- (puthash (pop keys-and-values) (pop keys-and-values) m))
- m))
-
-(ert-deftest maps ()
- :tags '(edn maps)
- (should (hash-table-p (parseedn-read-str "{ }")))
- (should (hash-table-p (parseedn-read-str "{}")))
- (should (map-equal (make-seeded-hash-table :foo :bar :baz :qux)
- (parseedn-read-str "{ :foo :bar :baz :qux}")))
- (should (map-equal (make-seeded-hash-table 1 "123" 'vector [1 2 3])
- (parseedn-read-str "{ 1 \"123\" vector [1 2 3]}")))
- (should (map-equal (make-seeded-hash-table [1 2 3] "some numbers")
- (parseedn-read-str "{[1 2 3] \"some numbers\"}"))))
-
-(ert-deftest sets ()
- :tags '(edn sets)
- (should (eq 'edn-set (car (parseedn-read-str "#{}"))))
- (should (eq 'edn-set (car (parseedn-read-str "#{ }"))))
- (should (equal '(edn-set (1 2 3)) (parseedn-read-str "#{1 2 3}")))
- (should (equal '(edn-set (1 [1 2 3] 3)) (parseedn-read-str "#{1 [1 2 3]
3}"))))
-
-(ert-deftest comment ()
- :tags '(edn comments)
- (should-not (parseedn-read-str ";nada"))
- (should (equal 1 (parseedn-read-str ";; comment
-1")))
- (should (equal [1 2 3] (parseedn-read-str "[1 2 ;comment to eol
-3]")))
- (should (equal '[valid more items] (parseedn-read-str "[valid;touching
trailing comment
- more items]")))
- (should (equal [valid vector more vector items] (parseedn-read-str "[valid
vector
- ;;comment in vector
- more vector items]"))))
-
-(defun test-val-passed-to-handler (val)
- (should (listp val))
- (should (= (length val) 2))
- (should (= 1 (car val)))
- 1)
-
-(setq parseedn-test-extra-handlers
- (a-list
- 'my/type #'test-val-passed-to-handler
- 'my/other-type (lambda (val) 2)))
-
-(ert-deftest tags ()
- :tags '(edn tags)
- (should-error (parseedn-read-str "#my/type value"
parseedn-test-extra-handlers))
- (should (= 1 (parseedn-read-str "#my/type (1 2)"
parseedn-test-extra-handlers)))
- (should (= 2 (parseedn-read-str "#my/other-type {:foo :bar}"
parseedn-test-extra-handlers)))
- (should-error (parseedn-read-str "#myapp/Person {:first \"Fred\" :last
\"Mertz\"}")))
-
-(ert-deftest roundtrip ()
- :tags '(edn roundtrip)
- (let ((data [1 2 3 :foo (4 5) qux "quux"]))
- (should (equal data (parseedn-read-str (parseedn-print-str data))))
- (should (map-equal (make-seeded-hash-table :foo :bar)
- (parseedn-read-str (parseedn-print-str
(make-seeded-hash-table :foo :bar)))))
- (should (equal '(edn-set (1 2 3 [3 1.11]))
- (parseedn-read-str (parseedn-print-str '(edn-set (1 2 3 [3
1.11]))))))))
-
-(ert-deftest inst ()
- :tags '(edn inst)
- (let* ((inst-str "#inst \"1985-04-12T23:20:50.52Z\"")
- (inst (parseedn-read-str inst-str))
- (time (date-to-time "1985-04-12T23:20:50.52Z")))
- (should (eq 'edn-inst (car inst)))
- (should (equal time (cdr inst)))))
-
-(ert-deftest uuid ()
- :tags '(edn uuid)
- (let* ((str "f81d4fae-7dec-11d0-a765-00a0c91e6bf6")
- (uuid (parseedn-read-str (concat "#uuid \"" str "\""))))
- (should (eq 'edn-uuid (car uuid)))))
-
-;; (ert-deftest invalid-edn ()
-;; (should-error (parseedn-read-str "///"))
-;; (should-error (parseedn-read-str "~cat"))
-;; (should-error (parseedn-read-str "foo/bar/baz/qux/quux"))
-;; (should-error (parseedn-read-str "#foo/"))
-;; (should-error (parseedn-read-str "foo/"))
-;; (should-error (parseedn-read-str ":foo/"))
-;; (should-error (parseedn-read-str "#/foo"))
-;; (should-error (parseedn-read-str "/symbol"))
-;; (should-error (parseedn-read-str ":/foo"))
-;; (should-error (parseedn-read-str "+5symbol"))
-;; (should-error (parseedn-read-str ".\\newline"))
-;; (should-error (parseedn-read-str "0cat"))
-;; (should-error (parseedn-read-str "-4cats"))
-;; (should-error (parseedn-read-str ".9"))
-;; (should-error (parseedn-read-str ":keyword/with/too/many/slashes"))
-;; (should-error (parseedn-read-str ":a.b.c/"))
-;; (should-error (parseedn-read-str "\\itstoolong"))
-;; (should-error (parseedn-read-str ":#/:"))
-;; (should-error (parseedn-read-str "/foo//"))
-;; (should-error (parseedn-read-str "///foo"))
-;; (should-error (parseedn-read-str ":{}"))
-;; (should-error (parseedn-read-str "//"))
-;; (should-error (parseedn-read-str "##"))
-;; (should-error (parseedn-read-str "::"))
-;; (should-error (parseedn-read-str "::a"))
-;; (should-error (parseedn-read-str ".5symbol"))
-;; (should-error (parseedn-read-str "{ \"foo\""))
-;; (should-error (parseedn-read-str "{ \"foo\" :bar"))
-;; (should-error (parseedn-read-str "{"))
-;; (should-error (parseedn-read-str ":{"))
-;; (should-error (parseedn-read-str "{{"))
-;; (should-error (parseedn-read-str "}"))
-;; (should-error (parseedn-read-str ":}"))
-;; (should-error (parseedn-read-str "}}"))
-;; (should-error (parseedn-read-str "#:foo"))
-;; (should-error (parseedn-read-str "\\newline."))
-;; (should-error (parseedn-read-str "\\newline0.1"))
-;; (should-error (parseedn-read-str "^"))
-;; (should-error (parseedn-read-str ":^"))
-;; (should-error (parseedn-read-str "_:^"))
-;; (should-error (parseedn-read-str "#{{[}}"))
-;; (should-error (parseedn-read-str "[}"))
-;; (should-error (parseedn-read-str "@cat")))
-
-;;; edn-el-parity-test.el ends here
diff --git a/test/parseedn-test.el b/test/parseedn-test.el
deleted file mode 100644
index eb4cfb41fa..0000000000
--- a/test/parseedn-test.el
+++ /dev/null
@@ -1,77 +0,0 @@
-;;; parseedn-test.el --- Unit tests for EDN reading/printing
-
-;; Copyright (C) 2017-2018 Arne Brasseur
-
-;; Author: Arne Brasseur <arne@arnebrasseur.net>
-
-;; This file is not part of GNU Emacs.
-
-;; This file is free software; you can redistribute it and/or modify
-;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 3, or (at your option)
-;; any later version.
-
-;; This file is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-;; GNU General Public License for more details.
-
-;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING. If not, write to
-;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-;; Boston, MA 02110-1301, USA.
-
-;;; Commentary
-
-;; Unit tests for EDN reading/printing
-
-;;; Code
-
-(require 'ert)
-(require 'parseclj)
-
-(load "test/parseclj-test-data.el")
-
-(ert-deftest parseedn-print-test ()
- (should (equal (parseedn-print-str nil) "nil"))
- (should (equal (parseedn-print-str 100) "100"))
- (should (equal (parseedn-print-str 1.2) "1.2"))
- (should (equal (parseedn-print-str [1 2 3]) "[1 2 3]"))
- (should (equal (parseedn-print-str t) "true")))
-
-(ert-deftest parseedn-read-test ()
- (should (equal (parseedn-read-str "true") t)))
-
-(defmacro define-parseedn-read-tests ()
- `(progn
- ,@(mapcar
- (lambda (pair)
- (let ((name (car pair))
- (data (cdr pair)))
- (if (and (a-get data :edn) (a-get data :source))
- (let ((test-name (intern (concat "parseedn-read:" name))))
- `(ert-deftest ,test-name ()
- :tags '(parseedn)
- (with-temp-buffer
- (insert ,(a-get data :source))
- (goto-char 1)
- (should (a-equal (parseedn-read) ',(a-get data
:edn)))))))))
- parseclj-test-data)))
-
-(defmacro define-parseedn-roundtrip-tests ()
- `(progn
- ,@(mapcar
- (lambda (pair)
- (let ((name (car pair))
- (data (cdr pair)))
- (if (and (a-get data :edn) (a-get data :source) (member
:edn-roundtrip (a-get data :tags)))
- (let ((test-name (intern (concat "parseedn-rountrip:" name))))
- `(ert-deftest ,test-name ()
- :tags '(parseedn-rountrip)
- (should (equal (parseedn-print-str (car ',(a-get data
:edn))) ,(a-get data :source))))))))
- parseclj-test-data)))
-
-(define-parseedn-read-tests)
-(define-parseedn-roundtrip-tests)
-
-;;; parseedn-test.el
- [nongnu] elpa/parseclj f86a3be4bf 107/185: Add last rewordings, (continued)
- [nongnu] elpa/parseclj f86a3be4bf 107/185: Add last rewordings, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 388bb2bde2 115/185: Fix test case for `\u` and `\o` characters, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj d3cb78544d 106/185: Use Emacs Lisp predicate style convention, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj aeac6a1755 118/185: Fix code's organization for 2-item stack reduction, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj bad1fb8745 119/185: Merge pull request #12 from lambdaisland/nested-2-items-reduction, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj b377e12d7e 125/185: Add test case for invalid input error token, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 903d60284e 130/185: Update the Travis CI badge, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj d691df5d63 131/185: Update the copyright years, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj acf4a29778 132/185: Update the README, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj d42b4ad744 144/185: Require a couple of dependencies to `parseclj-ast.el`, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj c32017ecc9 143/185: Merge pull request #20 from clojure-emacs/remove-parseedn,
ELPA Syncer <=
- [nongnu] elpa/parseclj ece9648128 179/185: Merge pull request #33 from clojure-emacs/arne/remove-a-from-tests, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj c7f50e3414 178/185: Update CHANGELOG, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 30c950a4ad 167/185: Use map-contains-key, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 0d157d759b 163/185: Merge branch 'master' into shebang-and-symbolic-values, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 089160a487 169/185: Drop a.el dependency, bump copyright year, bump version, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 93a0f43529 150/185: Merge pull request #21 from clojure-emacs/add-more-syntax-features, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj adb55fa579 183/185: Merge pull request #34 from clojure-emacs/cl-case-to-cond, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj dec638c5ca 153/185: Tweak the keywords, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 5cf5cd5f53 182/185: Replace seq-doseq with mapcar... IDK, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 3de700b057 154/185: Add a changelog, ELPA Syncer, 2021/12/28