From ccc7848110b06479cf8a38ee843d4d3adc01a27c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Tue, 12 Jul 2022 02:37:49 +0200 Subject: work --- module/c/unlex.scm | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'module/c/unlex.scm') 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,8 +8,15 @@ 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) @@ -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)))) -- cgit v1.2.3