From: Mark Wooding Date: Sun, 26 Mar 2017 14:16:18 +0000 (+0100) Subject: src/module-parse.lisp: Improve error recovery for `load' and `import' items. X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~mdw/git/sod/commitdiff_plain/87fa582ab143b74678b7cca49aabb0bab50a93cd src/module-parse.lisp: Improve error recovery for `load' and `import' items. --- 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