diff options
| author | Shagun Agrawal <agrawalshagun07@gmail.com> | 2024-09-19 22:54:27 +0530 |
|---|---|---|
| committer | Shagun Agrawal <agrawalshagun07@gmail.com> | 2024-09-19 22:54:27 +0530 |
| commit | 8fe495a61e4a85be1934e5205a6f036900ee45d0 (patch) | |
| tree | 11ea07d20186636269374401db9648ab8b3f8f1a /src/cljcc/driver.clj | |
| parent | 055c4478ecf882d918cfdfbd884b42d83fc8b1fd (diff) | |
Add driver option and lexing stage for functions Ch 9
Diffstat (limited to 'src/cljcc/driver.clj')
| -rw-r--r-- | src/cljcc/driver.clj | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/cljcc/driver.clj b/src/cljcc/driver.clj index b7b14c1..8485574 100644 --- a/src/cljcc/driver.clj +++ b/src/cljcc/driver.clj @@ -33,7 +33,7 @@ (throw (Exception. ^String (:err output))) (log/info (str "Successfully preprocessed file: " preprocessed-file-path))))) -(defn- assemble-step [directory filename] +(defn- assemble-step [directory filename options] (let [file-without-ext (remove-extension filename) assembly-file (make-file-name directory file-without-ext "s") preprocessed-file-path (make-file-name directory (remove-extension filename) "i") @@ -45,7 +45,9 @@ _ (println assembly-output) _ (spit assembly-out-file-path assembly-output) output-file (str directory "/" file-without-ext) - output (handle-sh "gcc" assembly-file "-o" output-file)] + output (if (:generate-object-file options) + (handle-sh "gcc" "-c" assembly-file "-o" output-file) + (handle-sh "gcc" assembly-file "-o" output-file))] (if (= 1 (:exit output)) (throw (Exception. ^String (:err output))) (log/info (str "Successfully created executable at: " output-file))))) @@ -103,7 +105,7 @@ (partial semantic-analyzer-step directory filename) (partial tacky-step directory filename) (partial compiler-step directory filename) - (partial assemble-step directory filename)]] + (partial assemble-step directory filename options)]] (cond (:lex options) (subvec steps 0 3) (:parse options) (subvec steps 0 4) |
