emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/parseclj 313fc4e630 077/185: Rename to parseclj


From: ELPA Syncer
Subject: [nongnu] elpa/parseclj 313fc4e630 077/185: Rename to parseclj
Date: Tue, 28 Dec 2021 14:05:19 -0500 (EST)

branch: elpa/parseclj
commit 313fc4e630d5db88e876d672050b98c7c6ed5418
Author: Arne Brasseur <arne@arnebrasseur.net>
Commit: Arne Brasseur <arne@arnebrasseur.net>

    Rename to parseclj
    
    (using zsh's globbing and perl's rename utility)
    sed s/clj-parse/parseclj/g -i **/*(.)
    rename 's/clj-parse/parseclj/g' **/*(.)
---
 Cask                                               |  2 +-
 DESIGN.md                                          | 46 +++++++++++-----------
 README.md                                          |  2 +-
 clj-ast.el                                         | 16 ++++----
 clj-edn.el                                         |  4 +-
 clj-parse.el => parseclj.el                        | 40 +++++++++----------
 test/clj-ast-test.el                               |  6 +--
 test/clj-edn-el-parity-test.el                     |  4 +-
 test/clj-edn-test.el                               |  8 ++--
 ...lj-parse-test-data.el => parseclj-test-data.el} |  6 +--
 test/{clj-parse-test.el => parseclj-test.el}       |  8 ++--
 11 files changed, 71 insertions(+), 71 deletions(-)

diff --git a/Cask b/Cask
index 528cd303fd..d6fa83afea 100644
--- a/Cask
+++ b/Cask
@@ -2,7 +2,7 @@
 (source melpa)
 (source lambdaisland "https://lambdaisland.github.io/elpa/";)
 
-(package-file "clj-parse.el")
+(package-file "parseclj.el")
 
 (files "clj-lex.el"
        "clj-edn.el"
diff --git a/DESIGN.md b/DESIGN.md
index e3f149f53f..86083c31d1 100644
--- a/DESIGN.md
+++ b/DESIGN.md
@@ -1,10 +1,10 @@
-# clj-parse Design Goals / Roadmap
+# parseclj Design Goals / Roadmap
 
-clj-parse is an Emacs Lisp library for parsing Clojure code and EDN data. It
+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.
 
-This documents describes the design goals for clj-parse, and as such may 
describe features which are not implemented yet.
+This documents describes the design goals for parseclj, and as such may 
describe features which are not implemented yet.
 
 ## Motivation
 
@@ -45,7 +45,7 @@ The implementation is implemented in three parts: a lexer, a 
parser, and multipl
 
 The *lexer* turns the input text, a buffer, into tokens, data structures 
representing a single syntactical unit, such as a symbol, a number, or a 
delimiter like "(", ")", "#{", or "#_".
 
-In clj-parse the lexer is a single function `clj-lex-next` which can be called 
repeatedly to get a sequence of tokens. `clj-lex-next` returns the token at 
"point" (i.e. the Emacs cursor position), and moves point to after the token.
+In parseclj the lexer is a single function `clj-lex-next` which can be called 
repeatedly to get a sequence of tokens. `clj-lex-next` returns the token at 
"point" (i.e. the Emacs cursor position), and moves point to after the token.
 
 A *token* is a association list (list of cons cells), with keys `:token-type`, 
`:form`, `:position`, and optionally `:error-type`.
 
@@ -121,9 +121,9 @@ Tokens can be recognized by the `:token-type` key, which 
must always come first
 
 ## Shift-reduce parser
 
-The parser is again a single function `clj-parse-reduce`. It is a higher order 
function, with much of the final result determined by the `reduce-leaf` and 
`reduce-node` functions passed in as arguments.
+The parser is again a single function `parseclj-reduce`. It is a higher order 
function, with much of the final result determined by the `reduce-leaf` and 
`reduce-node` functions passed in as arguments.
 
-`clj-parse-reduce` internally operates by using a stack. This stack contains 
tokens (as returned by `clj-lex-next`), and reduced values.
+`parseclj-reduce` internally operates by using a stack. This stack contains 
tokens (as returned by `clj-lex-next`), and reduced values.
 
 `reduce-leaf` is a two-argument function. It takes the current value of the 
stack, and a token, and returns an updated stack, typically by parsing the 
token to a value and pushing that value onto the stack.
 
@@ -186,7 +186,7 @@ Now the parser encounters the second closing parenthesis. 
It pops everything unt
 
 ### Dealing with parse errors
 
-`clj-parse-reduce` needs to be able to parse invalid input. Imagine analyzing 
a user's buffer while they are editing, to provide contextual help or do 
linting. Even when delimiters are unbalanced it should still be possible to get 
a "best effort" parse result. It turns out the shift-reduce approach provides 
that out of the box. The result of parsing invalid input is a stack which still 
has unreduced tokens in it.
+`parseclj-reduce` needs to be able to parse invalid input. Imagine analyzing a 
user's buffer while they are editing, to provide contextual help or do linting. 
Even when delimiters are unbalanced it should still be possible to get a "best 
effort" parse result. It turns out the shift-reduce approach provides that out 
of the box. The result of parsing invalid input is a stack which still has 
unreduced tokens in it.
 
 Unmatched opening delimiter:
 
@@ -248,7 +248,7 @@ These are the choices that the edn.el library has made:
 
 ### Differences with EDN.el
 
-At the moment the `clj-parse-edn-*` 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.
+At the moment the `parseclj-edn-*` 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
 
@@ -274,7 +274,7 @@ Non-leaf nodes contain a list of `:children`.
 
 ## Public API
 
-clj-parse provides three "parse modes"
+parseclj provides three "parse modes"
 
 - `edn` meant for parsing data, it parses EDN to emacs lisp data
 - `ast` meant for analyzing source code, parses to a "semantic" AST, does not 
preserve whitespace or comments
@@ -282,30 +282,30 @@ clj-parse provides three "parse modes"
 
 For each of these there can be the following functions
 
-- `clj-parse-{mode}` parse the current buffer starting at `point`, raise an 
error when syntax/lexing errors are encountered
-- `clj-parse-{mode}-full` same as above but ignore syntax errors, returning a 
partially parsed result
+- `parseclj-{mode}` parse the current buffer starting at `point`, raise an 
error when syntax/lexing errors are encountered
+- `parseclj-{mode}-full` same as above but ignore syntax errors, returning a 
partially parsed result
 - `clj-print-{mode}` turn the result of the corresponding parse function back 
into Clojure/EDN, and insert it into the current buffer
 
 Each of these have `-str` variant which instead works on strings. This yields 
a total potential API of:
 
 ```
-(defun clj-parse-edn (&OPTIONAL tag-handler))
-(defun clj-parse-edn-full (&OPTIONAL tag-handler))
+(defun parseclj-edn (&OPTIONAL tag-handler))
+(defun parseclj-edn-full (&OPTIONAL tag-handler))
 (defun clj-print-edn (edn))
-(defun clj-parse-edn-str (string &OPTIONAL tag-handler))
-(defun clj-parse-edn-full-str (string &OPTIONAL tag-handler))
+(defun parseclj-edn-str (string &OPTIONAL tag-handler))
+(defun parseclj-edn-full-str (string &OPTIONAL tag-handler))
 (defun clj-print-edn-str (edn))
-(defun clj-parse-ast ())
-(defun clj-parse-ast-full ())
+(defun parseclj-ast ())
+(defun parseclj-ast-full ())
 (defun clj-print-ast (node))
-(defun clj-parse-ast-str ())
-(defun clj-parse-ast-full-str ())
+(defun parseclj-ast-str ())
+(defun parseclj-ast-full-str ())
 (defun clj-print-ast-str (node))
-(defun clj-parse-source ())
-(defun clj-parse-source-full ())
+(defun parseclj-source ())
+(defun parseclj-source-full ())
 (defun clj-print-source (node))
-(defun clj-parse-source-str ())
-(defun clj-parse-source-full-str ())
+(defun parseclj-source-str ())
+(defun parseclj-source-full-str ())
 (defun clj-print-source-str (node))
 ```
 
diff --git a/README.md b/README.md
index 124801fd07..83026d14f6 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-[![Build 
Status](https://travis-ci.org/lambdaisland/clj-parse.svg?branch=master)](https://travis-ci.org/lambdaisland/clj-parse)
+[![Build 
Status](https://travis-ci.org/lambdaisland/parseclj.svg?branch=master)](https://travis-ci.org/lambdaisland/parseclj)
 
 # EDN reader and Clojure parser for Emacs Lisp
 
diff --git a/clj-ast.el b/clj-ast.el
index c295d316e6..21c86dfabc 100644
--- a/clj-ast.el
+++ b/clj-ast.el
@@ -30,16 +30,16 @@
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;; Parser
 
-(defun clj-parse--make-node (type position &rest kvs)
+(defun parseclj--make-node (type position &rest kvs)
   (apply 'a-list ':node-type type ':position position kvs))
 
 (defun clj-ast--reduce-leaf (stack token)
   (if (eq (clj-lex-token-type token) :whitespace)
       stack
     (cons
-     (clj-parse--make-node (clj-lex-token-type token) (a-get token 'pos)
+     (parseclj--make-node (clj-lex-token-type token) (a-get token 'pos)
                            ':form (a-get token 'form)
-                           ':value (clj-parse--leaf-token-value token))
+                           ':value (parseclj--leaf-token-value token))
      stack)))
 
 (defun clj-ast--reduce-node (stack opener-token children)
@@ -51,14 +51,14 @@
                  (:lbrace :map)
                  (t type))))
     (cl-case type
-      (:root (clj-parse--make-node :root 0 :children children))
+      (:root (parseclj--make-node :root 0 :children children))
       (:discard stack)
-      (:tag (list (clj-parse--make-node :tag
+      (:tag (list (parseclj--make-node :tag
                                         pos
                                         :tag (intern (substring (a-get 
opener-token 'form) 1))
                                         :children children)))
       (t (cons
-          (clj-parse--make-node type pos :children children)
+          (parseclj--make-node type pos :children children)
           stack)))))
 
 (defun clj-ast-parse ()
@@ -66,7 +66,7 @@
 
 Parses code in the current buffer, starting from the current
 position of (point)."
-  (clj-parse-reduce #'clj-ast--reduce-leaf #'clj-ast--reduce-node))
+  (parseclj-reduce #'clj-ast--reduce-leaf #'clj-ast--reduce-node))
 
 (defun clj-ast-parse-str (s)
   "Parse Clojure code in string S to AST."
@@ -95,7 +95,7 @@ position of (point)."
     (clj-ast-unparse (car (a-get node :children)))))
 
 (defun clj-ast-unparse (node)
-  (if (clj-parse--is-leaf? node)
+  (if (parseclj--is-leaf? node)
       (insert (alist-get ':form node))
     (let ((subnodes (alist-get ':children node)))
       (cl-case (a-get node ':node-type)
diff --git a/clj-edn.el b/clj-edn.el
index d509c6c4b0..4d0f09b1b5 100644
--- a/clj-edn.el
+++ b/clj-edn.el
@@ -44,7 +44,7 @@ handlers as an optional argument to the reader functions.")
 (defun clj-edn-reduce-leaf (stack token)
   (if (member (clj-lex-token-type token) (list :whitespace :comment))
       stack
-    (cons (clj-parse--leaf-token-value token) stack)))
+    (cons (parseclj--leaf-token-value token) stack)))
 
 (defun clj-edn-reduce-node (tag-readers)
   (lambda (stack opener-token children)
@@ -70,7 +70,7 @@ handlers as an optional argument to the reader functions.")
          stack)))))
 
 (defun clj-edn-read (&optional tag-readers)
-  (clj-parse-reduce #'clj-edn-reduce-leaf
+  (parseclj-reduce #'clj-edn-reduce-leaf
                     (clj-edn-reduce-node (a-merge clj-edn-default-tag-readers 
tag-readers))))
 
 (defun clj-edn-read-str (s &optional tag-readers)
diff --git a/clj-parse.el b/parseclj.el
similarity index 82%
rename from clj-parse.el
rename to parseclj.el
index cfccdb59f8..1291528ae2 100644
--- a/clj-parse.el
+++ b/parseclj.el
@@ -1,4 +1,4 @@
-;;; clj-parse.el --- Clojure/EDN parser              -*- lexical-binding: t; 
-*-
+;;; parseclj.el --- Clojure/EDN parser              -*- lexical-binding: t; -*-
 
 ;; Copyright (C) 2017  Arne Brasseur
 
@@ -37,7 +37,7 @@
 (require 'clj-edn)
 (require 'clj-ast)
 
-(defvar clj-parse--leaf-tokens '(:whitespace
+(defvar parseclj--leaf-tokens '(:whitespace
                                  :comment
                                  :number
                                  :nil
@@ -49,15 +49,15 @@
                                  :character)
   "Tokens that represent leaf nodes in the AST.")
 
-(defvar clj-parse--closer-tokens '(:rparen
+(defvar parseclj--closer-tokens '(:rparen
                                    :rbracket
                                    :rbrace)
   "Tokens that represent closing of an AST branch.")
 
-(defun clj-parse--is-leaf? (node)
-  (member (a-get node ':node-type) clj-parse--leaf-tokens))
+(defun parseclj--is-leaf? (node)
+  (member (a-get node ':node-type) parseclj--leaf-tokens))
 
-(defun clj-parse--is-open-prefix? (el)
+(defun parseclj--is-open-prefix? (el)
   (and (member (clj-lex-token-type el) '(:discard :tag))
        (clj-lex-token? el)))
 
@@ -68,7 +68,7 @@
 ;;
 ;; Note that this is kind of broken, we don't correctly detect if \u or \o 
forms
 ;; don't have the right forms.
-(defun clj-parse--string (s)
+(defun parseclj--string (s)
   (replace-regexp-in-string
    "\\\\o[0-8]\\{3\\}"
    (lambda (x)
@@ -89,7 +89,7 @@
                                   (t (substring x 1))))
                               (substring s 1 -1)))))
 
-(defun clj-parse--character (c)
+(defun parseclj--character (c)
   (let ((first-char (elt c 1)))
     (cond
      ((equal c "\\newline") ?\n)
@@ -100,7 +100,7 @@
      ((eq first-char ?o) (string-to-number (substring c 2) 8))
      (t first-char))))
 
-(defun clj-parse--leaf-token-value (token)
+(defun parseclj--leaf-token-value (token)
   (cl-case (clj-lex-token-type token)
     (:number (string-to-number (alist-get 'form token)))
     (:nil nil)
@@ -108,22 +108,22 @@
     (:false nil)
     (:symbol (intern (alist-get 'form token)))
     (:keyword (intern (alist-get 'form token)))
-    (:string (clj-parse--string (alist-get 'form token)))
-    (:character (clj-parse--character (alist-get 'form token)))))
+    (:string (parseclj--string (alist-get 'form token)))
+    (:character (parseclj--character (alist-get 'form token)))))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;; Shift-Reduce Parser
 
-(defun clj-parse--find-opener (stack closer-token)
+(defun parseclj--find-opener (stack closer-token)
   (cl-case (clj-lex-token-type closer-token)
     (:rparen :lparen)
     (:rbracket :lbracket)
     (:rbrace (clj-lex-token-type
               (seq-find (lambda (token) (member (clj-lex-token-type token) 
'(:lbrace :set))) stack)))))
 
-(defun clj-parse--reduce-coll (stack closer-token reduceN)
+(defun parseclj--reduce-coll (stack closer-token reduceN)
   "Reduce collection based on the top of the stack"
-  (let ((opener-type (clj-parse--find-opener stack closer-token))
+  (let ((opener-type (parseclj--find-opener stack closer-token))
         (coll nil))
     (while (and stack
                 (not (eq (clj-lex-token-type (car stack)) opener-type)))
@@ -137,7 +137,7 @@
         (message "STACK: %S , CLOSER: %S" stack closer-token)
         (error "Syntax Error")))))
 
-(defun clj-parse-reduce (reduce-leaf reduce-node)
+(defun parseclj-reduce (reduce-leaf reduce-node)
   (let ((stack nil))
 
     (while (not (eq (clj-lex-token-type (setq token (clj-lex-next))) :eof))
@@ -147,13 +147,13 @@
       ;; Reduce based on the top item on the stack (collections)
       (let ((token-type (clj-lex-token-type token)))
         (cond
-         ((member token-type clj-parse--leaf-tokens) (setf stack (funcall 
reduce-leaf stack token)))
-         ((member token-type clj-parse--closer-tokens) (setf stack 
(clj-parse--reduce-coll stack token reduce-node)))
+         ((member token-type parseclj--leaf-tokens) (setf stack (funcall 
reduce-leaf stack token)))
+         ((member token-type parseclj--closer-tokens) (setf stack 
(parseclj--reduce-coll stack token reduce-node)))
          (t (push token stack))))
 
       ;; Reduce based on top two items on the stack (special prefixed elements)
       (seq-let [top lookup] stack
-        (when (and (clj-parse--is-open-prefix? lookup)
+        (when (and (parseclj--is-open-prefix? lookup)
                    (not (clj-lex-token? top))) ;; top is fully reduced
             (setf stack (funcall reduce-node (cddr stack) lookup (list 
top))))))
 
@@ -163,6 +163,6 @@
     stack))
 
 
-(provide 'clj-parse)
+(provide 'parseclj)
 
-;;; clj-parse.el ends here
+;;; parseclj.el ends here
diff --git a/test/clj-ast-test.el b/test/clj-ast-test.el
index 5b383da516..d825d180bd 100644
--- a/test/clj-ast-test.el
+++ b/test/clj-ast-test.el
@@ -30,7 +30,7 @@
 (require 'ert)
 (require 'clj-ast)
 
-(load "test/clj-parse-test-data.el")
+(load "test/parseclj-test-data.el")
 
 (defmacro define-clj-ast-parse-tests ()
   `(progn
@@ -46,7 +46,7 @@
                        (insert ,(a-get data :source))
                        (goto-char 1)
                        (should (a-equal (clj-ast-parse) ',(a-get data 
:ast)))))))))
-        clj-parse-test-data)))
+        parseclj-test-data)))
 
 (defmacro define-clj-ast-roundtrip-tests ()
   `(progn
@@ -59,7 +59,7 @@
                   `(ert-deftest ,test-name ()
                      :tags '(clj-ast-rountrip)
                      (should (a-equal (clj-ast-parse-str (clj-ast-unparse-str 
',(a-get data :ast))) ',(a-get data :ast))))))))
-        clj-parse-test-data)))
+        parseclj-test-data)))
 
 
 (define-clj-ast-roundtrip-tests)
diff --git a/test/clj-edn-el-parity-test.el b/test/clj-edn-el-parity-test.el
index bae4d41609..ea5243627d 100644
--- a/test/clj-edn-el-parity-test.el
+++ b/test/clj-edn-el-parity-test.el
@@ -24,13 +24,13 @@
 ;;; Commentary:
 
 ;; These tests are copied verbatim from the edn.el source, and adapted to use
-;; our API. This way we assure that clj-parse can act as a drop-in replacement
+;; our API. This way we assure that parseclj can act as a drop-in replacement
 ;; for edn.el.
 
 ;;; Code:
 
 (require 'ert)
-(require 'clj-parse)
+(require 'parseclj)
 (eval-when-compile (require 'subr-x)) ;; for things like hash-table-keys
 
 (ert-deftest whitespace ()
diff --git a/test/clj-edn-test.el b/test/clj-edn-test.el
index 310b1324fa..dba7e7fb95 100644
--- a/test/clj-edn-test.el
+++ b/test/clj-edn-test.el
@@ -28,9 +28,9 @@
 ;;; Code
 
 (require 'ert)
-(require 'clj-parse)
+(require 'parseclj)
 
-(load "test/clj-parse-test-data.el")
+(load "test/parseclj-test-data.el")
 
 (ert-deftest clj-edn-print-test ()
   (should (equal (clj-edn-print-str nil) "nil"))
@@ -56,7 +56,7 @@
                        (insert ,(a-get data :source))
                        (goto-char 1)
                        (should (a-equal (clj-edn-read) ',(a-get data 
:edn)))))))))
-        clj-parse-test-data)))
+        parseclj-test-data)))
 
 (defmacro define-clj-edn-roundtrip-tests ()
   `(progn
@@ -69,7 +69,7 @@
                   `(ert-deftest ,test-name ()
                      :tags '(clj-edn-rountrip)
                      (should (equal (clj-edn-print-str (car ',(a-get data 
:edn))) ,(a-get data :source))))))))
-        clj-parse-test-data)))
+        parseclj-test-data)))
 
 (define-clj-edn-read-tests)
 (define-clj-edn-roundtrip-tests)
diff --git a/test/clj-parse-test-data.el b/test/parseclj-test-data.el
similarity index 98%
rename from test/clj-parse-test-data.el
rename to test/parseclj-test-data.el
index d6f5645d9d..a584b350d4 100644
--- a/test/clj-parse-test-data.el
+++ b/test/parseclj-test-data.el
@@ -1,4 +1,4 @@
-;;; clj-parse-test-data.el --- Clojure/EDN parser - test data
+;;; parseclj-test-data.el --- Clojure/EDN parser - test data
 
 ;; Copyright (C) 2017  Arne Brasseur
 
@@ -27,7 +27,7 @@
 
 ;;; Code:
 
-(setq clj-parse-test-data
+(setq parseclj-test-data
   (a-list
 
    "simple-list"
@@ -295,4 +295,4 @@
     :source "[nil true false]"
     :edn '([nil t nil]))))
 
-;;; clj-parse-test-data.el ends here
+;;; parseclj-test-data.el ends here
diff --git a/test/clj-parse-test.el b/test/parseclj-test.el
similarity index 89%
rename from test/clj-parse-test.el
rename to test/parseclj-test.el
index 172664cfb1..a20695a803 100644
--- a/test/clj-parse-test.el
+++ b/test/parseclj-test.el
@@ -1,4 +1,4 @@
-;;; clj-parse-test.el --- Clojure/EDN parser - tests
+;;; parseclj-test.el --- Clojure/EDN parser - tests
 
 ;; Copyright (C) 2017  Arne Brasseur
 
@@ -28,11 +28,11 @@
 ;;; Code:
 
 (require 'ert)
-(require 'clj-parse)
+(require 'parseclj)
 
 ;; needs testing of individual functions. all testing now is at the top level
 ;; through parse/unparse
 
-(provide 'clj-parse-test)
+(provide 'parseclj-test)
 
-;;; clj-parse-test.el ends here
+;;; parseclj-test.el ends here



reply via email to

[Prev in Thread] Current Thread [Next in Thread]