From: Mike D. Lowis Date: Tue, 24 Jul 2012 20:32:52 +0000 (-0400) Subject: Removed dependencies on extensions and changed default action to compile X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=f4a9a2a454866b27a2d7db02353a3f78135a5563;p=archive%2Fdlang-scm.git Removed dependencies on extensions and changed default action to compile --- diff --git a/Makefile b/Makefile index cb0d279..f0b1954 100644 --- a/Makefile +++ b/Makefile @@ -42,7 +42,7 @@ TEST_INCS = -I inc # Compiler and Linker Options #---------------------------- CSC = csc -CSCFLAGS = -c -w +CSCFLAGS = -c -explicit-use # Build Rules #------------ diff --git a/source/buf.scm b/source/buf.scm index 9e3b734..3a0e3f2 100644 --- a/source/buf.scm +++ b/source/buf.scm @@ -1,7 +1,4 @@ -(declare (unit buf) - (uses library)) - -(require-extension vector-lib) +(declare (unit buf) (uses library)) (define-record buf src ldfn pos marks data) @@ -18,6 +15,10 @@ (list? (buf-marks obj)) (vector? (buf-data obj)))) +(define (vector-append v1 v2 . vN) + (define new-vec (list->vector (append (vector->list v1) (vector->list v2)))) + (if (null? vN) new-vec (vector-append new-vec (car vN) (cdr vN)))) + (define (buf-marked? b) (> (length (buf-marks b)) 0)) diff --git a/source/main.scm b/source/main.scm index 780254c..21982b3 100644 --- a/source/main.scm +++ b/source/main.scm @@ -1,7 +1,4 @@ -(declare (uses lexer parser scheme)) - -; Require the String library extension -(require-extension srfi-13) +(declare (uses lexer parser scheme srfi-13)) (define (get-output-file-name ifname) (string-append (substring ifname 0 (string-index-right ifname #\.)) ".scm")) @@ -9,7 +6,15 @@ (define (parse-file fname) (scheme-program (dlang/program (dlang/lexer (open-input-file fname))))) -(define (interpret-file fname) +(define (dlang-compile-file fname) + (define ofname (get-output-file-name fname)) + (define program (parse-file fname)) + (with-output-to-file ofname + (lambda () (map print program))) + (system (string-append "csc " ofname)) + (delete-file ofname)) + +(define (dlang-interpret-file fname) (define ofname (get-output-file-name fname)) (define program (parse-file fname)) (with-output-to-file ofname @@ -19,6 +24,6 @@ ; If we have a file, then parse it (if (= 1 (length (command-line-arguments))) - (interpret-file (car (command-line-arguments))) + (dlang-compile-file (car (command-line-arguments))) (print "No input file provided."))