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