[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 2e8c52b 40/60: Make sure parsec-not-followed-by consumes n
From: |
Junpeng Qiu |
Subject: |
[elpa] master 2e8c52b 40/60: Make sure parsec-not-followed-by consumes no input |
Date: |
Tue, 25 Oct 2016 17:45:15 +0000 (UTC) |
branch: master
commit 2e8c52b1360f0cf05dc6adf4da9ab0874b66a3e6
Author: Junpeng Qiu <address@hidden>
Commit: Junpeng Qiu <address@hidden>
Make sure parsec-not-followed-by consumes no input
---
parsec-tests.el | 9 +++++++++
parsec.el | 13 +++++++------
2 files changed, 16 insertions(+), 6 deletions(-)
diff --git a/parsec-tests.el b/parsec-tests.el
index 661411f..fdf2055 100644
--- a/parsec-tests.el
+++ b/parsec-tests.el
@@ -342,6 +342,15 @@
(parsec-str "ab")
(parsec-not-followed-by (parsec-ch ?c))
(parsec-ch ?d)))
+ '("ab" "d")))
+ (should
+ (equal
+ (parsec-with-input "abd"
+ (parsec-collect*
+ (parsec-str "ab")
+ (parsec-or (parsec-not-followed-by (parsec-ch ?d))
+ (parsec-not-followed-by (parsec-ch ?c)))
+ (parsec-ch ?d)))
'("ab" "d"))))
(ert-deftest test-parsec-endby ()
diff --git a/parsec.el b/parsec.el
index 295aea8..1e27d5e 100644
--- a/parsec.el
+++ b/parsec.el
@@ -394,12 +394,13 @@ meaning as `parsec-many-till'."
"Succeed only when PARSER fails. Consume no input."
(let ((res-sym (make-symbol "results")))
`(catch 'parsec-not-followed-by
- (let ((,res-sym
- (catch 'parsec-immediate-stop
- (throw 'parsec-not-followed-by
- (parsec-or (throw 'parsec-immediate-stop (parsec-try
,parser))
- nil)))))
- (parsec-stop :message (format "Unexpected followed by: %s"
,res-sym))))))
+ (parsec-try
+ (let ((,res-sym
+ (catch 'parsec-immediate-stop
+ (throw 'parsec-not-followed-by
+ (parsec-or (throw 'parsec-immediate-stop (parsec-try
,parser))
+ nil)))))
+ (parsec-stop :message (format "Unexpected followed by: %s"
,res-sym)))))))
(defmacro parsec-endby (parser end)
"Parse zero or more occurrences of PARSER, separated and ended by END.
- [elpa] master d21bf7d 14/60: Remove unused code, (continued)
- [elpa] master d21bf7d 14/60: Remove unused code, Junpeng Qiu, 2016/10/25
- [elpa] master 108879f 11/60: Better propagate naming and implementation, Junpeng Qiu, 2016/10/25
- [elpa] master 5810eef 21/60: Remove parsec-continue, Junpeng Qiu, 2016/10/25
- [elpa] master 452ec1e 35/60: Update scheme parser, Junpeng Qiu, 2016/10/25
- [elpa] master 14b28a1 16/60: Add basic README, Junpeng Qiu, 2016/10/25
- [elpa] master 606fed1 10/60: Add simple JSON parser, Junpeng Qiu, 2016/10/25
- [elpa] master d8cd9d6 17/60: Better naming, Junpeng Qiu, 2016/10/25
- [elpa] master a5ca813 04/60: Full & simple parser, Junpeng Qiu, 2016/10/25
- [elpa] master 9996b5b 31/60: Update full-csv-parser, Junpeng Qiu, 2016/10/25
- [elpa] master bdfcbde 23/60: Update library description, Junpeng Qiu, 2016/10/25
- [elpa] master 2e8c52b 40/60: Make sure parsec-not-followed-by consumes no input,
Junpeng Qiu <=
- [elpa] master fb26929 34/60: Fix parsec-make-alternatives, Junpeng Qiu, 2016/10/25
- [elpa] master 31388e6 52/60: Add -s aliases, Junpeng Qiu, 2016/10/25
- [elpa] master 34521c6 53/60: Update README about *-s functions, Junpeng Qiu, 2016/10/25
- [elpa] master 8f0c266 58/60: Add doc for parsec-peek(-p), Junpeng Qiu, 2016/10/25
- [elpa] master ffd42de 45/60: Use simple-csv-parser.el as a demo, Junpeng Qiu, 2016/10/25
- [elpa] master bf49fb6 38/60: Upate README, Junpeng Qiu, 2016/10/25
- [elpa] master 966ca9e 43/60: Add comments to parsec.el, Junpeng Qiu, 2016/10/25
- [elpa] master c61a38c 22/60: Add convenient newline methods, Junpeng Qiu, 2016/10/25
- [elpa] master 0c3408a 01/60: Init commit, Junpeng Qiu, 2016/10/25
- [elpa] master 1929932 02/60: Split into two files, Junpeng Qiu, 2016/10/25