[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/parseclj 61577603f2 136/185: Update README.md with install
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/parseclj 61577603f2 136/185: Update README.md with installation and usage information |
Date: |
Tue, 28 Dec 2021 14:05:29 -0500 (EST) |
branch: elpa/parseclj
commit 61577603f2187804a436bf16bc22a0e531e89034
Author: Daniel Barreto <daniel.barreto.n@gmail.com>
Commit: Daniel Barreto <daniel.barreto.n@gmail.com>
Update README.md with installation and usage information
---
README.md | 125 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++----
parseclj.el | 4 +-
2 files changed, 120 insertions(+), 9 deletions(-)
diff --git a/README.md b/README.md
index 7d095555a9..1b930c937e 100644
--- a/README.md
+++ b/README.md
@@ -2,24 +2,135 @@
# EDN reader and Clojure parser for Emacs Lisp
-`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.
Take a look at the [design document](DESIGN.md) for more details.
-`parseclj` is in **alpha** state right now.
+`parseclj` is in **alpha** state right now, its API might be subject to change.
## Installation
-TODO
+Currently `parseclj` is not part of [MELPA](http://melpa.milkbox.net/), so
+the best way to install it is by getting your own copy of the `parseclj` repo
+and putting it somewhere in your Emacs
+[`load-path`](https://www.emacswiki.org/emacs/LoadPath).
+
+You can just copy-paste this code into your Emacs init file:
+
+```emacs-lisp
+(add-to-list 'load-path "/path/to/your/copy/of/parseclj/")
+```
## Usage
-TODO
+`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:
+
+``` emacs-lisp
+((:node-type . :root)
+ (:position . 1)
+ (:children ((:node-type . :list)
+ (:position . 1)
+ (:children ((:node-type . :number)
+ (:position . 2)
+ (:form . "1")
+ (:value . 1))
+ ((:node-type . :number)
+ (:position . 4)
+ (:form . "2")
+ (:value . 2))
+ ((:node-type . :vector)
+ (:position . 6)
+ (:children ((:node-type . :keyword)
+ (:position . 7)
+ (:form . ":a")
+ (:value . :a))
+ ((:node-type . :keyword)
+ (:position . 10)
+ (:form . ":b")
+ (:value . :b))
+ ((:node-type . :keyword)
+ (:position . 13)
+ (:form . ":c")
+ (:value . :c))))))))
+```
+
+In order to use any of them, you first need to require it:
+
+```emacs-lisp
+(require 'parseclj)
+;; or...
+(require 'parseedn)
+```
+
+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.
+ When given a string as a first argument, parses it and returns the
+ corresponding AST.
+
+ A list of options can be passed down to the parsing process, particularly:
+ * `:lexical-preservation`: a boolean value to retain whitespace, comments,
+ and discards. Defaults to nil.
+ * `:fail-fast`: a boolean value to raise an error when encountering invalid
+ syntax. Defaults to t.
+
+ Examples:
+
+ ```emacs-lisp
+ (parseclj-parse-clojure) ;; will parse clojure code in the current buffer
and return an AST
+ (parseclj-parse-clojure "(1 2 3)") ;; => ((:node-type . :root) ... )
+ (parseclj-parse-clojure :lexical-preservation t) ;; will parse clojure code
in current buffer preserving whitespaces, comments and discards
+ ```
+
+ > Note: there's an open issue to extend this API to [parse clojure code
within
+ > some boundaries of a
+ > buffer](https://github.com/clojure-emacs/parseclj/issues/13). Pull
requests
+ > are welcome.
+
+- `parseclj-unparse-clojure` ast
+
+ Transform the given AST into Clojure source code and inserts it into the
+ current buffer.
+
+- `parseclj-unparse-clojure-to-string` ast
+
+ 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
© 2017-2018 Arne Brasseur
-Distributed under the terms of the GNU General Public License 3.0 or later.
See LICENSE.
+Distributed under the terms of the GNU General Public License 3.0 or later. See
+[LICENSE](LICENSE).
diff --git a/parseclj.el b/parseclj.el
index b12695af26..b56b629240 100644
--- a/parseclj.el
+++ b/parseclj.el
@@ -44,8 +44,8 @@ key-value pairs to specify parsing options.
- `:lexical-preservation' Retain whitespace, comments, and
discards. Defaults to nil.
-- `:fail-fast' Raise an error
- when encountering invalid syntax. Defaults to t."
+- `:fail-fast' Raise an error when encountering invalid syntax.
+ Defaults to t."
(if (stringp (car string-and-options))
(with-temp-buffer
(insert (car string-and-options))
- [nongnu] elpa/parseclj 0f16fcf2fa 084/185: Implement parsing with lexical preservation (keep whitespace, comments), (continued)
- [nongnu] elpa/parseclj 0f16fcf2fa 084/185: Implement parsing with lexical preservation (keep whitespace, comments), ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj ca854455f6 099/185: Add missing requirement to `parseedn`, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj adbc0cabf5 100/185: Move `parseclj--{leaf, closing}-tokens` to `parseclj-lex` module, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 7794d9ee59 101/185: Add docstrings for `parseclj-lex` module, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 296a093132 102/185: Remove `parseclj-unparse`, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj d6525d30c6 111/185: Merge pull request #10 from lambdaisland/fix-ast-reduce-tag, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 0ef32ad912 120/185: Add support for having single quotes in symbols/keywords, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 0afb8c5f09 123/185: Add `parseclj-lex-error-token` helper, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj b2588ce0fb 126/185: Use EVM to setup Travis CI, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 46cfcd3120 129/185: Merge pull request #16 from lambdaisland/parseclj-lex-error-token, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 61577603f2 136/185: Update README.md with installation and usage information,
ELPA Syncer <=
- [nongnu] elpa/parseclj a82f229014 139/185: Ignore *.elc files, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 7fba1624e0 142/185: Update DESIGN.md to name difference between parseclj and parseedn, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 3693dd148f 145/185: Fix Cask file, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj af6102c4a8 146/185: Minor fix to README file, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 91c2ad82af 147/185: Add enough feature to be able to parse clojure.core, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj b40670a561 149/185: Add namespaced maps, fix backquote implementation, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj ff0443c27c 151/185: Add :read-one option, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 40e36c41eb 006/185: alist-get was only introduced in 25.1? :sadpanda:, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 6f36bbf6b4 009/185: Try to set up a build matrix, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj d4286f9071 010/185: Give README the right extension, ELPA Syncer, 2021/12/28