src/module-parse.lisp (code): Allow setting constraints without a fragment.
authorMark Wooding <mdw@distorted.org.uk>
Thu, 22 Aug 2019 12:03:52 +0000 (13:03 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Thu, 22 Aug 2019 12:12:02 +0000 (13:12 +0100)
Add new syntax for adding constraints to the output sequencer without
actually producing any output at all.

doc/syntax.tex
src/module-output.lisp
src/module-parse.lisp

index 0b415d2..8c66487 100644 (file)
@@ -672,6 +672,8 @@ declarations instead.
 <code-definition> ::=
   "code" <reason> ":" <item-name> @[<constraints>@]
   "{" <c-fragment> "}"
+\alt
+  "code" <reason> ":" <constraints> ";"
 
 <reason> ::= <identifier>
 
index f9eb3a4..7895176 100644 (file)
   (when (eq reason (code-fragment-reason frag))
     (dolist (constraint (code-fragment-constraints frag))
       (add-sequencer-constraint sequencer constraint))
-    (add-sequencer-item-function sequencer (code-fragment-name frag)
-                                (lambda (stream)
-                                  (write (code-fragment frag)
-                                         :stream stream
-                                         :pretty nil
-                                         :escape nil)))))
+    (awhen (code-fragment-name frag)
+      (add-sequencer-item-function sequencer it
+                                  (lambda (stream)
+                                    (write (code-fragment frag)
+                                           :stream stream
+                                           :pretty nil
+                                           :escape nil))))))
 
 (defmethod hook-output progn ((module module) (reason (eql :h)) sequencer)
   (sequence-output (stream sequencer)
index f025e37..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+
       (parse (seq ("code"
                   (reason (must (kw)))
                   (nil (must #\:))
-                  (item (or (seq ((name (must (item)))
+                  (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