Changed script-* to ps-* across the board for consistency.
authorTravis Cross <tc@traviscross.com>
Sat, 5 Apr 2008 06:36:29 +0000 (06:36 +0000)
committerTravis Cross <tc@traviscross.com>
Sat, 5 Apr 2008 06:36:29 +0000 (06:36 +0000)
src/compilation-interface.lisp
src/compiler.lisp
src/printer.lisp
src/special-forms.lisp

index 96b4cff..bf60a36 100644 (file)
@@ -1,10 +1,10 @@
 (in-package :parenscript)
 
-(defun compile-script (script-form &key (output-stream nil))
-  "Compiles the Parenscript form SCRIPT-FORM into Javascript.
+(defun compile-script (ps-form &key (output-stream nil))
+  "Compiles the Parenscript form PS-FORM into Javascript.
 If OUTPUT-STREAM is NIL, then the result is a string; otherwise code
 is output to the OUTPUT-STREAM stream."
-  (parenscript-print (compile-parenscript-form script-form :expecting :statement) output-stream))
+  (parenscript-print (compile-parenscript-form ps-form :expecting :statement) output-stream))
 
 (defmacro ps (&body body)
   "Given Parenscript forms (an implicit progn), expands to code which
index f1ac28c..dc9864c 100644 (file)
@@ -71,13 +71,13 @@ lexical block.")
   (defun make-macro-env-dictionary ()
     "Creates a standard macro dictionary."
     (make-hash-table :test #'equal))
-  (defvar *script-macro-toplevel* (make-macro-env-dictionary)
+  (defvar *ps-macro-toplevel* (make-macro-env-dictionary)
     "Toplevel macro environment dictionary. Key is the symbol of the
 macro, value is (symbol-macro-p . expansion-function).")
-  (defvar *script-macro-env* (list *script-macro-toplevel*)
+  (defvar *ps-macro-env* (list *ps-macro-toplevel*)
     "Current macro environment.")
 
-  (defvar *script-setf-expanders* (make-macro-env-dictionary)
+  (defvar *ps-setf-expanders* (make-macro-env-dictionary)
     "Setf expander dictionary. Key is the symbol of the access
 function of the place, value is an expansion function that takes the
 arguments of the access functions as a first value and the form to be
@@ -91,7 +91,7 @@ SPEC is of the form (symbol-macro-p . expansion-function)."
       (spec)
     `(setf (gethash (lisp-symbol-to-ps-identifier ,name :macro) ,env-dict) ,spec)))
 
-(defun lookup-macro-spec (name &optional (environment *script-macro-env*))
+(defun lookup-macro-spec (name &optional (environment *ps-macro-env*))
   "Looks up the macro spec associated with NAME in the given environment.  A
 macro spec is of the form (symbol-macro-p . function). Returns two values:
 the SPEC and the parent macro environment.
@@ -104,19 +104,19 @@ NAME must be a symbol."
         (when val
           (return-from lookup-macro-spec
             (values val (or (cdr env)
-                            (list *script-macro-toplevel*)))))))))
+                            (list *ps-macro-toplevel*)))))))))
 
-(defun script-symbol-macro-p (name &optional (environment *script-macro-env*))
+(defun ps-symbol-macro-p (name &optional (environment *ps-macro-env*))
   "True if there is a Parenscript symbol macro named by the symbol NAME."
   (and (symbolp name) (car (lookup-macro-spec name environment))))
 
-(defun script-macro-p (name &optional (environment *script-macro-env*))
+(defun ps-macro-p (name &optional (environment *ps-macro-env*))
   "True if there is a Parenscript macro named by the symbol NAME."
   (and (symbolp name)
        (let ((macro-spec (lookup-macro-spec name environment)))
          (and macro-spec (not (car macro-spec))))))
 
-(defun lookup-macro-expansion-function (name &optional (environment *script-macro-env*))
+(defun lookup-macro-expansion-function (name &optional (environment *ps-macro-env*))
   "Lookup NAME in the given macro expansion environment (which
 defaults to the current macro environment). Returns the expansion
 function and the parent macro environment of the macro."
@@ -135,21 +135,21 @@ function and the parent macro environment of the macro."
                          (cdr ,form-arg)
                        ,@body)))))
       
-  (defun define-script-macro% (name args body &key symbol-macro-p)
+  (defun define-ps-macro% (name args body &key symbol-macro-p)
     (undefine-ps-special-form name)
-    (setf (get-macro-spec name *script-macro-toplevel*)
+    (setf (get-macro-spec name *ps-macro-toplevel*)
           (cons symbol-macro-p (make-ps-macro-function args body)))
     nil))
 
 (defmacro defpsmacro (name args &body body)
   "Define a ParenScript macro, and store it in the toplevel ParenScript
 macro environment."
-  `(define-script-macro% ',name ',args ',body :symbol-macro-p nil))
+  `(define-ps-macro% ',name ',args ',body :symbol-macro-p nil))
 
-(defmacro define-script-symbol-macro (name &body body)
+(defmacro define-ps-symbol-macro (name &body body)
   "Define a ParenScript symbol macro, and store it in the toplevel ParenScript
 macro environment.  BODY is a Lisp form that should return a ParenScript form."
-  `(define-script-macro% ',name () ',body :symbol-macro-p t))
+  `(define-ps-macro% ',name () ',body :symbol-macro-p t))
 
 (defun import-macros-from-lisp (&rest names)
   "Import the named Lisp macros into the ParenScript macro
@@ -157,7 +157,7 @@ environment. When the imported macro is macroexpanded by ParenScript,
 it is first fully macroexpanded in the Lisp macro environment, and
 then that expansion is further expanded by ParenScript."
   (dolist (name names)
-    (define-script-macro% name '(&rest args) 
+    (define-ps-macro% name '(&rest args) 
       (list `(common-lisp:macroexpand `(,',name ,@args)))
       :symbol-macro-p nil)))
 
@@ -184,9 +184,9 @@ whether any expansion was performed on the form or not."
             (args (cdr form)))
         (cond ((equal op 'quote) (values (if (equalp '(nil) args) nil form) ; leave quotes alone, unless it's a quoted nil
                                          nil))
-              ((script-macro-p op) (values (ps-macroexpand (funcall (lookup-macro-expansion-function op) form)) t))
+              ((ps-macro-p op) (values (ps-macroexpand (funcall (lookup-macro-expansion-function op) form)) t))
               (t (values form nil))))
-      (cond ((script-symbol-macro-p form) (values (ps-macroexpand (funcall (lookup-macro-expansion-function form) (list form))) t))
+      (cond ((ps-symbol-macro-p form) (values (ps-macroexpand (funcall (lookup-macro-expansion-function form) (list form))) t))
             (t (values form nil)))))
 
 ;;;; compiler interface
@@ -212,7 +212,7 @@ resultant symbol has an associated script-package. Raises an error if
 the form cannot be compiled to a symbol."
   (let ((exp (compile-parenscript-form form)))
     (when (or (eql (first exp) 'js-variable)
-              (eql (first exp) 'script-quote))
+              (eql (first exp) 'ps-quote))
       (setf exp (second exp)))
     (assert (symbolp exp) ()
             "~a is expected to be a symbol, but compiles to ~a (the ParenScript output for ~a alone is \"~a\"). This could be due to ~a being a special form." form exp form (ps* form) form)
@@ -249,7 +249,7 @@ into a single options argument via CREATE."
   (flet ((keyword-arg (arg)
            "If the given compiled expression is supposed to be a keyword argument, returns
 the keyword for it."
-           (when (and (listp arg) (eql (first arg) 'script-quote)) (second arg))))
+           (when (and (listp arg) (eql (first arg) 'ps-quote)) (second arg))))
     (let ((compiled-args (mapcar (lambda (arg) (compile-parenscript-form arg :expecting :expression))
                                  arg-forms)))
       (do ((effective-expressions nil)
@@ -271,11 +271,11 @@ the keyword for it."
          (args (cdr form)))
     (cond ((eql name 'quote)
            (assert (= 1 (length args)) () "Wrong number of arguments to quote: ~s" args)
-           (list 'script-quote (first args)))
+           (list 'ps-quote (first args)))
           ((ps-special-form-p form) (apply (get-ps-special-form name) (cons expecting args)))
           ((op-form-p form)
            (list 'operator
-                 (script-convert-op-name (compile-parenscript-form (first form) :expecting :symbol))
+                 (ps-convert-op-name (compile-parenscript-form (first form) :expecting :symbol))
                  (mapcar (lambda (form) (compile-parenscript-form form :expecting :expression)) (rest form))))
           ((method-call-p form)
            (list 'js-method-call
index 7c2b4a3..dacaa84 100644 (file)
@@ -128,7 +128,7 @@ vice-versa.")
                  op)
              *op-precedence-hash*)))
 
-(defprinter script-quote (val)
+(defprinter ps-quote (val)
   (if (null val)
       (psw "null")
       (error "Cannot translate quoted value ~S to javascript" val)))
@@ -160,7 +160,7 @@ vice-versa.")
   (psw (js-translate-symbol var)))
 
 ;;; arithmetic operators
-(defun script-convert-op-name (op)
+(defun ps-convert-op-name (op)
   (case op
     (and '\&\&)
     (or '\|\|)
@@ -240,7 +240,7 @@ vice-versa.")
 (defprinter js-object (slot-defs)
   (psw "{ ")
   (loop for ((slot-name slot-value) . remaining) on slot-defs do
-        (if (and (listp slot-name) (eql 'script-quote (car slot-name)) (symbolp (second slot-name)))
+        (if (and (listp slot-name) (eql 'ps-quote (car slot-name)) (symbolp (second slot-name)))
             (psw (js-translate-symbol (second slot-name)))
             (ps-print slot-name))
         (psw " : ")
@@ -252,7 +252,7 @@ vice-versa.")
   (if (and (listp obj) (member (car obj) '(js-expression-if)))
       (parenthesize-print obj)
       (ps-print obj))
-  (if (and (listp slot) (eql 'script-quote (car slot)))
+  (if (and (listp slot) (eql 'ps-quote (car slot)))
       (progn (psw #\.)
              (if (symbolp (second slot))
                  (psw (js-translate-symbol (second slot)))
index 0033a78..731f985 100644 (file)
@@ -380,7 +380,7 @@ lambda-list::=
       ,@effective-body)))
 
 (defpsmacro defsetf-long (access-fn lambda-list (store-var) form)
-  (setf (get-macro-spec access-fn *script-setf-expanders*)
+  (setf (get-macro-spec access-fn *ps-setf-expanders*)
         (compile nil
                  (let ((var-bindings (ordered-set-difference lambda-list lambda-list-keywords)))
                    `(lambda (access-fn-args store-form)
@@ -398,7 +398,7 @@ lambda-list::=
 
 (defpsmacro defsetf-short (access-fn update-fn &optional docstring)
   (declare (ignore docstring))
-  (setf (get-macro-spec access-fn *script-setf-expanders*)
+  (setf (get-macro-spec access-fn *ps-setf-expanders*)
         (lambda (access-fn-args store-form)
           `(,update-fn ,@access-fn-args ,store-form)))
   nil)
@@ -410,7 +410,7 @@ lambda-list::=
 ;;; macros
 (defmacro with-temp-macro-environment ((var) &body body)
   `(let* ((,var (make-macro-env-dictionary))
-          (*script-macro-env* (cons ,var *script-macro-env*)))
+          (*ps-macro-env* (cons ,var *ps-macro-env*)))
     ,@body))
 
 (define-ps-special-form macrolet (expecting macros &body body)
@@ -435,12 +435,12 @@ lambda-list::=
 
 (define-ps-special-form defmacro (expecting name args &body body)
   (declare (ignore expecting))
-  (define-script-macro% name args body :symbol-macro-p nil)
+  (define-ps-macro% name args body :symbol-macro-p nil)
   nil)
 
 (define-ps-special-form define-symbol-macro (expecting name expansion)
   (declare (ignore expecting))
-  (define-script-macro% name () (list `',expansion) :symbol-macro-p t)
+  (define-ps-macro% name () (list `',expansion) :symbol-macro-p t)
   nil)
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -453,7 +453,7 @@ lambda-list::=
                                        (numberp name-expr)
                                        (and (listp name-expr)
                                             (or (eql 'js-variable (car name-expr))
-                                                (eql 'script-quote (car name-expr)))))
+                                                (eql 'ps-quote (car name-expr)))))
                                    ()
                                    "Slot ~s is not one of js-variable, keyword, string or number." name-expr)
                            (list name-expr (compile-parenscript-form val :expecting :expression))))))
@@ -519,11 +519,11 @@ lambda-list::=
 
 (defpsmacro setf (&rest args)
   (flet ((process-setf-clause (place value-form)
-           (if (and (listp place) (get-macro-spec (car place) *script-setf-expanders*))
-               (funcall (get-macro-spec (car place) *script-setf-expanders*) (cdr place) value-form)
+           (if (and (listp place) (get-macro-spec (car place) *ps-setf-expanders*))
+               (funcall (get-macro-spec (car place) *ps-setf-expanders*) (cdr place) value-form)
                (let ((exp-place (ps-macroexpand place)))
-                 (if (and (listp exp-place) (get-macro-spec (car exp-place) *script-setf-expanders*))
-                     (funcall (get-macro-spec (car exp-place) *script-setf-expanders*) (cdr exp-place) value-form)
+                 (if (and (listp exp-place) (get-macro-spec (car exp-place) *ps-setf-expanders*))
+                     (funcall (get-macro-spec (car exp-place) *ps-setf-expanders*) (cdr exp-place) value-form)
                      `(setf1% ,exp-place ,value-form))))))
     (assert (evenp (length args)) ()
             "~s does not have an even number of arguments." (cons 'setf args))