From efad2c1109c168fa4268875c1ff78fb24315e969 Mon Sep 17 00:00:00 2001 From: Alfredo Beaumont Date: Fri, 26 Apr 2013 17:22:14 +0200 Subject: [PATCH] Create and export read-from-string. Add a test for it --- src/read.lisp | 4 ++++ src/toplevel.lisp | 13 +++++++------ tests/read.lisp | 4 ++++ 3 files changed, 15 insertions(+), 6 deletions(-) create mode 100644 tests/read.lisp diff --git a/src/read.lisp b/src/read.lisp index 43628a4..c99604a 100644 --- a/src/read.lisp +++ b/src/read.lisp @@ -316,3 +316,7 @@ (defun ls-read-from-string (string &optional (eof-error-p t) eof-value) (ls-read (make-string-stream string) eof-error-p eof-value)) + +#+jscl +(defun read-from-string (string &optional (eof-errorp t) eof-value) + (ls-read-from-string string eof-errorp eof-value)) diff --git a/src/toplevel.lisp b/src/toplevel.lisp index 0a1b4dd..6fb2569 100644 --- a/src/toplevel.lisp +++ b/src/toplevel.lisp @@ -67,12 +67,13 @@ nconc nil not nreconc nth nthcdr null numberp or package-name package-use-list packagep parse-integer plusp prin1-to-string print proclaim prog1 prog2 progn psetq push - quote remove remove-if remove-if-not return return-from - revappend reverse rplaca rplacd second set setf setq some - string string-upcase string= stringp subseq symbol-function - symbol-name symbol-package symbol-plist symbol-value symbolp - t tagbody third throw truncate unless unwind-protect values - values-list variable warn when write-line write-string zerop)) + quote read-from-string remove remove-if remove-if-not return + return-from revappend reverse rplaca rplacd second set setf + setq some string string-upcase string= stringp subseq + symbol-function symbol-name symbol-package symbol-plist + symbol-value symbolp t tagbody third throw truncate unless + unwind-protect values values-list variable warn when write-line + write-string zerop)) (setq *package* *user-package*) diff --git a/tests/read.lisp b/tests/read.lisp new file mode 100644 index 0000000..6f10ca2 --- /dev/null +++ b/tests/read.lisp @@ -0,0 +1,4 @@ +;; TODO: Uncomment when either read-from-string supports all these parameters +;; or when test macro supports error handling, whichever comes first +;; (test (equal (read-from-string " 1 3 5" t nil :start 2) (values 3 5))) +(test (equal (read-from-string "(a b c)") (values '(A B C) 7))) -- 1.7.10.4