Code - turtles-own
[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)
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   #:tick
96   #:ticks
97   #:turn-right #:turn-left
98   #:with)
99  (:documentation
100   "CLNL NVM
101
102 NetLogo Virtual Machine: the simulation engine."))
103
104 (defpackage #:clnl-lexer
105  (:use :common-lisp)
106  (:export #:lex)
107  (:documentation
108   "CLNL Lexer
109
110 The primary code responsible for tokenizing NetLogo code."))
111
112 (defpackage #:clnl-interface
113  (:use :common-lisp)
114  (:export #:run #:export-view #:initialize)
115  (:documentation
116   "CLNL Interface
117
118 The NetLogo view interface using opengl.  This is responsible for taking the
119 current state of the enging and displaying it.  Will not house any interface
120 components."))
121
122 (defpackage #:clnl-cli
123  (:use :common-lisp :cl-charms/low-level)
124  (:export #:run)
125  (:documentation
126   "CLNL CLI
127
128 The main NetLogo interface for interacting with the program.  Since CLNL is
129 a command line interface program with a view for display purposes only, this
130 is where all the features that the traditional NetLogo UI lives."))
131
132 (defpackage #:clnl-model
133  (:use :common-lisp)
134  (:export #:default-model #:read-from-nlogo #:world-dimensions #:widget-globals #:code)
135  (:documentation
136   "CLNL Model
137
138 The representation, parsing, and serializing of NetLogo model files, including
139 all of the sections, and subsections held within.  This package houses not only
140 the code to read and write .nlogo files, but also the living state of the model
141 as clnl runs."))
142
143 (defpackage #:clnl-default-model-package
144  (:use :common-lisp)
145  (:shadow #:go))