init commit

This commit is contained in:
Moritz Gmeiner 2024-09-07 01:51:08 +02:00
commit 9a17038479
11 changed files with 71 additions and 0 deletions

BIN
.vscode/alive/fasl/tmp.fasl vendored Normal file

Binary file not shown.

11
.vscode/alive/fasl/tmp.lisp vendored Normal file
View file

@ -0,0 +1,11 @@
(in-package :cl-lox)
(defstruct code-pos
(line 1 :type integer)
(col 0 :type integer))
(defstruct token
(code-pos (make-code-pos) :type code-pos)
token-type
(data nil))

1
.vscode/alive/repl-history.json vendored Normal file
View file

@ -0,0 +1 @@
[{"pkgName":"cl-user","text":"(describe token-type)"},{"pkgName":"cl-user","text":"(describe 'token-type)"},{"pkgName":"cl-user","text":"(make-code-pos)"},{"pkgName":"cl-user","text":"(cl-lox::code-pos)"},{"pkgName":"cl-user","text":"(code-pos)"},{"pkgName":"cl-user","text":"(code-pos"},{"pkgName":"cl-user","text":"(typep \"asdf\" 'string)"},{"pkgName":"cl-user","text":"(describe 'integer)"},{"pkgName":"cl-user","text":"(describe 'string)"},{"pkgName":"cl-user","text":"'string"},{"pkgName":"cl-user","text":"string"},{"pkgName":"cl-user","text":"(type-of xyz)"},{"pkgName":"cl-user","text":"(setf xyz \"asdf\")"},{"pkgName":"cl-user","text":"xyz"},{"pkgName":"cl-user","text":"(defvar xyz 123)"},{"pkgName":"cl-user","text":"(cl-lox::scan-tokens 3)"},{"pkgName":"cl-user","text":"(scan-tokens 3)"},{"pkgName":"cl-user","text":"(cl-lox::run-repl)"},{"pkgName":"cl-user","text":"(cl-lox::run-file :path nil)"},{"pkgName":"cl-user","text":"(cl-lox:run-repl)"},{"pkgName":"cl-user","text":"(run-repl)"},{"pkgName":"cl-user","text":"(length argv)"},{"pkgName":"cl-user","text":"argv"},{"pkgName":"cl-user","text":"4"},{"pkgName":"cl-user","text":"(argv)"},{"pkgName":"cl-user","text":"(defvar argv (uiop:command-line-arguments))"},{"pkgName":"cl-user","text":"(define argv (uiop:command-line-arguments))"},{"pkgName":"cl-user","text":"(uiop:command-line-arguments)"},{"pkgName":"cl-user","text":"(cl-lox:main)"},{"pkgName":"cl-user","text":"(asdf:make :cl-lox)"},{"pkgName":"cl-user","text":"(my-command-line)"},{"pkgName":"cl-user","text":"(cl-lox:my-command-line)"},{"pkgName":"cl-user","text":"(cl-lox:hello)"},{"pkgName":"cl-user","text":"(hello)"},{"pkgName":"cl-user","text":"(ql:quickload \"cl-ppcre\")"},{"pkgName":"cl-user","text":"(ql:quickload cl-ppcre)"}]

6
.vscode/settings.json vendored Normal file
View file

@ -0,0 +1,6 @@
{
"editor.formatOnType": true,
"[commonlisp]": {
"editor.wordSeparators": "`|;:'\",()"
}
}

8
cl-lox.asd Normal file
View file

@ -0,0 +1,8 @@
(asdf:defsystem "cl-lox"
:description "Lox implementation in Common Lisp"
:serial t
:depends-on ()
:components ((:file "package")
(:file "src/cl-lox")
(:file "src/token")
(:file "src/lexer")))

4
package.lisp Normal file
View file

@ -0,0 +1,4 @@
(defpackage cl-lox
(:use cl)
(:export #:main)
(:export #:make-exe))

11
src/cl-lox.lisp Normal file
View file

@ -0,0 +1,11 @@
(in-package :cl-lox)
(defun main ()
(let* ((argv (uiop:command-line-arguments)) (argc (length argv)))
(cond ((= argc 0) (run-repl))
((= argc 1) (run-file :path (car argv))))))
(defun make-exe ()
(sb-ext:save-lisp-and-die "cl-lox" :toplevel #'main :executable t))

6
src/lexer.lisp Normal file
View file

@ -0,0 +1,6 @@
(in-package :cl-lox)
(defun scan-tokens (source)
(declare (string source)
(ignore source)))

13
src/run.lisp Normal file
View file

@ -0,0 +1,13 @@
(in-package :cl-lox)
(defun run-file (&key path)
(let ((source (uiop:read-file-string path)))
(run source)))
(defun run-repl ())
(defun run (source)
(declare (string source)
(ignore source)))

BIN
src/token.fasl Normal file

Binary file not shown.

11
src/token.lisp Normal file
View file

@ -0,0 +1,11 @@
(in-package :cl-lox)
(defstruct code-pos
(line 1 :type integer)
(col 0 :type integer))
(defstruct token
(code-pos (make-code-pos) :type code-pos)
token-type
(data nil))