Commit 738d9a34 authored by hayeah via gmail com's avatar hayeah via gmail com

modified lispscript.lisp to take advantage of :invert reader

darcs-hash:7e15e3787d17021f33f66f95fe9551258b89be6b
parent ed79ebe8
......@@ -138,13 +138,17 @@ Return: ((<js-form>*) (~ <js-form>*) (@ <js-form>*)) "
;; (use-package :wisp.util)
(process-js '(foo bar BazBaf ~ ab cd @ la boo))
(process-js 'foo)
(defmacro process-js (js-form)
`(process *javascript* (get-pretty-printer) ,js-form (top-level-environment *javascript*)))
;; (process-js '(foo bar BazBaf ~ ab cd @ la boo))
;; (process-js 'foo)
(wisp.util::fmt (:a 4 5))
(defmacro process-js (js-form)
`(fmt (process *javascript* (get-pretty-printer) ,js-form (top-level-environment *javascript*))))
(defmethod process-sexp ((language javascript) processor form environment)
(if (consp form)
......@@ -536,10 +540,6 @@ statements such as blocks to *not* emit a semicolon."
(define-javascript-special-operator throw :statement (processor expr)
"throw " (expression expr) ";")
(process-js '(try 1 2 3 4
(catch blah joo ha su)
(finally suma boo)))
;; Try
(define-javascript-special-operator try :statement (processor &rest body)
(flet ((key (e) (if (consp e) (first e))))
......@@ -570,34 +570,34 @@ statements such as blocks to *not* emit a semicolon."
(loop for stmt in (rest finally-clause) do (out (statement stmt) :freshline))
:unindent :freshline "}"))))))
(defspecial-js try :statement (&rest body)
(flet ((key (e) (if (consp e) (first e))))
(let ((catch-clause (find 'catch body :key #'key))
(finally-clause (find 'finally body :key #'key)))
(when catch-clause
(assert
(let ((next (cdr (member catch-clause body))))
(or (null next) (eql (car next) finally-clause)))))
(when finally-clause
(assert (null (cdr (member finally-clause body)))))
;; (defspecial-js try :statement (&rest body)
;; (flet ((key (e) (if (consp e) (first e))))
;; (let ((catch-clause (find 'catch body :key #'key))
;; (finally-clause (find 'finally body :key #'key)))
;; (when catch-clause
;; (assert
;; (let ((next (cdr (member catch-clause body))))
;; (or (null next) (eql (car next) finally-clause)))))
;; (when finally-clause
;; (assert (null (cdr (member finally-clause body)))))
(setf body (ldiff body (or (member catch-clause body)
(member finally-clause body))))
(out
"try {" :%
(:idn (:lst body :infix :% (out (statement stmt))))
:% "}"
(when catch-clause
(destructuring-bind (var &rest body) (rest catch-clause)
(out
" catch (" (name var) ") {" :%
(:idn (:lst body :infix :& (out (statement stmt))))
:& "}")))
(when finally-clause
(out
" finally {" :%
(:idn (lst (rest finally-clause) :infix :& (out (statement stmt))))
:& "}"))))))
;; (setf body (ldiff body (or (member catch-clause body)
;; (member finally-clause body))))
;; (out
;; "try {" :%
;; (:idn (:lst body :infix :% (out (statement stmt))))
;; :% "}"
;; (when catch-clause
;; (destructuring-bind (var &rest body) (rest catch-clause)
;; (out
;; " catch (" (name var) ") {" :%
;; (:idn (:lst body :infix :& (out (statement stmt))))
;; :& "}")))
;; (when finally-clause
;; (out
;; " finally {" :%
;; (:idn (lst (rest finally-clause) :infix :& (out (statement stmt))))
;; :& "}"))))))
;; Function -- two kinds, named and anonymous. The former is a
;; statement; the latter an expression.
......@@ -624,12 +624,3 @@ statements such as blocks to *not* emit a semicolon."
(let ((env (append pairs env)))
(loop for form in body do
(process *javascript* processor form env))))
(process-js '(function (b c) d f g))
This diff is collapsed.
......@@ -146,12 +146,12 @@
;; (defparameter *fmt-context* (cons nil nil))
;; (defparameter *fmt-ops* nil))
;;;; fmt global
;;;; fmt globals
(defparameter *fmt-stream* *standard-output*)
(defparameter *fmt-context* (cons nil nil))
(defparameter *fmt-ops* nil)
(defparameter *fmt-indent-em* 0)
;;;; fmt interface
(defmacro defmt-op (name args &body body)
"Defines a new format operation macro that may be used within the fmt macro. The names has to be a keyword."
......@@ -294,6 +294,7 @@
(defmt-op :tab ()
;; at least print a space to prevent nasty suprises
;; Do the right thing unless you know what you are doing.
`(progn (pprint-tab :line-relative 5 1 *fmt-stream*)
(unless *print-pretty* (princ " " *fmt-stream*))))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment