aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2022-07-12 02:46:12 +0200
committerHugo Hörnquist <hugo@lysator.liu.se>2022-07-12 02:46:15 +0200
commit5263ab1126adfc65e66104b50c618abea8c99772 (patch)
tree763fcb38fdf65d9f67b88448cb3a68d7caa6a8d1
parentwork (diff)
downloadcalp-5263ab1126adfc65e66104b50c618abea8c99772.tar.gz
calp-5263ab1126adfc65e66104b50c618abea8c99772.tar.xz
s/macro?/cpp-macro?/g
Guile cried way to much about me overriding a core identifier.
-rw-r--r--module/c/cpp-environment.scm13
-rw-r--r--module/c/preprocessor2.scm8
-rw-r--r--tests/test/cpp/cpp-environment.scm2
3 files changed, 12 insertions, 11 deletions
diff --git a/module/c/cpp-environment.scm b/module/c/cpp-environment.scm
index c3bd79f1..76219edc 100644
--- a/module/c/cpp-environment.scm
+++ b/module/c/cpp-environment.scm
@@ -8,13 +8,14 @@
:use-module ((c cpp-environment function-like-macro) :prefix #{fun:}#)
:use-module ((c cpp-environment object-like-macro) :prefix #{obj:}#)
:use-module ((c cpp-environment internal-macro) :prefix #{int:}#)
+ :use-module ((c unlex) :select (unlex))
:export (
macro-identifier
macro-body
macro-identifier-list
macro-variadic?
- macro?
+ cpp-macro?
;; pprint-macro
enter-active-if
@@ -79,7 +80,7 @@
(define object-macro? obj:object-like-macro?)
(define internal-macro? int:internal-macro?)
-(define (macro? x)
+(define (cpp-macro? x)
(or (obj:object-like-macro? x)
(fun:function-like-macro? x)
(int:internal-macro? x)))
@@ -158,7 +159,7 @@
(define (add-identifier environment key value)
(typecheck key string?)
- (typecheck value macro?)
+ (typecheck value cpp-macro?)
(let ((environment (clone-environment environment)))
(hash-set! (cpp-variables environment) key value)
@@ -169,13 +170,13 @@
(define (extend-environment environment macros)
- (typecheck macros (list-of macro?))
+ (typecheck macros (list-of cpp-macro?))
(fold (lambda (m env) (add-identifier env (macro-identifier m) m))
environment macros))
(define (disjoin-macro environment name)
(typecheck name string?)
- (remove-identifier env name))
+ (remove-identifier environment name))
@@ -199,7 +200,7 @@
(format p "#define ~a(~a) ~a"
(macro-identifier x)
(string-join (append (macro-identifier-list x)
- (if (variadic? x)
+ (if (macro-variadic? x)
'("...") '()))
"," 'infix)
(unlex (macro-body x))))))
diff --git a/module/c/preprocessor2.scm b/module/c/preprocessor2.scm
index 44931b68..3cb5913f 100644
--- a/module/c/preprocessor2.scm
+++ b/module/c/preprocessor2.scm
@@ -35,7 +35,7 @@
;; parameters is a lexeme list, as returned by parse-parameter-list
(define (build-parameter-map macro parameters)
- (typecheck macro macro?)
+ (typecheck macro cpp-macro?)
(typecheck parameters (list-of (list-of lexeme?)))
(map (lambda (pair) (modify pair cdr* drop-whitespace-both))
(if (macro-variadic? macro)
@@ -49,7 +49,7 @@
parameters))))
(define (expand# macro parameter-map)
- (typecheck macro macro?)
+ (typecheck macro cpp-macro?)
(typecheck parameter-map parameter-map?)
(let loop ((tokens (macro-body macro)))
(cond ((null? tokens) '())
@@ -126,7 +126,7 @@
(typecheck environment cpp-environment?)
;; Each element should be the lexeme list for that argument
(typecheck parameters (list-of (list-of lexeme?)))
- (typecheck macro macro?)
+ (typecheck macro cpp-macro?)
(check-arity macro parameters)
(let ()
@@ -176,7 +176,7 @@
;; remaining-tokens should be the token stream just after the name of the macro
(define (expand-macro environment macro noexpand-list remaining-tokens)
(typecheck environment cpp-environment?)
- (typecheck macro macro?)
+ (typecheck macro cpp-macro?)
(typecheck remaining-tokens (list-of lexeme?))
(typecheck noexpand-list (list-of string?))
diff --git a/tests/test/cpp/cpp-environment.scm b/tests/test/cpp/cpp-environment.scm
index 1b24676f..684c0fb5 100644
--- a/tests/test/cpp/cpp-environment.scm
+++ b/tests/test/cpp/cpp-environment.scm
@@ -34,7 +34,7 @@
identifier: "key"
body: (lex "value")))))
(let ((result (get-identifier e* "key")))
- (test-assert (macro? result))
+ (test-assert (cpp-macro? result))
(test-equal (lex "value")
(macro-body result)))))