aboutsummaryrefslogtreecommitdiff
path: root/module/c/cpp-environment.scm
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2022-07-07 18:40:27 +0200
committerHugo Hörnquist <hugo@lysator.liu.se>2022-07-07 21:31:32 +0200
commit1393ce3878e5d14214631fb83d58c819a7849b18 (patch)
treed1e34b2b459ea9c1702ac72f6e66f0b05ce45223 /module/c/cpp-environment.scm
parentChange makefile to explicit list of files. (diff)
downloadcalp-1393ce3878e5d14214631fb83d58c819a7849b18.tar.gz
calp-1393ce3878e5d14214631fb83d58c819a7849b18.tar.xz
work.
Diffstat (limited to 'module/c/cpp-environment.scm')
-rw-r--r--module/c/cpp-environment.scm22
1 files changed, 14 insertions, 8 deletions
diff --git a/module/c/cpp-environment.scm b/module/c/cpp-environment.scm
index 20589b8e..3ce754df 100644
--- a/module/c/cpp-environment.scm
+++ b/module/c/cpp-environment.scm
@@ -43,7 +43,10 @@
(define identifier
(cond ((obj:object-like-macro? x) obj:identifier)
((fun:function-like-macro? x) fun:identifier)
- ((int:internal-macro? x) int:identifier)))
+ ((int:internal-macro? x) int:identifier)
+ (else (scm-error 'wrong-type-arg "macro-identifier"
+ "Not a macro: ~s"
+ (list x) #f))))
(identifier x))
@@ -51,7 +54,10 @@
(define body-proc
(cond ((obj:object-like-macro? macro) obj:body)
((fun:function-like-macro? macro) fun:body)
- ((int:internal-macro? macro) int:body)))
+ ((int:internal-macro? macro) int:body)
+ (else (scm-error 'wrong-type-arg "macro-body"
+ "Not a macro: ~s"
+ (list macro) #f))))
(body-proc macro))
(define macro-identifier-list fun:identifier-list)
@@ -69,9 +75,10 @@
(define-type (cpp-environment)
(cpp-if-status type: (list-of (memv '(outside active-if inactive-if)))
default: '(outside))
- (cpp-variabes type: hash-table? default: (make-hash-table))
- (cpp-file-stack type: list?
- default: '()))
+ (cpp-variables type: hash-table? default: (make-hash-table))
+ (cpp-file-stack type: (and ((negate null?))
+ (list-of (pair-of string? exact-integer?)))
+ default: '(("*outside*" . 1))))
@@ -116,7 +123,7 @@
(scm-error 'wrong-type-arg "add-identifier!"
"Key must be a string, got: ~s"
(list key) #f))
- (unless (macro? key)
+ (unless (macro? value)
(scm-error 'wrong-type-arg "add-identifier!"
"Value must be a macro, got: ~s"
(list value) #f))
@@ -131,7 +138,6 @@
(define (extend-environment environment macros)
(let ((env (modify environment cpp-variables clone-hash-table)))
- (fold (lambda (pair m)
- (add-identifier! env (macro-identifier m) m ))
+ (fold (lambda (m env) (add-identifier! env (macro-identifier m) m))
env macros)))