new syntax macro (FILE-ENABLE-SQL-READER-SYNTAX)
authorNathan Bird <nathan@acceleration.net>
Mon, 20 Apr 2009 14:15:25 +0000 (10:15 -0400)
committerNathan Bird <nathan@acceleration.net>
Mon, 20 Apr 2009 14:15:25 +0000 (10:15 -0400)
Turns on the SQL reader syntax for the rest of the file.
The CL spec says that when finished loading a file the original
*readtable* is restored.  clhs COMPILE-FILE

This is because we kept having problems with the read syntax
not being disabled. When clsql goes to enable the syntax it first
checks that it hasn't already done so. Clsql believed it had, but
the lisp had correctly disabled it and so we are left without the
syntax being enabled.

sql/package.lisp
sql/syntax.lisp

index fbb67b42a6a1cc0f69a8bad9ea50b4eb16ca7bb0..c3c4a6d190cd5fd8f00087b036c92d24f0ce773b 100644 (file)
          #:locally-disable-sql-reader-syntax
          #:locally-enable-sql-reader-syntax
          #:restore-sql-reader-syntax-state
+        #:file-enable-sql-reader-syntax
 
          ;; SQL operations (operations.lisp)
          #:sql-query
index 436c224ccd9476b2aa3e46b88259a17ab175f037..1ce7e6b4aa7f3476a38d8cf4964a85ffa87ad552 100644 (file)
@@ -66,6 +66,15 @@ the current syntax state."
   '(eval-when (:compile-toplevel :load-toplevel :execute)
     (%enable-sql-reader-syntax)))
 
+(defmacro file-enable-sql-reader-syntax ()
+  "Turns on the SQL reader syntax for the rest of the file.
+The CL spec says that when finished loading a file the original
+*readtable* is restored.  clhs COMPILE-FILE"
+  '(eval-when (:compile-toplevel :load-toplevel :execute)
+    (setf *readtable* (copy-readtable))
+    (set-macro-character *sql-macro-open-char* #'sql-reader-open)
+    (set-macro-character *sql-macro-close-char* (get-macro-character #\)))))
+
 (defun %enable-sql-reader-syntax ()
   (unless *original-readtable*
     (setf *original-readtable* *readtable*