summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormRnea <akannemre@gmail.com>2024-08-22 01:13:28 +0300
committermRnea <akannemre@gmail.com>2024-08-22 01:13:28 +0300
commit3fc13bcdddd09065a9dae1ec054ab8af56c95109 (patch)
tree9bd222aa7a2bac3675fc89ef11a9afc7db74e900
parent4c8409da359cf0da14214ccc939c10ac759f76a5 (diff)
added some string escape chars and include path
-rw-r--r--cl-forth.lisp18
-rw-r--r--kurt.asd2
-rw-r--r--test/tests.lisp9
3 files changed, 21 insertions, 8 deletions
diff --git a/cl-forth.lisp b/cl-forth.lisp
index ec2a0f3..b0bcdbd 100644
--- a/cl-forth.lisp
+++ b/cl-forth.lisp
@@ -20,9 +20,13 @@
(iter (for ch = (read-char stream))
(cond ((char= ch #\")
(finish))
- ((and (char= ch #\\) (char= (peek-char nil stream) #\n))
- (read-char stream)
- (write-char #\Newline str))
+ ((char= ch #\\)
+ (case (peek-char nil stream)
+ (#\n (write-char #\Newline str))
+ (#\0 (write-char (code-char 0) str))
+ (#\\ (write-char #\\ str))
+ (#\" (write-char #\" str)))
+ (read-char stream))
(t (write-char ch str))))))
(defun read-character (stream line-num line col)
@@ -214,11 +218,17 @@
((eq :son (car tok)) (reverse makrodef))
(push tok makrodef)))))
+(defun find-library (name)
+ (or (probe-file (merge-pathnames name sb-ext:*core-pathname*))
+ (probe-file (merge-pathnames name (from-root "test/")))
+ (probe-file (merge-pathnames name (from-root "lib/")))
+ (error "library ~a could not be found." name)))
+
(defmethod parse-op ((parser parser) token (id (eql :kütüphane)))
"Library and the executable must be in the same location, no other search is made currently."
(let ((file (car (read-token parser))))
(setf (tokens parser)
- (append (lex-file (merge-pathnames file sb-ext:*core-pathname*))
+ (append (lex-file (find-library file))
(tokens parser)))))
(defun parse-tokens (tokens)
diff --git a/kurt.asd b/kurt.asd
index 517c5bb..f97bd7d 100644
--- a/kurt.asd
+++ b/kurt.asd
@@ -14,5 +14,5 @@
(:file "main")
(:file "test/tests"))
:build-operation "program-op"
- :build-pathname "test/kurt"
+ :build-pathname "kurt"
:entry-point "kurt:main")
diff --git a/test/tests.lisp b/test/tests.lisp
index 0907a58..4c3ff18 100644
--- a/test/tests.lisp
+++ b/test/tests.lisp
@@ -35,7 +35,7 @@
path
(from-root path)))
(successful nil))
- (with-open-file (str abs-path)
+ (with-open-file (str abs-path :external-format :utf-8)
(unless (string-equal "test" (second (uiop:split-string
(read-line str)
:separator '(#\Space))))
@@ -74,8 +74,11 @@
(run-test file :target target))))
(remove-if-not (lambda (file)
(string= "kurt" (pathname-type file)))
- (cl-fad:list-directory
- (from-root "test"))))
+ (append
+ (cl-fad:list-directory
+ (from-root "test"))
+ (cl-fad:list-directory
+ (from-root "examples/euler")))))
counting (eq t success?) into succs
counting (null success?) into fails
finally (format t "~a success, ~a fail~%" succs fails)))