src/module-parse.lisp (code): Hoist complex sub-items out of main parser.
authorMark Wooding <mdw@distorted.org.uk>
Thu, 22 Aug 2019 11:58:53 +0000 (12:58 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Thu, 22 Aug 2019 12:12:02 +0000 (13:12 +0100)
src/module-parse.lisp

index fed98f8..fb4903b 100644 (file)
             (item ()
               (parse (or (kw)
                          (seq (#\( (names (list (:min 1) (kw))) #\))
-                           names)))))
+                           names))))
+            (constraints ()
+              (parse (seq (#\[
+                           (constraints
+                            (list ()
+                              (list (:min 1)
+                                (error (:ignore-unconsumed t) (item)
+                                  (skip-until () :id #\( #\, #\])))
+                              #\,))
+                           #\])
+                       constraints)))
+            (fragment ()
+              (parse-delimited-fragment scanner #\{ #\})))
       (parse (seq ("code"
                   (reason (must (kw)))
                   (nil (must #\:))
                   (name (must (item)))
-                  (constraints (? (seq (#\[
-                                        (constraints
-                                         (list ()
-                                           (list (:min 1)
-                                             (error (:ignore-unconsumed t)
-                                                 (item)
-                                               (skip-until ()
-                                                 :id #\( #\, #\])))
-                                           #\,))
-                                        #\])
-                                    constraints)))
-                  (fragment (parse-delimited-fragment scanner #\{ #\})))
+                  (constraints (? (constraints)))
+                  (fragment (fragment)))
               (when name
                 (add-to-module *module*
                                (make-instance 'code-fragment-item