diff options
author | Hugo Hörnquist <hugo@lysator.liu.se> | 2022-07-23 23:34:11 +0200 |
---|---|---|
committer | Hugo Hörnquist <hugo@lysator.liu.se> | 2022-08-18 16:38:37 +0200 |
commit | 309c6a49f75283e34ca027bf32d80821a226cf25 (patch) | |
tree | 51b297040c32519388ae30b4f8a6374f671b1afe /module/c/preprocessor2.scm | |
parent | Only parse h-strings where applicable. (diff) | |
download | calp-309c6a49f75283e34ca027bf32d80821a226cf25.tar.gz calp-309c6a49f75283e34ca027bf32d80821a226cf25.tar.xz |
General cleanup around cpp.
Diffstat (limited to 'module/c/preprocessor2.scm')
-rw-r--r-- | module/c/preprocessor2.scm | 11 |
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 |