chiark / gitweb /
Reorganize some of the more random files.
[sod] / src / module-parse.lisp
index 81a39565d32bbbc51c1036df6e2b54d68692e4b6..fed98f80381fab3b2c3c7b53e7699c53f2669177 100644 (file)
@@ -108,9 +108,7 @@ (defun read-module (pathname &key (truename nil truep) location)
   (unless truep (setf truename (truename pathname)))
   (define-module (pathname :location location :truename truename)
     (with-open-file (f-stream pathname :direction :input)
   (unless truep (setf truename (truename pathname)))
   (define-module (pathname :location location :truename truename)
     (with-open-file (f-stream pathname :direction :input)
-      (let* ((*readtable* (copy-readtable))
-            (*package* (find-package '#:sod-user))
-            (char-scanner (make-instance 'charbuf-scanner
+      (let* ((char-scanner (make-instance 'charbuf-scanner
                                          :stream f-stream
                                          :filename (namestring pathname)))
             (scanner (make-instance 'sod-token-scanner
                                          :stream f-stream
                                          :filename (namestring pathname)))
             (scanner (make-instance 'sod-token-scanner
@@ -128,20 +126,13 @@   (define-module (pathname :location location :truename truename)
              (declare (ignore consumedp))
              (unless winp (syntax-error scanner result)))))))))
 
              (declare (ignore consumedp))
              (unless winp (syntax-error scanner result)))))))))
 
-(define-pluggable-parser module test (scanner pset)
-  ;; `demo' string `;'
-  (declare (ignore pset))
-  (with-parser-context (token-scanner-context :scanner scanner)
-    (parse (seq ("demo" (string (must :string)) (nil (must #\;)))
-            (format t ";; DEMO ~S~%" string)))))
-
 (define-pluggable-parser module file (scanner pset)
   ;; `import' string `;'
   ;; `load' string `;'
   (declare (ignore pset))
   (flet ((common (name type what thunk)
           (when name
 (define-pluggable-parser module file (scanner pset)
   ;; `import' string `;'
   ;; `load' string `;'
   (declare (ignore pset))
   (flet ((common (name type what thunk)
           (when name
-            (find-file scanner
+            (find-file (pathname (scanner-filename scanner))
                        (merge-pathnames name
                                         (make-pathname :type type
                                                        :case :common))
                        (merge-pathnames name
                                         (make-pathname :type type
                                                        :case :common))
@@ -156,6 +147,7 @@ (define-pluggable-parser module file (scanner pset)
                                                            :truename true)))
                                   (when module
                                     (module-import module)
                                                            :truename true)))
                                   (when module
                                     (module-import module)
+                                    (pushnew path (module-files *module*))
                                     (pushnew module
                                              (module-dependencies
                                               *module*))))
                                     (pushnew module
                                              (module-dependencies
                                               *module*))))
@@ -170,7 +162,9 @@ (define-pluggable-parser module file (scanner pset)
                   (common name "LISP" "Lisp file"
                           (lambda (path true)
                             (handler-case
                   (common name "LISP" "Lisp file"
                           (lambda (path true)
                             (handler-case
-                                (load true :verbose nil :print nil)
+                                (progn
+                                  (pushnew path (module-files *module*))
+                                  (load true :verbose nil :print nil))
                               (error (error)
                                 (cerror* "Error loading Lisp file ~S: ~A"
                                          path error)))))))))))
                               (error (error)
                                 (cerror* "Error loading Lisp file ~S: ~A"
                                          path error)))))))))))