From: Mark Wooding Date: Sun, 26 Mar 2017 14:16:18 +0000 (+0100) Subject: src/module-parse.lisp: Catch errors during class-item construction. X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~mdw/git/sod/commitdiff_plain/add6883c4623cc42552bc3587aad866184f37c06 src/module-parse.lisp: Catch errors during class-item construction. These aren't worth failing the whole class construction over, but they do mean that the individual class-item shouldn't be recorded. This approach seems generally easier than reporting continuable errors and then indicating failure in some other way, particularly in the case of slots with initializers. --- diff --git a/src/module-parse.lisp b/src/module-parse.lisp index 028ad87..15bfe87 100644 --- a/src/module-parse.lisp +++ b/src/module-parse.lisp @@ -317,8 +317,10 @@ (defun parse-class-body (scanner pset name supers) (parse (seq ((body (or (seq ("extern" #\;) nil) (parse-delimited-fragment scanner #\{ #\})))) - (make-sod-method class sub-nick name type - body sub-pset scanner)))) + (restart-case + (make-sod-method class sub-nick name type + body sub-pset scanner) + (continue () :report "Continue"))))) (parse-initializer () ;; initializer ::= `=' c-fragment @@ -335,14 +337,17 @@ (defun parse-class-body (scanner pset name supers) ;; ;; init-declarator ::= declarator [initializer] (flet ((make-it (name type init) - (make-sod-slot class name type - sub-pset scanner) - (when init - (make-sod-instance-initializer class - nick name - init - sub-pset - scanner)))) + (restart-case + (progn + (make-sod-slot class name type + sub-pset scanner) + (when init + (make-sod-instance-initializer class + nick name + init + sub-pset + scanner))) + (continue () :report "Continue")))) (parse (and (seq ((init (? (parse-initializer)))) (make-it name type init)) (skip-many () @@ -363,9 +368,11 @@ (defun parse-class-body (scanner pset name supers) (parse (and (skip-many () (seq ((name-a :id) #\. (name-b :id) (init (funcall parse-init))) - (funcall constructor class - name-a name-b init - sub-pset scanner)) + (restart-case + (funcall constructor class + name-a name-b init + sub-pset scanner) + (continue () :report "Continue"))) #\,) #\;))))