[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/peg 2fa278b: * peg.el (merge-error): Don't use add-to-l
From: |
Stefan Monnier |
Subject: |
[elpa] externals/peg 2fa278b: * peg.el (merge-error): Don't use add-to-list on a local var |
Date: |
Sun, 10 Mar 2019 18:20:20 -0400 (EDT) |
branch: externals/peg
commit 2fa278b595bbad3e40862d2a6786937bf93dc2a0
Author: Stefan Monnier <address@hidden>
Commit: Stefan Monnier <address@hidden>
* peg.el (merge-error): Don't use add-to-list on a local var
Fix remaining uses of `cl` and some compiler warnings
---
.gitignore | 3 +
peg.el | 186 ++++++++++++++++++++++++++++++++-----------------------------
2 files changed, 100 insertions(+), 89 deletions(-)
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..9f246e4
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,3 @@
+*.elc
+peg-autoloads.el
+peg-pkg.el
diff --git a/peg.el b/peg.el
index 2d3773f..8f238f1 100644
--- a/peg.el
+++ b/peg.el
@@ -609,24 +609,24 @@ input. PATH is the list of rules that we have visited so
far."
(peg-detect-cycles exp path)
t)
-(peg-add-method detect-cycles any (path) nil)
-(peg-add-method detect-cycles char (path c) nil)
-(peg-add-method detect-cycles set (path r c k) nil)
-(peg-add-method detect-cycles range (path c1 c2) nil)
-(peg-add-method detect-cycles str (path s) (equal s ""))
-(peg-add-method detect-cycles null (path) t)
-(peg-add-method detect-cycles fail (path) nil)
-(peg-add-method detect-cycles bob (path) t)
-(peg-add-method detect-cycles eob (path) t)
-(peg-add-method detect-cycles bol (path) t)
-(peg-add-method detect-cycles eol (path) t)
-(peg-add-method detect-cycles bow (path) t)
-(peg-add-method detect-cycles eow (path) t)
-(peg-add-method detect-cycles bos (path) t)
-(peg-add-method detect-cycles eos (path) t)
-(peg-add-method detect-cycles = (path s) nil)
-(peg-add-method detect-cycles syntax-class (p n) nil)
-(peg-add-method detect-cycles action (path form) t)
+(peg-add-method detect-cycles any (_path) nil)
+(peg-add-method detect-cycles char (_path _c) nil)
+(peg-add-method detect-cycles set (_path _r _c _k) nil)
+(peg-add-method detect-cycles range (_path _c1 _c2) nil)
+(peg-add-method detect-cycles str (_path s) (equal s ""))
+(peg-add-method detect-cycles null (_path) t)
+(peg-add-method detect-cycles fail (_path) nil)
+(peg-add-method detect-cycles bob (_path) t)
+(peg-add-method detect-cycles eob (_path) t)
+(peg-add-method detect-cycles bol (_path) t)
+(peg-add-method detect-cycles eol (_path) t)
+(peg-add-method detect-cycles bow (_path) t)
+(peg-add-method detect-cycles eow (_path) t)
+(peg-add-method detect-cycles bos (_path) t)
+(peg-add-method detect-cycles eos (_path) t)
+(peg-add-method detect-cycles = (_path _s) nil)
+(peg-add-method detect-cycles syntax-class (_p _n) nil)
+(peg-add-method detect-cycles action (_path _form) t)
(peg-define-method-table merge-error)
@@ -649,28 +649,35 @@ input. PATH is the list of rules that we have visited so
far."
(peg-merge-error e1 merged))
(peg-add-method merge-error str (merged str)
- (add-to-list 'merged str))
+ ;;(add-to-list 'merged str)
+ (cl-adjoin str merged :test #'equal))
(peg-add-method merge-error call (merged rule)
- (add-to-list 'merged rule))
+ ;; (add-to-list 'merged rule)
+ (cl-adjoin rule merged :test #'equal))
(peg-add-method merge-error char (merged char)
- (add-to-list 'merged (string char)))
+ ;; (add-to-list 'merged (string char))
+ (cl-adjoin (string char) merged :test #'equal))
(peg-add-method merge-error set (merged r c k)
- (add-to-list 'merged (peg-make-charset-regexp r c k)))
+ ;; (add-to-list 'merged (peg-make-charset-regexp r c k))
+ (cl-adjoin (peg-make-charset-regexp r c k) merged :test #'equal))
(peg-add-method merge-error range (merged from to)
- (add-to-list 'merged (format "[%c-%c]" from to)))
+ ;; (add-to-list 'merged (format "[%c-%c]" from to))
+ (cl-adjoin (format "[%c-%c]" from to) merged :test #'equal))
(peg-add-method merge-error * (merged exp)
(peg-merge-error exp merged))
(peg-add-method merge-error any (merged)
- (add-to-list 'merged '(any)))
+ ;; (add-to-list 'merged '(any))
+ (cl-adjoin '(any) merged :test #'equal))
(peg-add-method merge-error not (merged x)
- (add-to-list 'merged `(not ,x)))
+ ;; (add-to-list 'merged `(not ,x))
+ (cl-adjoin `(not ,x) merged :test #'equal))
(peg-add-method merge-error action (merged _) merged)
(peg-add-method merge-error null (merged) merged)
@@ -699,83 +706,85 @@ resp. succeded instead of signaling an error."
(defun peg-test ()
(interactive)
- (assert (peg-parse-string ((s "a")) "a" t))
- (assert (not (peg-parse-string ((s "a")) "b" t)))
- (assert (peg-parse-string ((s (not "a"))) "b" t))
- (assert (not (peg-parse-string ((s (not "a"))) "a" t)))
- (assert (peg-parse-string ((s (if "a"))) "a" t))
- (assert (not (peg-parse-string ((s (if "a"))) "b" t)))
- (assert (peg-parse-string ((s "ab")) "ab" t))
- (assert (not (peg-parse-string ((s "ab")) "ba" t)))
- (assert (not (peg-parse-string ((s "ab")) "a" t)))
- (assert (peg-parse-string ((s (range ?0 ?9))) "0" t))
- (assert (not (peg-parse-string ((s (range ?0 ?9))) "a" t)))
- (assert (peg-parse-string ((s [0-9])) "0" t))
- (assert (not (peg-parse-string ((s [0-9])) "a" t)))
- (assert (not (peg-parse-string ((s [0-9])) "" t)))
- (assert (peg-parse-string ((s (any))) "0" t))
- (assert (not (peg-parse-string ((s (any))) "" t)))
- (assert (peg-parse-string ((s (eob))) "" t))
- (assert (peg-parse-string ((s (not (eob)))) "a" t))
- (assert (peg-parse-string ((s (or "a" "b"))) "a" t))
- (assert (peg-parse-string ((s (or "a" "b"))) "b" t))
- (assert (not (peg-parse-string ((s (or "a" "b"))) "c" t)))
- (assert (peg-parse-string ((s (and "a" "b"))) "ab" t))
- (assert (peg-parse-string ((s (and "a" "b"))) "abc" t))
- (assert (not (peg-parse-string ((s (and "a" "b"))) "ba" t)))
- (assert (peg-parse-string ((s (and "a" "b" "c"))) "abc" t))
- (assert (peg-parse-string ((s (* "a") "b" (eob))) "b" t))
- (assert (peg-parse-string ((s (* "a") "b" (eob))) "ab" t))
- (assert (peg-parse-string ((s (* "a") "b" (eob))) "aaab" t))
- (assert (not (peg-parse-string ((s (* "a") "b" (eob))) "abc" t)))
- (assert (peg-parse-string ((s "")) "abc" t))
- (assert (peg-parse-string ((s "" (eob))) "" t))
- (assert (peg-parse-string ((s (opt "a") "b")) "abc" t))
- (assert (peg-parse-string ((s (opt "a") "b")) "bc" t))
- (assert (not (peg-parse-string ((s (or))) "ab" t)))
- (assert (peg-parse-string ((s (and))) "ab" t))
- (assert (peg-parse-string ((s (and))) "" t))
- (assert (peg-parse-string ((s ["^"])) "^" t))
- (assert (peg-parse-string ((s ["^a"])) "a" t))
- (assert (peg-parse-string ((s ["-"])) "-" t))
- (assert (peg-parse-string ((s ["]-"])) "]" t))
- (assert (peg-parse-string ((s ["^]"])) "^" t))
- (assert (peg-parse-string ((s [alpha])) "z" t))
- (assert (not (peg-parse-string ((s [alpha])) "0" t)))
- (assert (not (peg-parse-string ((s [alpha])) "" t)))
- (assert (not (peg-parse-string ((s ["][:alpha:]"])) "z" t)))
- (assert (peg-parse-string ((s (bob))) "" t))
- (assert (peg-parse-string ((s (bos))) "x" t))
- (assert (not (peg-parse-string ((s (bos))) " x" t)))
- (assert (peg-parse-string ((s "x" (eos))) "x" t))
- (assert (peg-parse-string ((s (syntax-class whitespace))) " " t))
- (assert (peg-parse-string ((s (= "foo"))) "foo" t))
- (assert (let ((f "foo")) (peg-parse-string ((s (= f))) "foo" t)))
- (assert (not (peg-parse-string ((s (= "foo"))) "xfoo" t)))
- (assert (equal (peg-parse-string ((s `(-- 1 2))) "") '(2 1)))
- (assert (equal (peg-parse-string ((s `(-- 1 2) `(a b -- a b))) "") '(2 1)))
- (assert (equal (peg-parse-string ((s (or (and (any) s)
+ (cl-assert (peg-parse-string ((s "a")) "a" t))
+ (cl-assert (not (peg-parse-string ((s "a")) "b" t)))
+ (cl-assert (peg-parse-string ((s (not "a"))) "b" t))
+ (cl-assert (not (peg-parse-string ((s (not "a"))) "a" t)))
+ (cl-assert (peg-parse-string ((s (if "a"))) "a" t))
+ (cl-assert (not (peg-parse-string ((s (if "a"))) "b" t)))
+ (cl-assert (peg-parse-string ((s "ab")) "ab" t))
+ (cl-assert (not (peg-parse-string ((s "ab")) "ba" t)))
+ (cl-assert (not (peg-parse-string ((s "ab")) "a" t)))
+ (cl-assert (peg-parse-string ((s (range ?0 ?9))) "0" t))
+ (cl-assert (not (peg-parse-string ((s (range ?0 ?9))) "a" t)))
+ (cl-assert (peg-parse-string ((s [0-9])) "0" t))
+ (cl-assert (not (peg-parse-string ((s [0-9])) "a" t)))
+ (cl-assert (not (peg-parse-string ((s [0-9])) "" t)))
+ (cl-assert (peg-parse-string ((s (any))) "0" t))
+ (cl-assert (not (peg-parse-string ((s (any))) "" t)))
+ (cl-assert (peg-parse-string ((s (eob))) "" t))
+ (cl-assert (peg-parse-string ((s (not (eob)))) "a" t))
+ (cl-assert (peg-parse-string ((s (or "a" "b"))) "a" t))
+ (cl-assert (peg-parse-string ((s (or "a" "b"))) "b" t))
+ (cl-assert (not (peg-parse-string ((s (or "a" "b"))) "c" t)))
+ (cl-assert (peg-parse-string ((s (and "a" "b"))) "ab" t))
+ (cl-assert (peg-parse-string ((s (and "a" "b"))) "abc" t))
+ (cl-assert (not (peg-parse-string ((s (and "a" "b"))) "ba" t)))
+ (cl-assert (peg-parse-string ((s (and "a" "b" "c"))) "abc" t))
+ (cl-assert (peg-parse-string ((s (* "a") "b" (eob))) "b" t))
+ (cl-assert (peg-parse-string ((s (* "a") "b" (eob))) "ab" t))
+ (cl-assert (peg-parse-string ((s (* "a") "b" (eob))) "aaab" t))
+ (cl-assert (not (peg-parse-string ((s (* "a") "b" (eob))) "abc" t)))
+ (cl-assert (peg-parse-string ((s "")) "abc" t))
+ (cl-assert (peg-parse-string ((s "" (eob))) "" t))
+ (cl-assert (peg-parse-string ((s (opt "a") "b")) "abc" t))
+ (cl-assert (peg-parse-string ((s (opt "a") "b")) "bc" t))
+ (cl-assert (not (peg-parse-string ((s (or))) "ab" t)))
+ (cl-assert (peg-parse-string ((s (and))) "ab" t))
+ (cl-assert (peg-parse-string ((s (and))) "" t))
+ (cl-assert (peg-parse-string ((s ["^"])) "^" t))
+ (cl-assert (peg-parse-string ((s ["^a"])) "a" t))
+ (cl-assert (peg-parse-string ((s ["-"])) "-" t))
+ (cl-assert (peg-parse-string ((s ["]-"])) "]" t))
+ (cl-assert (peg-parse-string ((s ["^]"])) "^" t))
+ (cl-assert (peg-parse-string ((s [alpha])) "z" t))
+ (cl-assert (not (peg-parse-string ((s [alpha])) "0" t)))
+ (cl-assert (not (peg-parse-string ((s [alpha])) "" t)))
+ (cl-assert (not (peg-parse-string ((s ["][:alpha:]"])) "z" t)))
+ (cl-assert (peg-parse-string ((s (bob))) "" t))
+ (cl-assert (peg-parse-string ((s (bos))) "x" t))
+ (cl-assert (not (peg-parse-string ((s (bos))) " x" t)))
+ (cl-assert (peg-parse-string ((s "x" (eos))) "x" t))
+ (cl-assert (peg-parse-string ((s (syntax-class whitespace))) " " t))
+ (cl-assert (peg-parse-string ((s (= "foo"))) "foo" t))
+ (cl-assert (let ((f "foo")) (peg-parse-string ((s (= f))) "foo" t)))
+ (cl-assert (not (peg-parse-string ((s (= "foo"))) "xfoo" t)))
+ (cl-assert (equal (peg-parse-string ((s `(-- 1 2))) "") '(2 1)))
+ (cl-assert (equal (peg-parse-string ((s `(-- 1 2) `(a b -- a b))) "") '(2
1)))
+ (cl-assert (equal (peg-parse-string ((s (or (and (any) s)
(substring [0-9]))))
"ab0cd1ef2gh")
'("2")))
- (assert (equal (peg-parse-string ((s (list x y))
+ (cl-assert (equal (peg-parse-string ((s (list x y))
(x `(-- 1))
(y `(-- 2)))
"")
'((1 2))))
- (assert (equal (peg-parse-string ((s (list (* x)))
+ (cl-assert (equal (peg-parse-string ((s (list (* x)))
(x "x" `(-- 'x)))
"xxx")
'((x x x))))
- (assert (equal (peg-parse-string ((s (region (* x)))
+ (cl-assert (equal (peg-parse-string ((s (region (* x)))
(x "x" `(-- 'x)))
"xxx")
+ ;; FIXME: Since string positions start at 0, this should
+ ;; really be '(3 x x x 0) !!
'(4 x x x 1)))
- (assert (equal (peg-parse-string ((s (region (list (* x))))
+ (cl-assert (equal (peg-parse-string ((s (region (list (* x))))
(x "x" `(-- 'x 'y)))
"xxx")
'(4 (x y x y x y) 1)))
- (assert (equal (with-temp-buffer
+ (cl-assert (equal (with-temp-buffer
(save-excursion (insert "abcdef"))
(list
(peg-parse (x "a"
@@ -786,8 +795,7 @@ resp. succeded instead of signaling an error."
'(nil "axyf")))
)
-(when (featurep 'cl)
- (peg-test))
+(peg-test)
;;; Examples:
@@ -987,7 +995,7 @@ resp. succeded instead of signaling an error."
;; (peg-ex-last-digit2 (make-string 500000 ?-))
;; (peg-ex-last-digit2 (make-string 500000 ?5))
-)) ; end of eval-when-load
+) t) ; end of eval-when-load
(provide 'peg)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [elpa] externals/peg 2fa278b: * peg.el (merge-error): Don't use add-to-list on a local var,
Stefan Monnier <=