Moved package-related code to namespace.lisp, added back *enable-package-system*.
[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 ;; object literals
53 #:create
54 #:with-slots
55
56 ;; macros
57 #:macrolet
58 #:symbol-macrolet
59
60 ;; if
61 #:if
62 #:when
63 #:unless
64
65 ;; single argument statements
66 #:return
67 #:throw
68
69 ;; single argument expressions
70 #:delete
71 #:void
72 #:typeof
73 #:instanceof
74 #:new
75
76 ;; assignment
77 #:setf
78
79 ;; variables
80 #:defvar
81
82 ;; iteration
83 #:for
84 #:doeach
85 #:while
86
87 ;; with
88 #:with
89
90 ;; case
91 #:switch
92 #:case
93 #:default
94
95 ;; try throw catch
96 #:try
97
98 ;; regex literals
99 #:regex
100
101 ;; conditional compilation (IE)
102 #:cc-if)
103 "Symbols exported from both the Parenscript and Javascript packages
104 that are also valid as Parenscript symbols for the corresponding script packages."))
105
106
107
108 (defpackage parenscript.javascript
109 (:use :common-lisp)
110 (:nicknames javascript ps-js)
111 #.(cons :export *shared-symbols-ps-js*)
112 (:export
113 ;; function definition
114 #:%js-defun
115 #:%js-lambda
116 #:%js-slot-value
117 ;; translate
118 #:js-to-strings
119 #:js-to-statement-strings
120 )
121 (:documentation "The package used to define Javascript special forms. Most of Parenscript
122 is defined as macros on top of Javascript special forms"))
123
124 (eval-when (:compile-toplevel :load-toplevel :execute)
125 (defparameter *parenscript-lang-exports*
126 (append
127 *shared-symbols-ps-js*
128 '(
129 ;; package system
130 #:defpackage
131 #:in-package
132
133 ;; function definition
134 #:defun
135 #:lambda
136
137 ;; lambda lists
138 #:&key
139 #:&rest
140 #:&body
141 #:&optional
142 #:&aux
143 #:&environment
144 #:&key-object
145 #:optional-args
146
147 ;; slot access
148 #:with-slots
149 #:slot-value
150
151 ;; eval-when
152 #:eval-when
153 ;; macros
154 #:macrolet
155 #:symbol-macrolet
156 #:define-symbol-macro
157 #:define-script-symbol-macro
158 #:defmacro
159
160 ;; lisp eval
161 #:lisp
162
163 ;; assignment
164 #:setf
165 #:defaultf
166
167 #:let
168
169 ;; iteration
170 #:do
171 #:dotimes
172 #:dolist
173 #:doeach
174 #:while
175
176 ;; v v v STUFF WE SHOULD PROBABLY MOVE TO OTHER LIBS v v v
177
178 ;; CSS
179 #:css
180 #:css-to-string
181 #:css-inline
182 #:css-file
183
184 ;; html generator for javascript
185 #:html
186
187 ;; utils
188 #:do-set-timeout
189 ))
190 "List of (uninterned) symbols. Contains all symbols considerred
191 part of the Parenscript language. These should be exported within
192 both the Lisp package and the script package for Parenscript."))
193
194 (defpackage :parenscript
195 (:use :common-lisp :parenscript.javascript)
196 (:nicknames :js :ps)
197 #.(cons :export *shared-symbols-ps-js*)
198 #.(cons :export *parenscript-lang-exports*)
199 (:export
200 ;; compiler
201 #:compile-script
202 #:compile-script-file
203 #:compile-script-system
204 #:compile-parenscript-file
205 #:compile-parenscript-file-to-string
206 #:script
207 #:script*
208 #:ps
209 #:ps*
210 #:js
211 #:js*
212 #:with-new-compilation-environment ; tentative
213 #:with-compilation-environment ; tentative
214 #:*compilation-environment*
215
216 ;; package system
217 #:find-script-package
218 #:script-intern
219 #:script-export
220 #:find-script-symbol
221 #:comp-env-current-package
222 #:symbol-script-package
223 #:script-package-name
224
225 ;; for parenscript macro definition within lisp
226 #:defscriptmacro
227 #:defpsmacro ; should we use one or the other of these?
228 #:defmacro/ps
229 #:defmacro+ps
230 #:import-macros-from-lisp
231
232 ;; gensym
233 #:with-unique-ps-names
234 #:gen-script-name
235 #:gen-script-name-string
236 #:gen-ps-name
237
238 ;; deprecated interface
239 #:gen-js-name
240 #:gen-js-name-string
241 #:with-unique-js-names
242 #:defjsmacro
243 #:js-compile
244 #:js-inline
245 #:js-inline*
246 #:js-file
247 #:js-script
248 #:js-to-statement-strings
249 ))
250
251 (in-package :parenscript)
252 (import
253 '(defscriptclass
254 define-script-special-form
255 defscriptmacro
256 symbol-to-js
257 script-quote
258 *package-prefix-style*
259 *script-macro-env*
260 compile-to-statement
261 compile-to-block
262 compile-to-symbol
263 compile-to-expression
264 symbol-script-package
265 script-package-name
266 list-join
267 list-to-string
268 append-to-last
269 prepend-to-first
270 string-join
271 val-to-string
272 string-split
273 script-special-form-p
274 make-macro-env-dictionary
275 script-equal
276 compile-script-form
277 )
278 :parenscript.javascript)
279
280 (defpackage parenscript.reader
281 (:nicknames parenscript-reader)
282 (:use :common-lisp :parenscript)
283 (:shadow #:readtablep
284 #:readtable-case
285 #:copy-readtable
286 #:get-macro-character
287 #:get-dispatch-macro-character
288 #:set-macro-character
289 #:set-dispatch-macro-character
290 #:make-dispatch-macro-character
291 #:set-syntax-from-char
292 #:read-preserving-whitespace
293 #:read
294 #:read-from-string
295 #:read-delimited-list
296 #:backquote-comma-dot
297 #:backquote
298 #:backquote-comma
299 #:backquote-comma-at
300
301 #:*read-eval*
302 #:*read-base*
303 #:*read-default-float-format*
304 #:*read-suppress*
305 #:*readtable*
306 #:*read-suppress*
307 #:*reader-error*
308 #:*read-suppress*
309
310 #:readtable
311 #:backquote
312 #:reader-error)
313 (:export
314 #:read
315 #:read-from-string
316 #:read-delimited-list)
317 (:documentation "The Parenscript reader. Used for reading Parenscript
318 forms."))
319
320 (defpackage parenscript.global
321 (:nicknames "GLOBAL")
322 (:documentation "Symbols interned in the global package are serialized in Javascript
323 as non-prefixed identifiers."))
324
325 (defpackage parenscript.user
326 (:use :parenscript)
327 (:nicknames ps-user parenscript-user)
328 (:documentation "The default package a user is inside of when compiling code."))
329
330 (defpackage parenscript.asdf
331 (:use :parenscript :asdf :common-lisp)
332 (:documentation "ASDF extensions that help compile and use Parenscript systems."))
333
334 (defpackage parenscript.non-prefixed (:nicknames ps.non-prefixed))
335 (defpackage parenscript.ps-gensyms)