[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 452ec1e 35/60: Update scheme parser
From: |
Junpeng Qiu |
Subject: |
[elpa] master 452ec1e 35/60: Update scheme parser |
Date: |
Tue, 25 Oct 2016 17:45:15 +0000 (UTC) |
branch: master
commit 452ec1efd958c44c18932e126dac14a18c8e1748
Author: Junpeng Qiu <address@hidden>
Commit: Junpeng Qiu <address@hidden>
Update scheme parser
---
examples/scheme-tests.el | 88 ++++++++++++++++++++++++++++++++++++++++++++++
examples/scheme.el | 12 +------
2 files changed, 89 insertions(+), 11 deletions(-)
diff --git a/examples/scheme-tests.el b/examples/scheme-tests.el
new file mode 100644
index 0000000..0e7e402
--- /dev/null
+++ b/examples/scheme-tests.el
@@ -0,0 +1,88 @@
+;;; scheme-tests.el --- Tests for scheme parser -*- lexical-binding: t;
-*-
+
+;; Copyright (C) 2016 Junpeng Qiu
+
+;; Author: Junpeng Qiu <address@hidden>
+;; Keywords:
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;;
+
+;;; Code:
+
+(require 'ert)
+(require 'scheme)
+
+(ert-deftest test-scheme-number ()
+ (should
+ (equal (scheme-read "25")
+ (scheme-number 25))))
+
+(ert-deftest test-scheme-string ()
+ (should
+ (equal
+ (scheme-read "\"This is a string\"")
+ "This is a string")))
+
+(ert-deftest test-scheme-list ()
+ (should
+ (equal
+ (scheme-read "(symbol)")
+ '(List
+ (Atom . "symbol"))))
+ (should
+ (equal
+ (scheme-read "(a test)")
+ '(List
+ (Atom . "a")
+ (Atom . "test")))))
+
+(ert-deftest test-scheme-dotted-list ()
+ (should
+ (equal
+ (scheme-read "(a . test)")
+ '(DottedList
+ ((Atom . "a"))
+ Atom . "test"))))
+
+(ert-deftest test-scheme-nested ()
+ (should
+ (equal
+ (scheme-read "(a (nested) test)")
+ '(List
+ (Atom . "a")
+ (List
+ (Atom . "nested"))
+ (Atom . "test")))))
+
+(ert-deftest test-scheme-quoted ()
+ (should
+ (equal
+ (scheme-read "(a '(quoted (dotted . list)) test)")
+ '(List
+ (Atom . "a")
+ (List
+ (Atom . "quote")
+ (List
+ (Atom . "quoted")
+ (DottedList
+ ((Atom . "dotted"))
+ Atom . "list")))
+ (Atom . "test")))))
+
+(provide 'scheme-tests)
+;;; scheme-tests.el ends here
diff --git a/examples/scheme.el b/examples/scheme.el
index 3127b59..d750c54 100644
--- a/examples/scheme.el
+++ b/examples/scheme.el
@@ -53,7 +53,7 @@
(defun scheme-parse-string ()
(parsec-and (parsec-ch ?\")
- (parsec-return (parsec-many-as-string (parsec-re "[^\"]"))
+ (parsec-return (parsec-many-as-string (parsec-none-of ?\"))
(parsec-ch ?\"))))
(defun scheme-parse-atom ()
@@ -104,15 +104,5 @@
(parsec-with-input expr
(scheme-parse-expr)))
-(scheme-read "25")
-(scheme-read "\"This is a string\"")
-(scheme-read "(symbol)")
-(scheme-read "(a test)")
-(scheme-read "(a . test)")
-(parsec-with-input "a . test"
- (parsec-sepby (scheme-parse-expr) (scheme-spaces)))
-(scheme-read "(a (nested) test)")
-(scheme-read "(a '(quoted (dotted . list)) test)")
-
(provide 'scheme)
;;; scheme.el ends here
- [elpa] master updated (e479a3e -> dfb3af0), Junpeng Qiu, 2016/10/25
- [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 <=
- [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, 2016/10/25
- [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