diff options
author | Hugo Hörnquist <hugo@lysator.liu.se> | 2022-07-12 02:37:49 +0200 |
---|---|---|
committer | Hugo Hörnquist <hugo@lysator.liu.se> | 2022-07-12 02:37:49 +0200 |
commit | ccc7848110b06479cf8a38ee843d4d3adc01a27c (patch) | |
tree | 2db89619c228b5e17f2df5b76b2eaf90060b0928 /module/c/unlex.scm | |
parent | Remove linear update environment procedures. (diff) | |
download | calp-ccc7848110b06479cf8a38ee843d4d3adc01a27c.tar.gz calp-ccc7848110b06479cf8a38ee843d4d3adc01a27c.tar.xz |
work
Diffstat (limited to '')
-rw-r--r-- | module/c/unlex.scm | 12 |
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)))) |