branch: elpa/parseclj
commit da4bacb5f5d74b914f853450539ddf5a4bb06642
Author: Arne Brasseur <[email protected]>
Commit: Arne Brasseur <[email protected]>
Rename parseclj-reduce to parseclj-parse
---
DESIGN.md | 8 ++++----
clj-ast.el | 2 +-
clj-edn.el | 2 +-
parseclj.el | 2 +-
4 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/DESIGN.md b/DESIGN.md
index 86083c31d1..b90ae0e577 100644
--- a/DESIGN.md
+++ b/DESIGN.md
@@ -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 `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.
+The parser is again a single function `parseclj-parse`. 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.
-`parseclj-reduce` internally operates by using a stack. This stack contains
tokens (as returned by `clj-lex-next`), and reduced values.
+`parseclj-parse` 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
-`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.
+`parseclj-parse` 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:
@@ -421,7 +421,7 @@ of the newly created node.
This implementation handles `:discard' nodes (#_), for other node
types it delegates to `parseclj-ast--reduce-branch'.")
-(defun parse-clj-ast-value (node)
+(defun parseclj-ast-value (node)
"Given an AST NODE, returns its value.
Recursively convert the AST node into an Emacs Lisp value. E.g.
diff --git a/clj-ast.el b/clj-ast.el
index 21c86dfabc..7b56d3ec99 100644
--- a/clj-ast.el
+++ b/clj-ast.el
@@ -66,7 +66,7 @@
Parses code in the current buffer, starting from the current
position of (point)."
- (parseclj-reduce #'clj-ast--reduce-leaf #'clj-ast--reduce-node))
+ (parseclj-parse #'clj-ast--reduce-leaf #'clj-ast--reduce-node))
(defun clj-ast-parse-str (s)
"Parse Clojure code in string S to AST."
diff --git a/clj-edn.el b/clj-edn.el
index 4d0f09b1b5..49a8730a09 100644
--- a/clj-edn.el
+++ b/clj-edn.el
@@ -70,7 +70,7 @@ handlers as an optional argument to the reader functions.")
stack)))))
(defun clj-edn-read (&optional tag-readers)
- (parseclj-reduce #'clj-edn-reduce-leaf
+ (parseclj-parse #'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/parseclj.el b/parseclj.el
index 1291528ae2..3b42ab20f8 100644
--- a/parseclj.el
+++ b/parseclj.el
@@ -137,7 +137,7 @@
(message "STACK: %S , CLOSER: %S" stack closer-token)
(error "Syntax Error")))))
-(defun parseclj-reduce (reduce-leaf reduce-node)
+(defun parseclj-parse (reduce-leaf reduce-node)
(let ((stack nil))
(while (not (eq (clj-lex-token-type (setq token (clj-lex-next))) :eof))