added some string escape chars and include path

This commit is contained in:
2024-08-22 01:13:28 +03:00
parent 4c8409da35
commit 3fc13bcddd
3 changed files with 21 additions and 8 deletions

View File

@@ -20,9 +20,13 @@
(iter (for ch = (read-char stream)) (iter (for ch = (read-char stream))
(cond ((char= ch #\") (cond ((char= ch #\")
(finish)) (finish))
((and (char= ch #\\) (char= (peek-char nil stream) #\n)) ((char= ch #\\)
(read-char stream) (case (peek-char nil stream)
(write-char #\Newline str)) (#\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)))))) (t (write-char ch str))))))
(defun read-character (stream line-num line col) (defun read-character (stream line-num line col)
@@ -214,11 +218,17 @@
((eq :son (car tok)) (reverse makrodef)) ((eq :son (car tok)) (reverse makrodef))
(push tok 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))) (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." "Library and the executable must be in the same location, no other search is made currently."
(let ((file (car (read-token parser)))) (let ((file (car (read-token parser))))
(setf (tokens parser) (setf (tokens parser)
(append (lex-file (merge-pathnames file sb-ext:*core-pathname*)) (append (lex-file (find-library file))
(tokens parser))))) (tokens parser)))))
(defun parse-tokens (tokens) (defun parse-tokens (tokens)

View File

@@ -14,5 +14,5 @@
(:file "main") (:file "main")
(:file "test/tests")) (:file "test/tests"))
:build-operation "program-op" :build-operation "program-op"
:build-pathname "test/kurt" :build-pathname "kurt"
:entry-point "kurt:main") :entry-point "kurt:main")

View File

@@ -35,7 +35,7 @@
path path
(from-root path))) (from-root path)))
(successful nil)) (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 (unless (string-equal "test" (second (uiop:split-string
(read-line str) (read-line str)
:separator '(#\Space)))) :separator '(#\Space))))
@@ -74,8 +74,11 @@
(run-test file :target target)))) (run-test file :target target))))
(remove-if-not (lambda (file) (remove-if-not (lambda (file)
(string= "kurt" (pathname-type file))) (string= "kurt" (pathname-type file)))
(append
(cl-fad:list-directory (cl-fad:list-directory
(from-root "test")))) (from-root "test"))
(cl-fad:list-directory
(from-root "examples/euler")))))
counting (eq t success?) into succs counting (eq t success?) into succs
counting (null success?) into fails counting (null success?) into fails
finally (format t "~a success, ~a fail~%" succs fails))) finally (format t "~a success, ~a fail~%" succs fails)))