aboutsummaryrefslogtreecommitdiff
path: root/module/c/preprocessor2.scm
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2022-07-23 23:34:11 +0200
committerHugo Hörnquist <hugo@lysator.liu.se>2022-08-18 16:38:37 +0200
commit309c6a49f75283e34ca027bf32d80821a226cf25 (patch)
tree51b297040c32519388ae30b4f8a6374f671b1afe /module/c/preprocessor2.scm
parentOnly parse h-strings where applicable. (diff)
downloadcalp-309c6a49f75283e34ca027bf32d80821a226cf25.tar.gz
calp-309c6a49f75283e34ca027bf32d80821a226cf25.tar.xz
General cleanup around cpp.
Diffstat (limited to 'module/c/preprocessor2.scm')
-rw-r--r--module/c/preprocessor2.scm11
1 files changed, 8 insertions, 3 deletions
diff --git a/module/c/preprocessor2.scm b/module/c/preprocessor2.scm
index e4590d41..e63103dc 100644
--- a/module/c/preprocessor2.scm
+++ b/module/c/preprocessor2.scm
@@ -29,6 +29,7 @@
;; defined-macro
c-search-path
handle-preprocessing-tokens
+ cpp
preprocess-string
make-default-environment
))
@@ -734,7 +735,7 @@
((pragma) handle-pragma)
(else (throw 'propagate
"Unknown preprocessing directive: ~s"
- (list line-tokens))))))
+ (list (unlex line-tokens)))))))
(-> environment
(op body)
(loop remaining-tokens))))))))))
@@ -822,12 +823,16 @@
(value-ref 0)))
-(define* (preprocess-string str optional: (environment (make-default-environment)))
+;; partial pre-process, useful for running just the preprocessor interactivly
+(define* (cpp str optional: (environment (make-default-environment)))
(->> str
;;; Phase 1-3
tokenize
;;; 4. Execution of preprocessing directives, all preprocessing directives are then deleted
- (handle-preprocessing-tokens environment)
+ (handle-preprocessing-tokens environment)))
+
+(define* (preprocess-string str optional: (environment (make-default-environment)))
+ (->> (cpp str environment)
abort*
;;; 5. (something with character sets)
;;; 7. Whitespace tokens are discarded, each preprocessing token is converted into a token