Added functions to set up and tear down a persistent compilation environment.
[clinton/parenscript.git] / src / package.lisp
1 (in-package :cl-user)
2 ;;;; Package definitions for the Parenscript
3 ;; #:
4
5 (eval-when (:compile-toplevel :load-toplevel)
6 ;; exports shared between PARENSCRIPT and PARENSCRIPT.JAVASCRIPT
7 (defparameter *shared-symbols-ps-js*
8 '(
9 ;; literals
10 #:t
11 #:f
12 #:true
13 #:nil
14 #:this
15 #:false
16 #:undefined
17
18 ;; keywords
19 #:break
20 #:continue
21
22 ;; array literals
23 #:array
24 #:list
25 #:aref
26 #:make-array
27
28 ;; operators
29 #:! #:not #:~
30 #:* #:/ #:%
31 #:+ #:-
32 #:<< #:>>
33 #:>>>
34 #:< #:> #:<= #:>=
35 #:in
36 #:eql #:== #:!= #:=
37 #:=== #:!==
38 #:&
39 #:^
40 #:\|
41 #:\&\& #:and
42 #:\|\| #:or
43 #:>>= #:<<=
44 #:*= #:/= #:%= #:+= #:\&= #:^= #:\|= #:~=
45 #:++ #:--
46 #:1+ #:1-
47 #:incf #:decf
48
49 ;; body forms
50 #:progn
51
52 ;; function definition
53 #:defun
54 #:lambda
55
56 ;; object literals
57 #:create
58 #:slot-value
59 #:with-slots
60
61 ;; macros
62 #:macrolet
63 #:symbol-macrolet
64
65 ;; if
66 #:if
67 #:when
68 #:unless
69
70 ;; single argument statements
71 #:return
72 #:throw
73
74 ;; single argument expressions
75 #:delete
76 #:void
77 #:typeof
78 #:instanceof
79 #:new
80
81 ;; assignment
82 #:setf
83
84 ;; variables
85 #:defvar
86
87 ;; iteration
88 #:for
89 #:doeach
90 #:while
91
92 ;; with
93 #:with
94
95 ;; case
96 #:switch
97 #:case
98 #:default
99
100 ;; try throw catch
101 #:try
102
103 ;; regex literals
104 #:regex
105
106 ;; conditional compilation (IE)
107 #:cc-if)
108 "Symbols exported from both the Parenscript and Javascript packages
109 that are also valid as Parenscript symbols for the corresponding script packages."))
110
111
112
113 (defpackage parenscript.javascript
114 (:use :common-lisp)
115 (:nicknames javascript ps-js)
116 #.(cons :export *shared-symbols-ps-js*)
117 (:export
118 ;; translate
119 #:js-to-strings
120 #:js-to-statement-strings
121 )
122 (:documentation "The package used to define Javascript special forms. Most of Parenscript
123 is defined as macros on top of Javascript special forms"))
124
125 (eval-when (:compile-toplevel :load-toplevel :execute)
126 (defparameter *parenscript-lang-exports*
127 (append
128 *shared-symbols-ps-js*
129 '(
130 ;; package system
131 #:defpackage
132 #:in-package
133
134 ;; eval-when
135 #:eval-when
136 ;; macros
137 #:macrolet
138 #:symbol-macrolet
139
140 ;; lisp eval
141 #:lisp
142
143 ;; assignment
144 #:setf
145
146 #:let
147
148 ;; iteration
149 #:do
150 #:dotimes
151 #:dolist
152 #:doeach
153 #:while
154
155 ;; v v v STUFF WE SHOULD PROBABLY MOVE TO OTHER LIBS v v v
156
157 ;; CSS
158 #:css
159 #:css-to-string
160 #:css-inline
161 #:css-file
162
163 ;; html generator for javascript
164 #:html
165 ))
166 "List of (uninterned) symbols. Contains all symbols considerred
167 part of the Parenscript language. These should be exported within
168 both the Lisp package and the script package for Parenscript."))
169
170 (defpackage :parenscript
171 (:use :common-lisp :parenscript.javascript)
172 (:nicknames :js :ps)
173 #.(cons :export *shared-symbols-ps-js*)
174 #.(cons :export *parenscript-lang-exports*)
175 (:export
176 ;; compiler
177 #:compile-script
178 #:compile-script-file
179 #:compile-script-system
180 #:compile-parenscript-file
181 #:compile-parenscript-file-to-string
182 #:script
183 #:script*
184 #:ps
185 #:ps*
186 #:js
187 #:js*
188 #:with-new-compilation-environment ; tentative
189 #:with-compilation-environment ; tentative
190 #:*compilation-environment*
191
192 ;; package system
193 #:*enable-package-system*
194 #:find-script-package
195 #:script-intern
196 #:script-export
197 #:find-script-symbol
198 #:comp-env-current-package
199 #:symbol-script-package
200 #:script-package-name
201
202 ;; for parenscript macro definition within lisp
203 #:defscriptmacro
204 #:defpsmacro ; should we use one or the other of these?
205 #:defmacro/ps
206 #:defmacro+ps
207 #:import-macros-from-lisp
208
209 ;; gensym
210 #:with-unique-ps-names
211 #:gen-script-name
212 #:gen-script-name-string
213 #:gen-ps-name
214
215 ;; deprecated interface
216 #:gen-js-name
217 #:gen-js-name-string
218 #:with-unique-js-names
219 #:defjsmacro
220 #:js-compile
221 #:js-inline
222 #:js-inline*
223 #:js-file
224 #:js-script
225 #:js-to-statement-strings
226 #:setup-persistent-compilation-environment
227 #:clear-persistent-compilation-environment
228 ))
229
230 (in-package :parenscript)
231 (import
232 '(defscriptclass
233 define-script-special-form
234 defscriptmacro
235 symbol-to-js
236 script-quote
237 *package-prefix-style*
238 *script-macro-env*
239 compile-to-statement
240 compile-to-block
241 compile-to-symbol
242 compile-to-expression
243 symbol-script-package
244 script-package-name
245 list-join
246 list-to-string
247 append-to-last
248 prepend-to-first
249 string-join
250 val-to-string
251 string-split
252 script-special-form-p
253 make-macro-env-dictionary
254 script-equal
255 compile-script-form
256 )
257 :parenscript.javascript)
258
259 (defpackage parenscript.reader
260 (:nicknames parenscript-reader)
261 (:use :common-lisp :parenscript)
262 (:shadow #:readtablep
263 #:readtable-case
264 #:copy-readtable
265 #:get-macro-character
266 #:get-dispatch-macro-character
267 #:set-macro-character
268 #:set-dispatch-macro-character
269 #:make-dispatch-macro-character
270 #:set-syntax-from-char
271 #:read-preserving-whitespace
272 #:read
273 #:read-from-string
274 #:read-delimited-list
275 #:backquote-comma-dot
276 #:backquote
277 #:backquote-comma
278 #:backquote-comma-at
279
280 #:*read-eval*
281 #:*read-base*
282 #:*read-default-float-format*
283 #:*read-suppress*
284 #:*readtable*
285 #:*read-suppress*
286 #:*reader-error*
287 #:*read-suppress*
288
289 #:readtable
290 #:backquote
291 #:reader-error)
292 (:export
293 #:read
294 #:read-from-string
295 #:read-delimited-list)
296 (:documentation "The Parenscript reader. Used for reading Parenscript
297 forms."))
298
299 (defpackage parenscript.global
300 (:nicknames "GLOBAL")
301 (:documentation "Symbols interned in the global package are serialized in Javascript
302 as non-prefixed identifiers."))
303
304 (defpackage parenscript.user
305 (:use :parenscript)
306 (:nicknames ps-user parenscript-user)
307 (:documentation "The default package a user is inside of when compiling code."))
308
309 (defpackage parenscript.asdf
310 (:use :parenscript :asdf :common-lisp)
311 (:documentation "ASDF extensions that help compile and use Parenscript systems."))