[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/parseclj 1b071d7775 104/185: Add documentation to `parseed
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/parseclj 1b071d7775 104/185: Add documentation to `parseedn` module |
Date: |
Tue, 28 Dec 2021 14:05:25 -0500 (EST) |
branch: elpa/parseclj
commit 1b071d7775eb1f972265c2bc13374d1fdf57476d
Author: Daniel Barreto <daniel.barreto.n@gmail.com>
Commit: Daniel Barreto <daniel.barreto.n@gmail.com>
Add documentation to `parseedn` module
---
parseedn.el | 39 ++++++++++++++++++++++++++++++++++++---
1 file changed, 36 insertions(+), 3 deletions(-)
diff --git a/parseedn.el b/parseedn.el
index e98cee19aa..a225b1635f 100644
--- a/parseedn.el
+++ b/parseedn.el
@@ -36,8 +36,10 @@
;; don't have the right forms.
(require 'a)
+(require 'parseclj-lex)
(defun parseedn--string (s)
+ ""
(replace-regexp-in-string
"\\\\o[0-8]\\{3\\}"
(lambda (x)
@@ -59,6 +61,7 @@
(substring s 1 -1)))))
(defun parseedn--character (c)
+ "Parse a EDN character C into an Emacs Lisp character."
(let ((first-char (elt c 1)))
(cond
((equal c "\\newline") ?\n)
@@ -90,17 +93,30 @@
'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
+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
+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 (parseedn--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)
@@ -125,21 +141,33 @@ handlers as an optional argument to the reader
functions.")
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-parse #'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))
@@ -147,6 +175,7 @@ handlers as an optional argument to the reader functions.")
(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 " ")
@@ -157,6 +186,8 @@ handlers as an optional argument to the reader functions.")
(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)))
@@ -192,6 +223,8 @@ handlers as an optional argument to the reader functions.")
(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))))
- [nongnu] elpa/parseclj 3d261f5d3c 072/185: Bump version of a, (continued)
- [nongnu] elpa/parseclj 3d261f5d3c 072/185: Bump version of a, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 47cf208a91 091/185: Fix parsing of tags/discard with :lexical-preservation, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj da4bacb5f5 078/185: Rename parseclj-reduce to parseclj-parse, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 2a42dcb6fa 066/185: Update License info in README, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj ba9f4d723f 076/185: Document proposal for alternative package organization, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj a8e1de0d62 075/185: Merge pull request #4 from lambdaisland/edn-ast-split, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 6fdf22a553 062/185: Update license, fix dependencies, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 5fbe901cba 071/185: Parse/unparse :tag, rountrip AST, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 6e0dc9516c 093/185: Add missing require, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj b79b3a5438 098/185: Add documentation to `parseclj-ast.el`, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 1b071d7775 104/185: Add documentation to `parseedn` module,
ELPA Syncer <=
- [nongnu] elpa/parseclj e1cb9e5514 113/185: Add a few more node accessors., ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 80e92cdf9f 001/185: Move into its own repo, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 2588470302 116/185: Merge pull request #9 from lambdaisland/docstrings-and-conventions, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 92396d11cf 127/185: Merge pull request #17 from lambdaisland/travis-evm, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj f87278a70e 135/185: Merge pull request #18 from clojure-emacs/doc-&-style-fixes-part-2, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj eedc0d812e 168/185: Update docstring and metion Emacs 27 alternative, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 815ba87a77 137/185: Merge pull request #19 from clojure-emacs/update-readme, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 9e0b51e39c 160/185: revert tabs to spaces, address minor review comments, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj bdd6489128 003/185: add travis badge, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj f6b8ad665c 004/185: Fix .travis.yml, ELPA Syncer, 2021/12/28