[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/yaml 67d86e158e 033/124: Add code documentation; remove
From: |
ELPA Syncer |
Subject: |
[elpa] externals/yaml 67d86e158e 033/124: Add code documentation; remove unused code |
Date: |
Fri, 29 Nov 2024 15:59:57 -0500 (EST) |
branch: externals/yaml
commit 67d86e158e7e9431745c0f880f2edb2d55573a9d
Author: Zachary Romero <zacromero@posteo.net>
Commit: Zachary Romero <zacromero@posteo.net>
Add code documentation; remove unused code
---
.github/workflows/test.yml | 6 +++
yaml-tests.el | 3 +-
yaml.el | 97 ++++++++++++++++++++--------------------------
3 files changed, 48 insertions(+), 58 deletions(-)
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 2595571564..996327c436 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -12,3 +12,9 @@ jobs:
- name: Run tests
run: |
emacs -Q --batch -L . -l *-tests.el -f ert-run-tests-batch-and-exit
+ - uses: purcell/setup-emacs@master
+ with:
+ version: 24.4
+ - name: Run tests
+ run: |
+ emacs -Q --batch -L . -l *-tests.el -f ert-run-tests-batch-and-exit
diff --git a/yaml-tests.el b/yaml-tests.el
index e409168d6f..2d3e0c7f4c 100644
--- a/yaml-tests.el
+++ b/yaml-tests.el
@@ -223,8 +223,7 @@ Document
;; Example 9.3 Bare Documents
;; TODO: Allow first character of bare document to be %
- ;; (should (equal (yaml-parse-string "%!PS-Adobe-2.0 # Not the first line
- ;; ")))
+ ;; (should (equal (yaml-parse-string "%!PS-Adobe-2.0 # Not the first
line\n")))
(should (equal (yaml-parse-string "---
{ matches
diff --git a/yaml.el b/yaml.el
index f1ddd24d26..ac6f84a56c 100644
--- a/yaml.el
+++ b/yaml.el
@@ -54,9 +54,12 @@ This flag is intended for development purposes.")
"c-printable"
"b-as-space"))
-(defvar yaml--parsing-input "")
-(defvar yaml--parsing-position 0)
-(defvar yaml--states nil)
+(defvar yaml--parsing-input ""
+ "The string content of the current item being processed.")
+(defvar yaml--parsing-position 0
+ "The position that the parser is currently looking at.")
+(defvar yaml--states nil
+ "Stack of parsing states.")
(defvar yaml--parsing-object-type nil)
(defvar yaml--parsing-sequence-type nil)
@@ -177,7 +180,6 @@ This flag is intended for development purposes.")
(defvar yaml--document-end-explicit nil)
(defvar yaml--tag-map nil)
(defvar yaml--tag-handle nil)
-(defvar yaml--anchor nil)
(defvar yaml--document-end nil)
(defvar yaml--cache nil)
@@ -187,7 +189,8 @@ This flag is intended for development purposes.")
(defvar yaml--root nil)
(defvar yaml--anchor-mappings nil)
-(defvar yaml--resolve-aliases nil)
+(defvar yaml--resolve-aliases nil
+ "Flag determining if the event processing should attempt to resolve
aliases.")
(defun yaml--parse-block-header (header)
"Parse the HEADER string returning chomping style and indent count."
@@ -319,10 +322,6 @@ This flag is intended for development purposes.")
(apply #'vector l))
(t l)))
-(defun yaml--add-event (e)
- "Add event E."
- nil)
-
(defun yaml--stream-start-event ()
"Create the data for a stream-start event."
'(:stream-start))
@@ -424,33 +423,33 @@ This flag is intended for development purposes.")
(setcar yaml--object-stack (reverse (car yaml--object-stack))))
(defconst yaml--grammar-events-in
- '(("l-yaml-stream" . (lambda () ;; TODO remvoe yaml--add-event
- (yaml--add-event (yaml--stream-start-event))
+ '(("l-yaml-stream" . (lambda ()
+ (yaml--stream-start-event)
(setq yaml--document-start-version nil)
(setq yaml--document-start-explicit nil)
(setq yaml--tag-map (make-hash-table))
- (yaml--add-event (yaml--document-start-event nil))))
+ (yaml--document-start-event nil)))
("c-flow-mapping" . (lambda ()
- (yaml--add-event (yaml--mapping-start-event t))))
+ (yaml--mapping-start-event t)))
("c-flow-sequence" . (lambda ()
- (yaml--add-event (yaml--sequence-start-event nil))))
+ (yaml--sequence-start-event nil)))
("l+block-mapping" . (lambda ()
- (yaml--add-event (yaml--mapping-start-event nil))))
+ (yaml--mapping-start-event nil)))
("l+block-sequence" . (lambda ()
- (yaml--add-event (yaml--sequence-start-event
nil))))
+ (yaml--sequence-start-event nil)))
("ns-l-compact-mapping" . (lambda ()
- (yaml--add-event (yaml--mapping-start-event
nil))))
+ (yaml--mapping-start-event nil)))
("ns-l-compact-sequence" . (lambda ()
- (yaml--add-event (yaml--sequence-start-event
nil))))
+ (yaml--sequence-start-event nil)))
("ns-flow-pair" . (lambda ()
- (yaml--add-event (yaml--mapping-start-event t))))))
+ (yaml--mapping-start-event t)))))
(defconst yaml--grammar-events-out
'(("c-b-block-header" . (lambda (text)
nil))
("l-yaml-stream" . (lambda (text)
(yaml--check-document-end)
- (yaml--add-event (yaml--stream-end-event))))
+ (yaml--stream-end-event)))
("ns-yaml-version" . (lambda (text)
(when yaml--document-start-version
(throw 'error "Multiple %YAML directives not
allowed."))
@@ -467,20 +466,20 @@ This flag is intended for development purposes.")
(setq yaml--document-end-explicit t))
(yaml--check-document-end)))
("c-flow-mapping" . (lambda (text)
- (yaml--add-event (yaml--mapping-end-event))))
+ (yaml--mapping-end-event)))
("c-flow-sequence" . (lambda (text)
- (yaml--add-event (yaml--sequence-end-event ))))
+ (yaml--sequence-end-event )))
("l+block-mapping" . (lambda (text)
- (yaml--add-event (yaml--mapping-end-event))))
+ (yaml--mapping-end-event)))
("l+block-sequence" . (lambda (text)
(yaml--revers-at-list)
- (yaml--add-event (yaml--sequence-end-event))))
+ (yaml--sequence-end-event)))
("ns-l-compact-mapping" . (lambda (text)
- (yaml--add-event (yaml--mapping-end-event))))
+ (yaml--mapping-end-event)))
("ns-l-compact-sequence" . (lambda (text)
- (yaml--add-event (yaml--sequence-end-event))))
+ (yaml--sequence-end-event)))
("ns-flow-pair" . (lambda (text)
- (yaml--add-event (yaml--mapping-end-event))))
+ (yaml--mapping-end-event)))
("ns-plain" . (lambda (text)
(let* ((replaced (if (and (zerop (length
yaml--state-stack))
(string-match "\\(^\\|\n\\)...$"
text))
@@ -500,7 +499,7 @@ This flag is intended for development purposes.")
" "))
replaced))
)
- (yaml--add-event (yaml--scalar-event "plain"
replaced)))))
+ (yaml--scalar-event "plain" replaced))))
("c-single-quoted" . (lambda (text)
(let* ((replaced (replace-regexp-in-string
"\\(?:[ \t]*\r?\n[ \t]*\\)"
@@ -520,7 +519,7 @@ This flag is intended for development purposes.")
(substring x 1)
"'"))
replaced)))
- (yaml--add-event (yaml--scalar-event "single"
(substring replaced 1 (1- (length replaced))))))))
+ (yaml--scalar-event "single" (substring replaced
1 (1- (length replaced)))))))
("c-double-quoted" . (lambda (text)
(let* ((replaced (replace-regexp-in-string
"\\(?:[ \t]*\r?\n[ \t]*\\)"
@@ -570,28 +569,28 @@ This flag is intended for development purposes.")
"\\"
replaced))
(replaced (substring replaced 1 (1- (length
replaced)))))
- (yaml--add-event (yaml--scalar-event "double"
replaced)))))
+ (yaml--scalar-event "double" replaced))))
("c-l+literal" . (lambda (text)
(let* ((processed-text (yaml--process-literal-text
text)))
- (yaml--add-event (yaml--scalar-event "folded"
processed-text)))))
+ (yaml--scalar-event "folded" processed-text))))
("c-l+folded" . (lambda (text)
(when (equal (car yaml--state-stack) :trail-comments)
(pop yaml--state-stack)
(let ((comment-text (pop yaml--object-stack)))
(setq text (string-trim-right text (concat
(regexp-quote comment-text) "\n*$")))))
(let* ((processed-text (yaml--process-folded-text text)))
- (yaml--add-event (yaml--scalar-event "folded"
processed-text)))))
+ (yaml--scalar-event "folded" processed-text))))
("e-scalar" . (lambda (text)
- (yaml--add-event (yaml--scalar-event "plain" "null"))))
+ (yaml--scalar-event "plain" "null")))
("c-ns-anchor-property" . (lambda (text)
(yaml--anchor-event (substring text 1))))
("c-ns-tag-property" . (lambda (text)
;; (error "not implemented: %s" text)
))
("l-trail-comments" . (lambda (text)
- (yaml--add-event (yaml--trail-comments-event
text))))
+ (yaml--trail-comments-event text)))
("c-ns-alias-node" . (lambda (text)
- (yaml--add-event (yaml--alias-event (substring text
1)))))))
+ (yaml--alias-event (substring text 1))))))
(defun yaml--walk-events (tree)
"Event walker iterates over the parse TREE and signals events based off of
the parsed rules."
@@ -682,22 +681,6 @@ This flag is intended for development purposes.")
(setq yaml--parsing-position (1+ yaml--parsing-position))
t))
-(defun yaml--run-all (&rest funcs)
- "Return list of all evaluated FUNCS if all of FUNCS pass."
- (let* ((start-pos yaml--parsing-position)
- (ress '())
- (res (catch 'break
- (while funcs
- (let ((res (funcall (car funcs))))
- (when (not res)
- (throw 'break nil))
- (setq ress (append ress (list res)))
- (setq funcs (cdr funcs))))
- ress)))
- (unless res
- (setq yaml--parsing-position start-pos))
- res))
-
(defun yaml--run-all (&rest funcs)
"Return list of all evaluated FUNCS if all of FUNCS pass."
(let* ((start-pos yaml--parsing-position)
@@ -810,7 +793,6 @@ This flag is intended for development purposes.")
(or (>= yaml--parsing-position (length yaml--parsing-input))
(and (yaml--state-curr-doc)
(yaml--start-of-line)
- ;; TODO Test this Regex
(string-match "\\^g(?:---|\\.\\.\\.\\)\\([[:blank:]]\\|$\\)"
(substring yaml--parsing-input yaml--parsing-position)))))
(defun yaml--ord (f)
@@ -957,10 +939,13 @@ value. It defaults to the symbol :false."
(length yaml--parsing-input))))
(when yaml--parse-debug (message "Parsed data: %s" (pp-to-string res)))
(yaml--walk-events res)
- (setq yaml--root nil)
- (setq yaml--resolve-aliases t)
- (yaml--walk-events res)
- yaml--root)))
+ (if (zerop (hash-table-count yaml--anchor-mappings))
+ yaml--root
+ ;; Run event processing twice to resolve aliases.
+ (setq yaml--root nil)
+ (setq yaml--resolve-aliases t)
+ (yaml--walk-events res)
+ yaml--root))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- [elpa] externals/yaml a47f5a8274 054/124: indent buffer, (continued)
- [elpa] externals/yaml a47f5a8274 054/124: indent buffer, ELPA Syncer, 2024/11/29
- [elpa] externals/yaml 164cd43d6e 087/124: Merge pull request #34 from zkry/fix-bad-anchor-map->list-conversion, ELPA Syncer, 2024/11/29
- [elpa] externals/yaml e711e774b1 074/124: Allow parsing false and/or null as nil, ELPA Syncer, 2024/11/29
- [elpa] externals/yaml 50a3a00cb8 061/124: FIX insert symbol name when not equal to :null or :false, ELPA Syncer, 2024/11/29
- [elpa] externals/yaml ee9001e091 063/124: Fix the escape character in parser (after /), ELPA Syncer, 2024/11/29
- [elpa] externals/yaml ee86566af1 114/124: Merge pull request #47 from tarsiiformes/typos, ELPA Syncer, 2024/11/29
- [elpa] externals/yaml a15b045399 010/124: Condense grammar functions to one, ELPA Syncer, 2024/11/29
- [elpa] externals/yaml 0bb76de608 009/124: Add YAML scalar conversion and type conversion, ELPA Syncer, 2024/11/29
- [elpa] externals/yaml 840be1b2b2 012/124: | blocks parse, initial wip, ELPA Syncer, 2024/11/29
- [elpa] externals/yaml 64c117d084 052/124: Fix encoding issues for nil, false, and arrays, ELPA Syncer, 2024/11/29
- [elpa] externals/yaml 67d86e158e 033/124: Add code documentation; remove unused code,
ELPA Syncer <=
- [elpa] externals/yaml 091521769e 019/124: Add readme file, ELPA Syncer, 2024/11/29
- [elpa] externals/yaml 8a3303b59e 015/124: Fix indentation bug, ELPA Syncer, 2024/11/29
- [elpa] externals/yaml 9ebddb5523 047/124: Merge pull request #5 from zkry/improve-parsing-error-message, ELPA Syncer, 2024/11/29
- [elpa] externals/yaml 0db4ab0a1e 046/124: Improve parsing error message, ELPA Syncer, 2024/11/29
- [elpa] externals/yaml e2fe7e2e57 042/124: Merge pull request #3 from zkry/add-yaml-spec-json, ELPA Syncer, 2024/11/29
- [elpa] externals/yaml 6d52649383 076/124: Fix list encoding indentation #29, ELPA Syncer, 2024/11/29
- [elpa] externals/yaml bda9a00090 058/124: return alist key as a symbol as a default, ELPA Syncer, 2024/11/29
- [elpa] externals/yaml 45aa819a4f 068/124: Add MELPA tag to README, ELPA Syncer, 2024/11/29
- [elpa] externals/yaml 37c176fc5c 086/124: Fix the anchor parse event turning maps into lists, ELPA Syncer, 2024/11/29
- [elpa] externals/yaml f546dac2a8 082/124: Initial implementation of position storage, ELPA Syncer, 2024/11/29