aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2022-07-09 23:18:16 +0200
committerHugo Hörnquist <hugo@lysator.liu.se>2022-07-09 23:20:00 +0200
commitdeee127a0e7d1803436033ff40d62f9bdf478c35 (patch)
treea315364bb5767fbda13776d6454f862871a07bc2
parentMerge typecheck macro into c-parser. (diff)
downloadcalp-deee127a0e7d1803436033ff40d62f9bdf478c35.tar.gz
calp-deee127a0e7d1803436033ff40d62f9bdf478c35.tar.xz
Extend type-clauses with not.
-rw-r--r--doc/ref/guile/util-type.texi11
-rw-r--r--module/c/cpp-environment.scm2
-rw-r--r--module/hnh/util/type.scm3
3 files changed, 9 insertions, 7 deletions
diff --git a/doc/ref/guile/util-type.texi b/doc/ref/guile/util-type.texi
index 104b00b3..d389287e 100644
--- a/doc/ref/guile/util-type.texi
+++ b/doc/ref/guile/util-type.texi
@@ -22,11 +22,12 @@ into the argument list in the first position:
(proc args ...) ⇒ (proc x args ...)
@end example
-The two primitives @code{and} and @code{or} are also available, which
-both take an arbitrary number of predicates, and calls them in order,
-with Scheme's usual short-circuiting rules.
-@footnote{@code{and} and @code{or} doesn't have to be primitives, but
-we would otherwise have one hell of a namespace conflict}
+The primitives @code{and}, @code{or}, and @code{not} are also
+available, which each take the same number of predicates as schemes
+primitives of the same name, and calls them in order, with Scheme's
+usual short-circuiting rules. @footnote{These don't have to be
+primitives, but we would otherwise have one hell of a namespace
+conflict}
@defmac list-of variable type-clause
Checks if @var{variable} is a list, and that every element satisfies type-clause.
diff --git a/module/c/cpp-environment.scm b/module/c/cpp-environment.scm
index d6c86f7a..51f16168 100644
--- a/module/c/cpp-environment.scm
+++ b/module/c/cpp-environment.scm
@@ -77,7 +77,7 @@
(cpp-if-status type: (list-of (memv '(outside active-if inactive-if)))
default: '(outside))
(cpp-variables type: hash-table? default: (make-hash-table))
- (cpp-file-stack type: (and ((negate null?))
+ (cpp-file-stack type: (and (not null?)
(list-of (pair-of string? exact-integer?)))
default: '(("*outside*" . 1))))
diff --git a/module/hnh/util/type.scm b/module/hnh/util/type.scm
index 800834e5..f35f7839 100644
--- a/module/hnh/util/type.scm
+++ b/module/hnh/util/type.scm
@@ -22,9 +22,10 @@
;; DSL for specifying type predicates
;; Basically a procedure body, but the variable to test is implicit.
(define-syntax build-validator-body
- (syntax-rules (and or list-of)
+ (syntax-rules (and or not)
((_ variable (and clauses ...)) (and (build-validator-body variable clauses) ...))
((_ variable (or clauses ...)) (or (build-validator-body variable clauses) ...))
+ ((_ variable (not clause)) (not (build-validator-body variable clause)))
((_ variable (proc args ...)) (proc variable args ...))
((_ variable proc) (proc variable))))