summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cl-forth.lisp12
-rw-r--r--main.lisp23
2 files changed, 24 insertions, 11 deletions
diff --git a/cl-forth.lisp b/cl-forth.lisp
index faa48a6..ec2a0f3 100644
--- a/cl-forth.lisp
+++ b/cl-forth.lisp
@@ -46,12 +46,12 @@
(let ((flag t))
(cond ((char= #\| next-char)
(read-char line-stream)
- (if (char-equal #\Space
- (peek-char nil line-stream nil nil))
- (collect (make-token :pipe line-num col :identifier)
- into tokens)
- (progn (unread-char #\| line-stream)
- (setf flag nil))))
+ (let ((peeked (peek-char nil line-stream nil nil)))
+ (if (or (not peeked) (char-equal #\Space peeked))
+ (collect (make-token :pipe line-num col :identifier)
+ into tokens)
+ (progn (unread-char #\| line-stream)
+ (setf flag nil)))))
((char= #\Space next-char) (read-char line-stream))
((char= #\; next-char) ;; and not in string
(finish))
diff --git a/main.lisp b/main.lisp
index 6b0d08c..8e9e719 100644
--- a/main.lisp
+++ b/main.lisp
@@ -61,7 +61,13 @@
:filepath
:description "Kaynak dosyasını belirt."
:short-name #\k
- :key :kaynak)))
+ :key :kaynak)
+ (clingon:make-option
+ :string
+ :initial-value "nasm"
+ :description "Derleme hedefini belirt."
+ :short-name #\h
+ :key :hedef)))
(defun subcommands ()
(list (clingon:make-command
@@ -69,10 +75,17 @@
:description "Dosyadaki programı derle"
:usage "<dosya-ismi>"
:options (comp-options)
- :handler (lambda (cmd) (generate-program
- (make-program
- (clingon:getopt cmd :kaynak))
- :compile t)))
+ :handler
+ (lambda (cmd) (let ((hedef (clingon:getopt cmd :hedef)))
+ (generate-program
+ (make-program
+ (clingon:getopt cmd :kaynak))
+ :path
+ (format nil "output.~a"
+ (cond ((string-equal "nasm" hedef) "asm")
+ ((string-equal "c" hedef) "c")))
+ :compile t
+ :target (intern (string-upcase hedef) :keyword)))))
(clingon:make-command
:name "test"
:description "Testleri çalıştır."