X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~mdw/git/lisp/blobdiff_plain/d7d819976cb5d84766bffd2c5272c86203687ee9..ea87c989d51bfd4b64d2a802f87216dfce551a76:/infix.lisp diff --git a/infix.lisp b/infix.lisp index 64a0a30..ff5a3c9 100644 --- a/infix.lisp +++ b/infix.lisp @@ -94,8 +94,12 @@ (defvar *paren-depth* 0 ;;;-------------------------------------------------------------------------- ;;; The tokenizer. -(defconstant eof (cons :eof nil) - "A magical object which `get-token' returns at end-of-file.") +(eval-when (:compile-toplevel :load-toplevel :execute) + (let ((value (cons :eof nil))) + (unless (and (boundp 'eof) + (equal (symbol-value 'eof) value)) + (defconstant eof (cons :eof nil) + "A magical object which `get-token' returns at end-of-file.")))) (defun default-get-token () "Read a token from *stream* and store it in *token*." @@ -279,7 +283,7 @@ (defmacro defopfunc (op kind &body body) the value stack." `(progn (setf (get ',op ',kind) - (lambda () ,@body)) + (lambda () ,@body)) ',op)) (defmacro definfix (op prec &body body) @@ -423,7 +427,7 @@ (defun parse-ident-list () (let ((stuff nil)) (loop (unless (symbolp *token*) - (error "expected symbol; found ~S" *token*)) + (error "expected symbol; found ~S" *token*)) (push *token* stuff) (get-token) (unless (delim '|,| nil) @@ -817,8 +821,8 @@ (testrig "infix" #'test-infix (defun foo (x) (- x 6))) ("bind x = 3 in x - 2" . (let ((x 3)) (- x 2))) ("bind x, y = values(1, 2), - z = 3, - docs, decls, body = parse-body(body) in complicated" . + z = 3, + docs, decls, body = parse-body(body) in complicated" . (multiple-value-bind (x y) (values 1 2) (let ((z 3)) (multiple-value-bind (docs decls body) (parse-body body)