projects
/
jscl.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Report unexpected errors in the reader
[jscl.git]
/
test.lisp
diff --git
a/test.lisp
b/test.lisp
index
2333621
..
adf8c12
100644
(file)
--- a/
test.lisp
+++ b/
test.lisp
@@
-69,14
+69,17
@@
(defun consp (x) (consp x))
(defun car (x) (car x))
(defun consp (x) (consp x))
(defun car (x) (car x))
+(defun cdr (x) (cdr x))
+
(defun caar (x) (car (car x)))
(defun cadr (x) (car (cdr x)))
(defun caar (x) (car (car x)))
(defun cadr (x) (car (cdr x)))
-(defun caddr (x) (car (cdr (cdr x))))
-(defun cadddr (x) (car (cdr (cdr (cdr x)))))
-(defun cdr (x) (cdr x))
(defun cdar (x) (cdr (car x)))
(defun cddr (x) (cdr (cdr x)))
(defun cdar (x) (cdr (car x)))
(defun cddr (x) (cdr (cdr x)))
-(defun cdddr (x) (cdr (cdr x)))
+
+(defun caddr (x) (car (cdr (cdr x))))
+(defun cdddr (x) (cdr (cdr (cdr x))))
+
+(defun cadddr (x) (car (cdr (cdr (cdr x)))))
(defun first (x) (car x))
(defun second (x) (cadr x))
(defun first (x) (car x))
(defun second (x) (cadr x))
@@
-94,12
+97,15
@@
x
(list x)))
x
(list x)))
-(defun append (list1 list2)
+(defun append-two (list1 list2)
(if (null list1)
list2
(cons (car list1)
(append (cdr list1) list2))))
(if (null list1)
list2
(cons (car list1)
(append (cdr list1) list2))))
+(defun append (&rest lists)
+ (!reduce #'append-two lists '()))
+
(defun reverse-aux (list acc)
(if (null list)
acc
(defun reverse-aux (list acc)
(if (null list)
acc
@@
-448,13
+454,15
@@
(skip-whitespaces-and-comments stream)
(let ((ch (%peek-char stream)))
(cond
(skip-whitespaces-and-comments stream)
(let ((ch (%peek-char stream)))
(cond
+ ((null ch)
+ (error "Unspected EOF"))
((char= ch #\))
(%read-char stream)
nil)
((char= ch #\.)
(%read-char stream)
((char= ch #\))
(%read-char stream)
nil)
((char= ch #\.)
(%read-char stream)
- (skip-whitespaces-and-comments stream)
(prog1 (ls-read stream)
(prog1 (ls-read stream)
+ (skip-whitespaces-and-comments stream)
(unless (char= (%read-char stream) #\))
(error "')' was expected."))))
(t
(unless (char= (%read-char stream) #\))
(error "')' was expected."))))
(t
@@
-464,8
+472,10
@@
(let ((string "")
(ch nil))
(setq ch (%read-char stream))
(let ((string "")
(ch nil))
(setq ch (%read-char stream))
- (while (not (char= ch #\"))
- (when (char= ch #\\)
+ (while (not (eql ch #\"))
+ (when (null ch)
+ (error "Unexpected EOF"))
+ (when (eql ch #\\)
(setq ch (%read-char stream)))
(setq string (concat string (string ch)))
(setq ch (%read-char stream)))
(setq ch (%read-char stream)))
(setq string (concat string (string ch)))
(setq ch (%read-char stream)))
@@
-547,6
+557,7
@@
(defun mark-binding-as-declared (b)
(setcar (cdddr b) t))
(defun mark-binding-as-declared (b)
(setcar (cdddr b) t))
+
(defvar *variable-counter* 0)
(defun gvarname (symbol)
(concat "v" (integer-to-string (incf *variable-counter*))))
(defvar *variable-counter* 0)
(defun gvarname (symbol)
(concat "v" (integer-to-string (incf *variable-counter*))))
@@
-736,7
+747,7
@@
(lookup-function-translation x fenv))))
#+common-lisp
(lookup-function-translation x fenv))))
#+common-lisp
-c(defmacro eval-when-compile (&body body)
+(defmacro eval-when-compile (&body body)
`(eval-when (:compile-toplevel :load-toplevel :execute)
,@body))
`(eval-when (:compile-toplevel :load-toplevel :execute)
,@body))
@@
-753,8
+764,8
@@
c(defmacro eval-when-compile (&body body)
(define-transformation let (bindings &rest body)
(let ((bindings (mapcar #'ensure-list bindings)))
(define-transformation let (bindings &rest body)
(let ((bindings (mapcar #'ensure-list bindings)))
- `((lambda ,(mapcar 'car bindings) ,@body)
- ,@(mapcar 'cadr bindings))))
+ `((lambda ,(mapcar #'car bindings) ,@body)
+ ,@(mapcar #'cadr bindings))))
;;; A little backquote implementation without optimizations of any
;;; kind for lispstrack.
;;; A little backquote implementation without optimizations of any
;;; kind for lispstrack.
@@
-828,7
+839,7
@@
c(defmacro eval-when-compile (&body body)
(compile-bool (concat "(" (ls-compile x env fenv) "===" (ls-compile nil env fenv) ")")))
(define-compilation cons (x y)
(compile-bool (concat "(" (ls-compile x env fenv) "===" (ls-compile nil env fenv) ")")))
(define-compilation cons (x y)
- (concat "{car: " (ls-compile x env fenv) ", cdr: " (ls-compile y env fenv) "}"))
+ (concat "({car: " (ls-compile x env fenv) ", cdr: " (ls-compile y env fenv) "})"))
(define-compilation consp (x)
(compile-bool
(define-compilation consp (x)
(compile-bool
@@
-932,7
+943,7
@@
c(defmacro eval-when-compile (&body body)
"})()" *newline*))))
(define-compilation js-eval (string)
"})()" *newline*))))
(define-compilation js-eval (string)
- (concat "eval(" (ls-compile string env fenv) ")"))
+ (concat "eval.apply(window, [" (ls-compile string env fenv) "])"))
(define-compilation error (string)
(define-compilation error (string)