Prims - Implement turtles-here
[clnl] / src / main / package.lisp
1 (defpackage #:clnl (:use :common-lisp)
2  (:export
3   #:run #:boot #:run-commands #:run-reporter #:*model-package*
4   #:model->multi-form-lisp #:model->single-form-lisp)
5  (:documentation
6   "Main CLNL package
7
8 The entry point for general purpose clnl startup, as well as
9 the place that ties all the parts together into a cohesive whole."))
10
11 (defpackage #:clnl-parser
12  (:use :common-lisp)
13  (:export #:parse)
14  (:documentation
15   "CLNL Parser
16
17 All the code to convert the list of tokens coming from the lexer
18 into an ast that can be transpiled later."))
19
20 (defpackage #:clnl-code-parser
21  (:use :common-lisp)
22  (:export #:parse #:globals #:procedures #:turtles-own-vars #:patches-own-vars)
23  (:documentation
24   "CLNL Code Parser
25
26 A parser specifically for code from NetLogo models, that turns the lexed
27 ast from an entire structured file into something more defined.
28
29 This is different from the general parser (in clnl-parser) in that
30 it's made for parsing the code section of nlogo files, and so works
31 outside of the constraints.  In NetLogo, I believe this is analagous
32 to the StructureParser, but I'm guessing there's weird overlap with
33 other things."))
34
35 (defpackage #:clnl-random
36  (:use :common-lisp)
37  (:shadow #:export)
38  (:export #:export #:set-seed #:next-int #:next-double #:next-long)
39  (:documentation
40   "Wrapper around mt19937.
41
42 mt19937 implements a merseinne twister that must be adapted a little in
43 order to match the implementation in the main NetLogo codebase which tries
44 to match how java.util.Random works.  Turtles, all the way down."))
45
46 (defpackage #:clnl-transpiler
47  (:use :common-lisp)
48  (:export #:transpile #:reporter-p #:command-list-p)
49  (:documentation
50   "CLNL Transpiler
51
52 The transpiler is responsible for taking an ast and turning it into valid CL code
53 targeting the nvm.  Here is where start to care about commands versus reporters
54 and ensuring that things are in the right place.  The reason we wait until here
55 is because we want to allow someone else to play with the AST before handing it off
56 to us.  For instance, the command center wants to add \"show\" to reporters, and
57 the users dictate based on entry point whether they are expecting a command
58 or a reporter.  So monitors can say \"hey, transpile this reporter\" and we'll check
59 to make sure it actually is.
60
61 Furthermore, the lisp code that any netlogo code would be transpiled to should
62 use exported symbols, such that anyone writing NetLogo code in lisp could use
63 the nvm in the same way that comes out of this transpiler
64 All the code to convert the list of tokens coming from the lexer
65 into an ast that can be transpiled later."))
66
67 (defpackage #:clnl-nvm
68  (:use :common-lisp)
69  (:shadow #:random #:count)
70  (:export #:export-world #:create-world #:current-state #:with-stop-handler
71   ; API as used by transpiled NetLogo programs
72   #:agent-value
73   #:ask
74   #:clear-all
75   #:count
76   #:create-turtles
77   #:die
78   #:display
79   #:hatch
80   #:of
81   #:forward
82   #:lookup-color
83   #:one-of
84   #:patches
85   #:reset-ticks
86   #:random
87   #:random-float
88   #:random-xcor
89   #:random-ycor
90   #:set-default-shape
91   #:setxy
92   #:show
93   #:stop
94   #:turtles
95   #:turtles-here
96   #:tick
97   #:ticks
98   #:turn-right #:turn-left
99   #:with)
100  (:documentation
101   "CLNL NVM
102
103 NetLogo Virtual Machine: the simulation engine."))
104
105 (defpackage #:clnl-lexer
106  (:use :common-lisp)
107  (:export #:lex)
108  (:documentation
109   "CLNL Lexer
110
111 The primary code responsible for tokenizing NetLogo code."))
112
113 (defpackage #:clnl-interface
114  (:use :common-lisp)
115  (:export #:run #:export-view #:initialize)
116  (:documentation
117   "CLNL Interface
118
119 The NetLogo view interface using opengl.  This is responsible for taking the
120 current state of the enging and displaying it.  Will not house any interface
121 components."))
122
123 (defpackage #:clnl-cli
124  (:use :common-lisp :cl-charms/low-level)
125  (:export #:run)
126  (:documentation
127   "CLNL CLI
128
129 The main NetLogo interface for interacting with the program.  Since CLNL is
130 a command line interface program with a view for display purposes only, this
131 is where all the features that the traditional NetLogo UI lives."))
132
133 (defpackage #:clnl-model
134  (:use :common-lisp)
135  (:export #:default-model #:read-from-nlogo #:world-dimensions #:widget-globals #:code)
136  (:documentation
137   "CLNL Model
138
139 The representation, parsing, and serializing of NetLogo model files, including
140 all of the sections, and subsections held within.  This package houses not only
141 the code to read and write .nlogo files, but also the living state of the model
142 as clnl runs."))
143
144 (defpackage #:clnl-default-model-package
145  (:use :common-lisp)
146  (:shadow #:go))