Add documentation checker for exported symbols
[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)))
8                (format t "Via lexing, AST for~%~S~% became~%~S~%~%" str ast) ast))
9    (parsed-ast (let ((ast (clnl-parser:parse lexed-ast)))
10                 (format t "Via parsing, AST for~%~S~% became~%~S~%~%" lexed-ast ast) ast))
11    (transpiled-ast (let ((ast (clnl-transpiler:transpile-commands parsed-ast)))
12                     (format t "Via transpiling, AST for~%~S~% became~%~S~%" parsed-ast ast) ast)))
13   (eval transpiled-ast)))
14
15 (defun p (result) result)
16
17 (defun run ()
18  "RUN => RESULT
19
20 ARGUMENTS AND VALUES:
21
22   RESULT: undefined, the system terminates at the end of the loop
23
24 DESCRIPTION:
25
26   RUN implements a very simple REPL."
27  (loop
28   :for str := (progn (format t "> ") (force-output) (read-line))
29   :while str
30   :do (p (e (r str))))
31  (sb-ext:exit))
32
33 (defun boot ()
34  "BOOT => RESULT
35
36 ARGUMENTS AND VALUES:
37
38   RESULT: undefined
39
40 DESCRIPTION:
41
42   BOOT does exactly that, boots the clnl system in a clean state.  The seed
43   is set so that multiple runs will evaluate to the same."
44  (clnl-random:set-seed 15)
45  (clnl-nvm:create-world))
46
47 (defun run-commands (cmds)
48  "RUN-COMMANDS CMDS => RESULT
49
50 ARGUMENTS AND VALUES:
51
52   CMDS: A string that may have one more NetLogo commands
53   RESULT: undefined
54
55 DESCRIPTION:
56
57   RUN-COMMANDS will take NetLogo commands, put them through the various
58   stages need to turn them into Common Lisp code, and run it."
59  (eval (clnl-transpiler:transpile-commands (clnl-parser:parse (clnl-lexer:lex cmds)))))
60
61 (defun run-reporter (reporter)
62  "RUN-REPORTER REPORTER => RESULT
63
64 ARGUMENTS AND VALUES:
65
66   REPORTER: A string that should have only one reporter
67   RESULT: The value reported by the NVM
68
69 DESCRIPTION:
70
71   RUN-REPORTER will take a NetLogo REPORTER, put it through the various
72   stages need to turn them into Common Lisp code, run it, and return the RESULT."
73  (eval (clnl-transpiler:transpile-reporter (car (clnl-parser:parse (clnl-lexer:lex reporter))))))