added ops for C codegen

This commit is contained in:
2024-08-09 11:41:14 +03:00
parent 1056b74b11
commit b574944656
3 changed files with 99 additions and 40 deletions

View File

@@ -34,7 +34,7 @@
(collect (read-line str)))
(t (finish)))))))
(defun run-test (path)
(defun run-test (path &key (target :nasm))
"File must begin with 2 comments:
First must be TEST
Second must eval to the expected result"
@@ -49,8 +49,11 @@
(return-from run-test 'not-test))
(let ((expected-output (eval (read-form-comment str))))
(generate-program (parse-tokens (lex-stream str))
:path (change-file-type abs-path "asm")
:compile t :silence t)
:path (change-file-type abs-path (case target
(:nasm "asm")
(:c "c")))
:compile t :silence t
:target target)
(let ((output (run (list (drop-file-type abs-path))
:output :string :silence t)))
(format t "testing ~a... " (pathname-name path))