From 54ea6ee880f52c23279bf58262ca245b531d04b0 Mon Sep 17 00:00:00 2001 From: Mark Wooding Date: Thu, 22 Aug 2019 13:03:52 +0100 Subject: [PATCH] src/module-parse.lisp (code): Allow setting constraints without a fragment. Add new syntax for adding constraints to the output sequencer without actually producing any output at all. --- doc/syntax.tex | 2 ++ src/module-output.lisp | 13 +++++++------ src/module-parse.lisp | 8 +++++++- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/doc/syntax.tex b/doc/syntax.tex index 0b415d2..8c66487 100644 --- a/doc/syntax.tex +++ b/doc/syntax.tex @@ -672,6 +672,8 @@ declarations instead. ::= "code" ":" @[@] "{" "}" +\alt + "code" ":" ";" ::= diff --git a/src/module-output.lisp b/src/module-output.lisp index f9eb3a4..7895176 100644 --- a/src/module-output.lisp +++ b/src/module-output.lisp @@ -114,12 +114,13 @@ (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) diff --git a/src/module-parse.lisp b/src/module-parse.lisp index f025e37..8344281 100644 --- a/src/module-parse.lisp +++ b/src/module-parse.lisp @@ -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+ @@ -80,7 +81,12 @@ (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 -- 2.11.0