src/module-parse.lisp (code): Prepare for an additional variant.
authorMark Wooding <mdw@distorted.org.uk>
Thu, 22 Aug 2019 12:00:18 +0000 (13:00 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Thu, 22 Aug 2019 12:12:02 +0000 (13:12 +0100)
Some more minor refactoring: pull NAME [CONSTRAINTS] `{' FRAGMENT
`}' into an `or' subitem.

src/module-parse.lisp

index fb4903b..f025e37 100644 (file)
       (parse (seq ("code"
                   (reason (must (kw)))
                   (nil (must #\:))
-                  (name (must (item)))
-                  (constraints (? (constraints)))
-                  (fragment (fragment)))
-              (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.