chiark / gitweb /
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 0b415d27cfc9ffce7b0413c8b5e2f486e5aeb3c4..8c6648730d92e6b6778c6a0abeef624f67327840 100644 (file)
@@ -672,6 +672,8 @@ declarations instead.
 <code-definition> ::=
   "code" <reason> ":" <item-name> @[<constraints>@]
   "{" <c-fragment> "}"
+\alt
+  "code" <reason> ":" <constraints> ";"
 
 <reason> ::= <identifier>
 
index f9eb3a47b952ac9e3ee01d3ed644f262ee6ed2a4..78951768da3b9a1b1e08f495d8cfdc3ec7af1e46 100644 (file)
@@ -114,12 +114,13 @@ (defmethod hook-output progn ((frag code-fragment-item) reason sequencer)
   (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 f025e379a8a7f718637e27ab285a3af71384cff8..83442818780b2d99d7a127fae9f69bf6d0772135 100644 (file)
@@ -52,6 +52,7 @@ (define-pluggable-parser module typename (scanner pset)
 
 (define-pluggable-parser module code (scanner pset)
   ;; `code' id `:' item-name [constraints] `{' c-fragment `}'
+  ;; `code' id `:' constraints `;'
   ;;
   ;; constraints ::= `[' list[constraint] `]'
   ;; constraint ::= item-name+
@@ -80,7 +81,12 @@ (define-pluggable-parser module code (scanner pset)
       (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