X-Git-Url: https://git.distorted.org.uk/~mdw/sod/blobdiff_plain/6f4f8db4ab19a3029e293918184a2a1f452bc85f..d018d6d87c7a2c3458348f775319b6f9c4a88380:/src/module-parse.lisp diff --git a/src/module-parse.lisp b/src/module-parse.lisp index 170d61f..f025e37 100644 --- a/src/module-parse.lisp +++ b/src/module-parse.lisp @@ -64,30 +64,32 @@ (item () (parse (or (kw) (seq (#\( (names (list (:min 1) (kw))) #\)) - names))))) + names)))) + (constraints () + (parse (seq (#\[ + (constraints + (list () + (list (:min 1) + (error (:ignore-unconsumed t) (item) + (skip-until () :id #\( #\, #\]))) + #\,)) + #\]) + constraints))) + (fragment () + (parse-delimited-fragment scanner #\{ #\}))) (parse (seq ("code" (reason (must (kw))) (nil (must #\:)) - (name (must (item))) - (constraints (? (seq (#\[ - (constraints - (list () - (list (:min 1) - (error (:ignore-unconsumed t) - (item) - (skip-until () - :id #\( #\, #\]))) - #\,)) - #\]) - constraints))) - (fragment (parse-delimited-fragment scanner #\{ #\}))) - (when name - (add-to-module *module* - (make-instance 'code-fragment-item - :fragment fragment - :constraints constraints - :reason reason - :name name)))))))) + (item (or (seq ((name (must (item))) + (constraints (? (constraints))) + (fragment (fragment))) + (and name + (make-instance 'code-fragment-item + :reason reason + :constraints constraints + :name name + :fragment fragment)))))) + (when item (add-to-module *module* item))))))) ;;; External files. @@ -108,9 +110,7 @@ (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