(let (ch)
(skip-whitespaces stream)
(setq ch (%peek-char stream))
- (while (and ch (eql ch #\;))
- (read-until stream (lambda (x) (eql x #\newline)))
+ (while (and ch (char= ch #\;))
+ (read-until stream (lambda (x) (char= x #\newline)))
(skip-whitespaces stream)
(setq ch (%peek-char stream)))))
(#\'
(list 'function (ls-read stream)))
(#\\
- (let ((cname (read-until stream #'terminalp)))
+ (let ((cname
+ (concat (string (%read-char stream))
+ (read-until stream #'terminalp))))
(cond
((string= cname "space") (char-code #\space))
((string= cname "newline") (char-code #\newline))
(defun literal->js (sexp)
(cond
- ((null sexp) "undefined")
+ ((null sexp) "false")
((integerp sexp) (integer-to-string sexp))
((stringp sexp) (concat "\"" sexp "\""))
((symbolp sexp) (concat "{name: \"" (symbol-name sexp) "\"}"))
(concat "(Math.floor(" (ls-compile x env fenv) "))"))
(define-compilation null (x)
- (concat "(" (ls-compile x env fenv) "== undefined)"))
+ (concat "(" (ls-compile x env fenv) "== false)"))
(define-compilation cons (x y)
(concat "{car: " (ls-compile x env fenv) ", cdr: " (ls-compile y env fenv) "}"))
((integerp sexp) (integer-to-string sexp))
((stringp sexp) (concat "\"" sexp "\""))
((listp sexp)
- (let ((sexp (ls-macroexpand-1 sexp env fenv)))
- (if (listp sexp)
- (let ((compiler-func (second (assoc (car sexp) *compilations*))))
- (if compiler-func
- (apply compiler-func env fenv (cdr sexp))
- (compile-funcall (car sexp) (cdr sexp) env fenv)))
- (ls-compile sexp env fenv))))))
-
-
-(defun ls-compile (sexp &optional env fenv)
- (cond
- ((symbolp sexp) (lookup-variable sexp env))
- ((integerp sexp) (integer-to-string sexp))
- ((stringp sexp) (concat "\"" sexp "\""))
- ((listp sexp)
(if (assoc (car sexp) *compilations*)
(let ((comp (second (assoc (car sexp) *compilations*))))
(apply comp env fenv (cdr sexp)))