From 87fa582ab143b74678b7cca49aabb0bab50a93cd Mon Sep 17 00:00:00 2001 Message-Id: <87fa582ab143b74678b7cca49aabb0bab50a93cd.1715290598.git.mdw@distorted.org.uk> From: Mark Wooding Date: Sun, 26 Mar 2017 15:16:18 +0100 Subject: [PATCH] src/module-parse.lisp: Improve error recovery for `load' and `import' items. Organization: Straylight/Edgeware From: Mark Wooding --- src/module-parse.lisp | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/module-parse.lisp b/src/module-parse.lisp index 014e7e3..95196f8 100644 --- a/src/module-parse.lisp +++ b/src/module-parse.lisp @@ -140,14 +140,15 @@ (define-pluggable-parser module file (scanner pset) ;; `load' string `;' (declare (ignore pset)) (flet ((common (name type what thunk) - (find-file scanner - (merge-pathnames name - (make-pathname :type type - :case :common)) - what - thunk))) + (when name + (find-file scanner + (merge-pathnames name + (make-pathname :type type + :case :common)) + what + thunk)))) (with-parser-context (token-scanner-context :scanner scanner) - (parse (or (seq ("import" (name :string) #\;) + (parse (or (seq ("import" (name (must :string)) (nil (must #\;))) (common name "SOD" "module" (lambda (path true) (handler-case @@ -160,8 +161,12 @@ (define-pluggable-parser module file (scanner pset) *module*)))) (file-error (error) (cerror* "Error reading module ~S: ~A" + path error)) + (error (error) + (cerror* "Unexpected error reading ~ + module ~S: ~A" path error)))))) - (seq ("load" (name :string) #\;) + (seq ("load" (name (must :string)) (nil (must #\;))) (common name "LISP" "Lisp file" (lambda (path true) (handler-case -- [mdw]