diff --git a/build.sh b/build.sh index 80a559a..3a4f741 100755 --- a/build.sh +++ b/build.sh @@ -1,6 +1,6 @@ #!/bin/sh -sbcl --load cl-forth.asd \ - --eval '(ql:quickload :cl-forth)' \ - --eval '(asdf:make :cl-forth)' \ +sbcl --load kurt.asd \ + --eval '(ql:quickload :kurt)' \ + --eval '(asdf:make :kurt)' \ --eval '(quit)' diff --git a/cl-forth.lisp b/cl-forth.lisp index 410b112..ab3af1a 100644 --- a/cl-forth.lisp +++ b/cl-forth.lisp @@ -1,4 +1,4 @@ -(in-package :cl-forth) +(in-package :kurt) (defun make-token (sym? line col &optional (type nil)) (when (null type) diff --git a/assembly.lisp b/codegen.lisp similarity index 99% rename from assembly.lisp rename to codegen.lisp index 16183f7..1e8c364 100644 --- a/assembly.lisp +++ b/codegen.lisp @@ -1,4 +1,4 @@ -(in-package :cl-forth) +(in-package :kurt) (defparameter *psuedo-identifiers* '(syscall-1 syscall-2 syscall-3 syscall-4 syscall-5 syscall-6 makro son kütüphane) diff --git a/errors.lisp b/errors.lisp new file mode 100644 index 0000000..2f955ca --- /dev/null +++ b/errors.lisp @@ -0,0 +1,26 @@ +(in-package :kurt) + +(defun report-line (line-num line col? &optional (stream t)) + (format stream "~5a:~a~%" line-num line) + (iter (for i from 0 below (+ 6 (if (consp col?) + (getf (cdr col?) :col) ;; if token get col + col?))) + (write-char #\Space stream)) + (format stream "^~%")) + +(define-condition char-not-closed () + ((line :initarg :line :reader line) + (col :initarg :col :reader col) + (line-num :initarg :line-num :reader line-num)) + (:report (lambda (condition stream) + (format stream "Karakterin kapanış sembolü ' eksik.~%") + (report-line (line-num condition) (line condition) (col condition) stream)))) + +(defun handle-char-not-closed (line-num line token-or-col) + (make-condition 'char-not-closed :line-num line-num :line line :col token-or-col)) + +;; (define-condition op-not-implemented (style-warning) +;; ((undef-ops :initarg :ops :reader undef-ops)) +;; (:report (lambda (condition stream) +;; (format stream "These ops are not defined in op-case: ~s" +;; (undef-ops condition))))) diff --git a/cl-forth.asd b/kurt.asd similarity index 73% rename from cl-forth.asd rename to kurt.asd index 6702f90..517c5bb 100644 --- a/cl-forth.asd +++ b/kurt.asd @@ -1,4 +1,4 @@ -(asdf:defsystem "cl-forth" +(asdf:defsystem "kurt" :description "Stack based language implemented in Common Lisp" :version "0.1" :author "Emre Akan" @@ -7,11 +7,12 @@ :serial t :components ((:file "package") (:file "util") - (:file "assembly") + (:file "errors") + (:file "codegen") (:file "cl-forth") (:file "simulation") (:file "main") (:file "test/tests")) :build-operation "program-op" - :build-pathname "test/cl-forth" - :entry-point "cl-forth:main") + :build-pathname "test/kurt" + :entry-point "kurt:main") diff --git a/main.lisp b/main.lisp index 15b33a7..6b0d08c 100644 --- a/main.lisp +++ b/main.lisp @@ -1,4 +1,4 @@ -(in-package :cl-forth) +(in-package :kurt) ;; (defun main () ;; (let ((args (rest sb-ext:*posix-argv*))) @@ -97,8 +97,8 @@ (defun top-level-command () (clingon:make-command - :name "cl-forth" - :description "cl-forth derleyicisi" + :name "kurt" + :description "kurt derleyicisi" :version "0.1.0" :authors '("Emre Akan ") :options (top-level-options) diff --git a/package.lisp b/package.lisp index 76547a0..3880c56 100644 --- a/package.lisp +++ b/package.lisp @@ -1,3 +1,3 @@ -(defpackage cl-forth +(defpackage kurt (:use :common-lisp :iterate) (:export #:main)) diff --git a/simulation.lisp b/simulation.lisp index 2699dc9..b0e317c 100644 --- a/simulation.lisp +++ b/simulation.lisp @@ -1,4 +1,4 @@ -(in-package :cl-forth) +(in-package :kurt) (defvar *stack* nil) (defvar *bel* nil) diff --git a/test/arith.lorth b/test/arith.kurt similarity index 100% rename from test/arith.lorth rename to test/arith.kurt diff --git a/test/bits.lorth b/test/bits.kurt similarity index 100% rename from test/bits.lorth rename to test/bits.kurt diff --git a/test/branchs.lorth b/test/branchs.kurt similarity index 100% rename from test/branchs.lorth rename to test/branchs.kurt diff --git a/test/include.kurt b/test/include.kurt new file mode 100644 index 0000000..80b69d2 --- /dev/null +++ b/test/include.kurt @@ -0,0 +1,3 @@ +kütüphane "std.lorth" + +stdout "Merhaba Dünya!\n" write \ No newline at end of file diff --git a/test/loop.lorth b/test/loop.kurt similarity index 100% rename from test/loop.lorth rename to test/loop.kurt diff --git a/test/makro.lorth b/test/makro.kurt similarity index 100% rename from test/makro.lorth rename to test/makro.kurt diff --git a/test/stack.lorth b/test/stack.kurt similarity index 100% rename from test/stack.lorth rename to test/stack.kurt diff --git a/test/std.kurt b/test/std.kurt new file mode 100644 index 0000000..cf7e684 --- /dev/null +++ b/test/std.kurt @@ -0,0 +1,4 @@ +makro sys-write 1 son +makro write (fd string -- ) + değiş sys-write syscall-3 son +makro stdout 1 son \ No newline at end of file diff --git a/test/syscall.lorth b/test/syscall.kurt similarity index 100% rename from test/syscall.lorth rename to test/syscall.kurt diff --git a/test/tests.lisp b/test/tests.lisp index 8b00817..0907a58 100644 --- a/test/tests.lisp +++ b/test/tests.lisp @@ -1,4 +1,4 @@ -(in-package :cl-forth) +(in-package :kurt) (defun drop-file-type (file &key (returns :string)) (let* ((file-str (namestring file)) @@ -73,7 +73,7 @@ (ignore-errors (run-test file :target target)))) (remove-if-not (lambda (file) - (string= "lorth" (pathname-type file))) + (string= "kurt" (pathname-type file))) (cl-fad:list-directory (from-root "test")))) counting (eq t success?) into succs diff --git a/util.lisp b/util.lisp index 9f80adb..0eee717 100644 --- a/util.lisp +++ b/util.lisp @@ -1,4 +1,4 @@ -(in-package :cl-forth) +(in-package :kurt) (eval-when (:compile-toplevel :load-toplevel :execute) (defmacro eval-always (&body body) @@ -26,7 +26,7 @@ (apply #'uiop:run-program args options)) (defun from-root (path) - (merge-pathnames path (asdf:system-source-directory :cl-forth))) + (merge-pathnames path (asdf:system-source-directory :kurt))) ;; ,(file-namestring ;; (make-pathname :name (pathname-name path)