src/class-make-{proto,impl}.lisp: Don't always add initializers to classes.
[sod] / src / module-parse.lisp
index fed98f8..8344281 100644 (file)
@@ -52,6 +52,7 @@
 
 (define-pluggable-parser module code (scanner pset)
   ;; `code' id `:' item-name [constraints] `{' c-fragment `}'
+  ;; `code' id `:' constraints `;'
   ;;
   ;; constraints ::= `[' list[constraint] `]'
   ;; constraint ::= item-name+
             (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 #\{ #\})))
-              (when name
-                (add-to-module *module*
-                               (make-instance 'code-fragment-item
-                                              :fragment fragment
-                                              :constraints constraints
-                                              :reason reason
-                                              :name name))))))))
+                  (item (or (seq ((constraints (constraints))
+                                  (nil (must #\;)))
+                              (make-instance 'code-fragment-item
+                                             :reason reason
+                                             :constraints constraints))
+                            (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.