(define-module (c compiler) :use-module ((srfi srfi-1) :select (remove)) :use-module (srfi srfi-71) :use-module ((c cpp-environment) :select (enter-file)) :use-module ((hnh util) :select (-> ->>)) :use-module ((hnh util io) :select (read-file)) :use-module ((c preprocessor2) :select (preprocess-string make-default-environment)) :use-module ((hnh util values) :select (abort* on-fst on-snd)) :use-module ((c ast) :select (build-ast)) :export (run-compiler compile-string compile-string* the-environment )) ;;; 5.1.11.2 Translation phases (define* (run-compiler path key: (environment (make-default-environment))) (-> path read-file (compile-string (enter-file environment path)))) (define* (compile-string str optional: (environment (make-default-environment))) (on-snd (build-ast (abort* (preprocess-string str environment))))) (define the-environment (make-parameter (make-default-environment))) (define* (compile-string* str) (let ((cpp-env result (compile-string str))) (if (null? result) (compile-string (string-append str ";") (the-environment)) result)))