From add6883c4623cc42552bc3587aad866184f37c06 Mon Sep 17 00:00:00 2001 Message-Id: From: Mark Wooding Date: Sun, 26 Mar 2017 15:16:18 +0100 Subject: [PATCH] src/module-parse.lisp: Catch errors during class-item construction. Organization: Straylight/Edgeware From: Mark Wooding 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. --- src/module-parse.lisp | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) 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"))) #\,) #\;)))) -- [mdw]