Just another update

This commit is contained in:
Ingy döt Net 2015-02-20 00:35:01 -05:00
parent a25938f123
commit 00a190b0a6
6591 changed files with 94363 additions and 23227 deletions

View file

@ -9,15 +9,15 @@
collect (read-char stream) into digits
finally (return (parse-integer (coerce digits 'string))))))
(consume-whitespace)
(let ((c (peek-char nil stream nil nil)))
(let ((token (case c
((nil) nil)
((#\() :lparen)
((#\)) :rparen)
((#\*) '*)
((#\/) '/)
((#\+) '+)
((#\-) '-)
(let* ((c (peek-char nil stream nil nil)))
(token (case c
(nil nil)
(#\( :lparen)
(#\) :rparen)
(#\* '*)
(#\/ '/)
(#\+ '+)
(#\- '-)
(otherwise
(unless (digit-char-p c)
(cerror "Skip it." "Unexpected character ~w." c)
@ -27,7 +27,7 @@
(read-integer)))))
(unless (or (null token) (integerp token))
(read-char stream))
token))))
token)))
(defun group-parentheses (tokens &optional (delimited nil))
(do ((new-tokens '()))
@ -37,12 +37,12 @@
(values (nreverse new-tokens) '()))
(let ((token (pop tokens)))
(case token
((:lparen)
(:lparen
(multiple-value-bind (group remaining-tokens)
(group-parentheses tokens t)
(setf new-tokens (cons group new-tokens)
tokens remaining-tokens)))
((:rparen)
(:rparen
(if (not delimited)
(cerror "Ignore it." "Unexpected right parenthesis.")
(return (values (nreverse new-tokens) tokens))))