[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/tomelr 0f4e7b4f2c 47/84: fix: Better detection of neste
From: |
ELPA Syncer |
Subject: |
[elpa] externals/tomelr 0f4e7b4f2c 47/84: fix: Better detection of nested TTA, but still wip |
Date: |
Tue, 3 May 2022 09:58:11 -0400 (EDT) |
branch: externals/tomelr
commit 0f4e7b4f2c40a2cdce735d614eba9b7ac4640d06
Author: Kaushal Modi <kaushal.modi@gmail.com>
Commit: Kaushal Modi <kaushal.modi@gmail.com>
fix: Better detection of nested TTA, but still wip
This fix also breaks the plist support for TTA
---
README.org | 7 +++----
test/tinternal.el | 10 ++++++++++
test/tplist.el | 23 ++++++++++++-----------
tomelr.el | 33 ++++++++++++++++++++++++++-------
4 files changed, 51 insertions(+), 22 deletions(-)
diff --git a/README.org b/README.org
index 4944ec5fcb..e44d71aea8 100644
--- a/README.org
+++ b/README.org
@@ -18,7 +18,7 @@ the Emacs core library
[[https://git.savannah.gnu.org/cgit/emacs.git/tree/lisp/j
It will then be gradually refactored so that it meets the
specification defined below.
-* Library Completion Status [6/7]
+* Library Completion Status [5/7]
- [X] Scalar
- [X] Boolean
- [X] Integer
@@ -35,7 +35,7 @@ specification defined below.
- [-] Array of Tables
- [X] Basic Array of Tables
- [ ] Nested Array of Tables
-- [X] Property Lists
+- [ ] Property Lists
* Specification and Conversion Examples
[[https://scripter.co/defining-tomelr/][Companion blog post]]
@@ -952,8 +952,7 @@ contributors = [
]
}
#+end_example
-** DONE P-lists
-CLOSED: [2022-04-29 Fri 18:42]
+** TODO P-lists
**** S-expression
#+begin_src emacs-lisp :eval no :noweb-ref p-list
'(:int 123
diff --git a/test/tinternal.el b/test/tinternal.el
index 5b4e1bb5d8..0e46b57ebb 100644
--- a/test/tinternal.el
+++ b/test/tinternal.el
@@ -47,7 +47,17 @@
;;;; tomelr--toml-table-array-p
(ert-deftest test-internal-valid-tta ()
(let ((inp '(
+ ;; ;; TTA with 1 table of 1 key-val pair
(((a . 1)))
+ ((:a 1))
+ ;; ;; TTA with 2 tables of 2 key-val pairs
+ (((a . 1) (b . 2))
+ ((a . 100) (b . 200)))
+ ((:a 1 :b 2)
+ (:a 100 :b 200))
+ ;; TTA with 1 table nesting another TTA
+ (((a . (((b . 2))))))
+ ((:a ((:b 2))))
)))
(dolist (el inp)
(should (equal t (tomelr--toml-table-array-p el))))))
diff --git a/test/tplist.el b/test/tplist.el
index 6798e137cf..2191d305f9 100644
--- a/test/tplist.el
+++ b/test/tplist.el
@@ -40,10 +40,11 @@
:list_of_lists [(1 2) (3 4 5)]
:map (:key1 123
:key2 "xyz")
- :list_of_maps [(:key1 123
- :key2 "xyz")
- (:key1 567
- :key2 "klm")])))
+ ;; :list_of_maps [(:key1 123
+ ;; :key2 "xyz")
+ ;; (:key1 567
+ ;; :key2 "klm")]
+ )))
(ref '("int = 123
str = \"abc\"
bool_false = false
@@ -54,13 +55,13 @@ bool_list = [ true, false, true, false ]
list_of_lists = [ [ 1, 2 ], [ 3, 4, 5 ] ]
[map]
key1 = 123
- key2 = \"xyz\"
-[[list_of_maps]]
- key1 = 123
- key2 = \"xyz\"
-[[list_of_maps]]
- key1 = 567
- key2 = \"klm\""))
+ key2 = \"xyz\""))
+ ;; [[list_of_maps]]
+ ;; key1 = 123
+ ;; key2 = \"xyz\"
+ ;; [[list_of_maps]]
+ ;; key1 = 567
+ ;; key2 = \"klm\""))
out)
(dolist (el inp)
(push (tomelr-encode el) out))
diff --git a/tomelr.el b/tomelr.el
index 2c3ed32b74..f61c10db9d 100644
--- a/tomelr.el
+++ b/tomelr.el
@@ -378,13 +378,32 @@ Definition of a TOML Table Array (TTA):
- OBJECT is TTA if it is of type ((TT1) (TT2) ..) where each element is a
TOML Table (TT)."
- (when (and (not (tomelr--toml-table-p object))
- (not (stringp object))
- (mapp object)) ;Because `mapp' is non-nil for strings too
- (seq-every-p
- (lambda (elem)
- (tomelr--toml-table-p elem))
- object)))
+ (let (ttap)
+ (when (and (not (tomelr--toml-table-p object))
+ (listp object))
+ ;; (message "[tomelr--toml-table-array-p DBG] object = %S, type = %S,
len = %d"
+ ;; object (type-of object) (safe-length object))
+ (setq ttap (cond
+ ((seq-every-p
+ (lambda (elem)
+ ;; (message " [tomelr--toml-table-array-p DBG] elem =
%S, type = %S, len = %d"
+ ;; elem (type-of elem) (safe-length elem))
+ ;; (when (listp elem)
+ ;; (message " [tomelr--toml-table-array-p DBG]
sub-elem 0 = %S, type = %S, len = %d"
+ ;; (car elem) (type-of (car elem))
(safe-length (car elem))))
+ (tomelr--toml-table-p elem))
+ object)
+ t)
+ ;; Handling the case of a nested TTA.
+ ;; Example: (((a . (((b .
2))))))
+ ((and (listp (car object)) ; ((a . (((b .
2)))))
+ (listp (car (car object))) ; (a . (((b .
2))))
+ (symbolp (car (car (car object))))) ; a <- symbol
+ ;; ------(((b . 2)))----- <--
This will be a TTA.
+ (tomelr--toml-table-array-p (cdr (car (car object)))))
+ (t
+ nil))))
+ ttap))
(defun tomelr--print-array (array)
"Insert a TOML representation of ARRAY at point.
- [elpa] externals/tomelr 52dc93201d 08/84: feat: First cut -- Port json-encode from json.el to tomelr-encode, (continued)
- [elpa] externals/tomelr 52dc93201d 08/84: feat: First cut -- Port json-encode from json.el to tomelr-encode, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr 7cd15e79b8 10/84: tool(ci): Add GHA setup, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr c872e9efc1 17/84: test: Add test for integer scalar key-value pairs, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr a1f434f03a 31/84: feat: Support nested TOML tables, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr 6bbe740e52 28/84: test: Test that 'false is also considered as boolean false in TOML, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr 9c91e0dc07 18/84: test: Add test for float scalar key-value pairs, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr 96c890a68b 23/84: feat: Convert Lisp lists to TOML arrays, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr bb85106ee9 27/84: doc: Add spec for nested tables and arrays of tables, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr 1d65064ffa 20/84: feat: Recognize local date format YYYY-MM-DD, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr 2810504e84 32/84: feat: Add basic support for S-exp plists -> TOML conversion, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr 0f4e7b4f2c 47/84: fix: Better detection of nested TTA, but still wip,
ELPA Syncer <=
- [elpa] externals/tomelr cff1f8aa89 38/84: fix: Support TOML tables arrays specified as plist vector, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr 4c419bcee2 37/84: fix: Support TOML tables specified as plists, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr baf81228bc 45/84: fix: Correct the spec for nested array of tables, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr 4dda8e6be3 46/84: chore: Style edits in a test, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr 5959b90ffa 44/84: fix: Don't let TOML tables be recognized as TOML tables arrays, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr b64eb07e99 49/84: fix: Detect TT with sub-tables correctly, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr 4386d99a85 65/84: refactor(minor): Use `tomelr--toml-table-p`, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr 26f1fc2f3c 55/84: doc: Update the medley example, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr e2b313ca3b 52/84: feat: Implement everything planned in the initial spec, ELPA Syncer, 2022/05/03
- [elpa] externals/tomelr 4434ccc64b 70/84: chore: Bump version, ELPA Syncer, 2022/05/03