aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2022-07-25 01:11:33 +0200
committerHugo Hörnquist <hugo@lysator.liu.se>2022-08-18 16:38:37 +0200
commitfb1057dae461cce902fa9434a86ad01e769719c8 (patch)
tree0fb580953ca594d173f40926d04c698c4cbb4934
parentProperly unlex characters. (diff)
downloadcalp-fb1057dae461cce902fa9434a86ad01e769719c8.tar.gz
calp-fb1057dae461cce902fa9434a86ad01e769719c8.tar.xz
Made pprint-environment differentiate between "public" and "private" macros.
-rw-r--r--module/c/cpp-environment.scm20
1 files changed, 15 insertions, 5 deletions
diff --git a/module/c/cpp-environment.scm b/module/c/cpp-environment.scm
index 951540fa..bc4ceb1b 100644
--- a/module/c/cpp-environment.scm
+++ b/module/c/cpp-environment.scm
@@ -4,6 +4,7 @@
:use-module (hnh util object)
:use-module (hnh util type)
:use-module (hnh util lens)
+ :use-module ((hnh util) :select (group-by))
:use-module ((c lex2) :select (lexeme?))
:use-module ((c unlex) :select (unlex))
:use-module ((rnrs enums))
@@ -245,11 +246,20 @@
(define* (pprint-environment environment optional: (port (current-output-port)))
- (display "/*** Environment ***/\n" port)
- (for-each (lambda (pair)
- (pprint-macro (cdr pair) port)
- (newline port))
- (cpp-variables environment)))
+ (let* ((grouped
+ (group-by (lambda (pair)
+ (if (char=? #\_ (string-ref (car pair) 0))
+ 'private 'public))
+ (cpp-variables environment)))
+ (private (map cdr (car (assoc-ref grouped 'private))))
+ (public (map cdr (car (assoc-ref grouped 'public))))
+ (proc (lambda (x) (pprint-macro x port) (newline port))))
+ (with-output-to-port port
+ (lambda ()
+ (display "/*** Private Environment ***/") (newline)
+ (for-each proc private)
+ (display "/*** Public Environment ***/") (newline)
+ (for-each proc public)))))
(define* (pprint-macro x optional: (p (current-output-port)))
(cond ((internal-macro? x)