From b9e89e0d84e8ab8d3e8d9ac02e3349bac908b415 Mon Sep 17 00:00:00 2001 From: Nathan Bird Date: Mon, 20 Apr 2009 10:15:25 -0400 Subject: [PATCH] new syntax macro (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 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 | 1 + sql/syntax.lisp | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/sql/package.lisp b/sql/package.lisp index 135d0f6..9e9dcb6 100644 --- a/sql/package.lisp +++ b/sql/package.lisp @@ -394,6 +394,7 @@ #: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 diff --git a/sql/syntax.lisp b/sql/syntax.lisp index 1aec1ca..7e1906b 100644 --- a/sql/syntax.lisp +++ b/sql/syntax.lisp @@ -64,6 +64,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* -- 2.34.1