Rename to clnl, add documentation
[clnl] / src / main / main.lisp
1 (in-package #:clnl)
2
3 (defun e (ast) ast)
4
5 (defun r (str)
6  (let*
7   ((lexed-ast (let ((ast (clnl-lexer:lex str))) (format t "Via lexing, AST for~%~S~% became~%~S~%~%" str ast) ast))
8    (parsed-ast (let ((ast (clnl-parser:parse lexed-ast))) (format t "Via parsing, AST for~%~S~% became~%~S~%~%" lexed-ast ast) ast))
9    (transpiled-ast (let ((ast (clnl-transpiler:transpile-commands parsed-ast))) (format t "Via transpiling, AST for~%~S~% became~%~S~%" parsed-ast ast) ast)))
10   (eval transpiled-ast)))
11
12 (defun p (result) result)
13
14 (defun run ()
15  (loop for str = (progn (format t "> ") (force-output) (read-line))
16        while str
17        do (p (e (r str)))))
18
19 (defun boot ()
20  (clnl-random:set-seed 15)
21  (clnl-nvm:create-world)
22  )
23
24 (defun run-commands (cmds)
25  (eval (clnl-transpiler:transpile-commands (clnl-parser:parse  (clnl-lexer:lex cmds)))))
26
27 (defun run-reporter (reporter)
28  (eval (clnl-transpiler:transpile-reporter (car (clnl-parser:parse (clnl-lexer:lex reporter))))))