aboutsummaryrefslogtreecommitdiff
path: root/module/c/unlex.scm
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--module/c/unlex.scm12
1 files changed, 10 insertions, 2 deletions
diff --git a/module/c/unlex.scm b/module/c/unlex.scm
index 9f4b25b9..18e800d9 100644
--- a/module/c/unlex.scm
+++ b/module/c/unlex.scm
@@ -8,10 +8,17 @@
stringify-token
stringify-tokens))
-;; takes a list of preprocessing-token's, and return a "source" string
(define (unlex tokens)
(typecheck tokens (list-of lexeme?))
(string-concatenate
+ (map (lambda (x) (cond (x preprocessing-token? => stringify-token)
+ ((whitespace-token? x) (lexeme-body x))))
+ tokens)))
+
+;; takes a list of preprocessing-token's, and return a "source" string
+(define (unlex-aggressive tokens)
+ (typecheck tokens (list-of lexeme?))
+ (string-concatenate
(map (lambda (x)
(cond ((preprocessing-token? x) (stringify-token x))
((whitespace-token? x) " ")))
@@ -34,4 +41,5 @@
;; takes a token list, and return a single string literal token
(define (stringify-tokens tokens)
- (lexeme type: 'preprocessing-token body: `(string-literal ,(unlex tokens))))
+ (lexeme type: 'preprocessing-token
+ body: `(string-literal ,(unlex-aggressive tokens))))