Commit | Line | Data |
---|---|---|
8e198a08 | 1 | (in-package :cl-user) |
171bbab3 RD |
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 | |
bbea4c83 | 13 | "NIL" |
171bbab3 RD |
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 | ||
171bbab3 RD |
52 | ;; object literals |
53 | #:create | |
171bbab3 RD |
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 | ||
8e198a08 | 107 | |
5aa10005 | 108 | (defpackage parenscript.javascript |
83cb67fd | 109 | (:use :common-lisp) |
5aa10005 | 110 | (:nicknames javascript ps-js) |
171bbab3 | 111 | #.(cons :export *shared-symbols-ps-js*) |
5aa10005 | 112 | (:export |
46f794a4 RD |
113 | ;; function definition |
114 | #:%js-defun | |
115 | #:%js-lambda | |
bbea4c83 | 116 | #:%js-slot-value |
5aa10005 RD |
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 | ||
171bbab3 RD |
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 | ||
46f794a4 RD |
133 | ;; function definition |
134 | #:defun | |
135 | #:lambda | |
136 | ||
46f794a4 RD |
137 | ;; lambda lists |
138 | #:&key | |
139 | #:&rest | |
140 | #:&body | |
141 | #:&optional | |
142 | #:&aux | |
143 | #:&environment | |
bbea4c83 | 144 | #:&key-object |
d989d711 | 145 | #:optional-args |
46f794a4 | 146 | |
bbea4c83 RD |
147 | ;; slot access |
148 | #:with-slots | |
149 | #:slot-value | |
46f794a4 | 150 | |
171bbab3 RD |
151 | ;; eval-when |
152 | #:eval-when | |
153 | ;; macros | |
154 | #:macrolet | |
155 | #:symbol-macrolet | |
46f794a4 RD |
156 | #:define-symbol-macro |
157 | #:define-script-symbol-macro | |
158 | #:defmacro | |
171bbab3 RD |
159 | |
160 | ;; lisp eval | |
161 | #:lisp | |
162 | ||
163 | ;; assignment | |
164 | #:setf | |
46f794a4 RD |
165 | #:defaultf |
166 | ||
171bbab3 RD |
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 | ||
171bbab3 RD |
184 | ;; html generator for javascript |
185 | #:html | |
dbb7017b VS |
186 | |
187 | ;; utils | |
188 | #:do-set-timeout | |
171bbab3 RD |
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 | ||
5aa10005 RD |
194 | (defpackage :parenscript |
195 | (:use :common-lisp :parenscript.javascript) | |
9da682ca | 196 | (:nicknames :js :ps) |
171bbab3 RD |
197 | #.(cons :export *shared-symbols-ps-js*) |
198 | #.(cons :export *parenscript-lang-exports*) | |
8e198a08 | 199 | (:export |
8e198a08 | 200 | ;; compiler |
9da682ca | 201 | #:compile-script |
171bbab3 | 202 | #:compile-script-file |
3199f8b6 | 203 | #:compile-script-system |
5aa10005 RD |
204 | #:compile-parenscript-file |
205 | #:compile-parenscript-file-to-string | |
9da682ca | 206 | #:script |
7590646c VS |
207 | #:script* |
208 | #:ps | |
209 | #:ps* | |
b5be3f57 VS |
210 | #:js |
211 | #:js* | |
9da682ca RD |
212 | #:with-new-compilation-environment ; tentative |
213 | #:with-compilation-environment ; tentative | |
5aa10005 RD |
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 | |
9da682ca RD |
224 | |
225 | ;; for parenscript macro definition within lisp | |
171bbab3 RD |
226 | #:defscriptmacro |
227 | #:defpsmacro ; should we use one or the other of these? | |
a19d2bde VS |
228 | #:defmacro/ps |
229 | #:defmacro+ps | |
ca493d55 | 230 | #:import-macros-from-lisp |
0b7a1d2f | 231 | |
7590646c VS |
232 | ;; gensym |
233 | #:with-unique-ps-names | |
234 | #:gen-script-name | |
235 | #:gen-script-name-string | |
236 | #:gen-ps-name | |
551080b7 | 237 | |
9da682ca | 238 | ;; deprecated interface |
7590646c VS |
239 | #:gen-js-name |
240 | #:gen-js-name-string | |
241 | #:with-unique-js-names | |
9da682ca RD |
242 | #:defjsmacro |
243 | #:js-compile | |
9da682ca RD |
244 | #:js-inline |
245 | #:js-inline* | |
246 | #:js-file | |
247 | #:js-script | |
9da682ca | 248 | #:js-to-statement-strings |
171bbab3 | 249 | )) |
5aa10005 RD |
250 | |
251 | (in-package :parenscript) | |
5aa10005 RD |
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 | |
7590646c | 275 | script-equal |
5aa10005 RD |
276 | compile-script-form |
277 | ) | |
278 | :parenscript.javascript) | |
279 | ||
280 | (defpackage parenscript.reader | |
281 | (:nicknames parenscript-reader) | |
282 | (:use :common-lisp :parenscript) | |
171bbab3 RD |
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 | |
5aa10005 | 300 | |
171bbab3 RD |
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* | |
5aa10005 | 309 | |
171bbab3 RD |
310 | #:readtable |
311 | #:backquote | |
312 | #:reader-error) | |
5aa10005 | 313 | (:export |
171bbab3 RD |
314 | #:read |
315 | #:read-from-string | |
316 | #:read-delimited-list) | |
317 | (:documentation "The Parenscript reader. Used for reading Parenscript | |
318 | forms.")) | |
5aa10005 RD |
319 | |
320 | (defpackage parenscript.global | |
171bbab3 | 321 | (:nicknames "GLOBAL") |
5aa10005 RD |
322 | (:documentation "Symbols interned in the global package are serialized in Javascript |
323 | as non-prefixed identifiers.")) | |
324 | ||
325 | (defpackage parenscript.user | |
171bbab3 | 326 | (:use :parenscript) |
a9fce0a7 RD |
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) | |
905f534e VS |
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) |