Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

A bunch of tutorial changes to make it work with SBCL and its package…

… locks.
  • Loading branch information...
commit 459fd28f40b9b529568c7393116a7df235651892 1 parent b4654a9
@sellout sellout authored
View
14 tutorial/chapter2.lisp
@@ -15,15 +15,15 @@
(defun read-token ()
"Returns either a character or one of 'tok-eof, 'tok-def, 'tok-extern,
'tok-identifier, or 'tok-number."
- (flet ((read-char () (read-char *standard-input* nil nil)))
+ (flet ((get-char () (read-char *standard-input* nil nil)))
(loop while (find last-char +whitespace+)
- do (setf last-char (read-char)))
+ do (setf last-char (get-char)))
(cond ((eql last-char nil) ; check for EOF, do not eat
'tok-eof)
((alpha-char-p last-char)
(setf *identifier-string*
(coerce (cons last-char
- (loop do (setf last-char (read-char))
+ (loop do (setf last-char (get-char))
while (alphanumericp last-char)
collecting last-char))
'string))
@@ -35,19 +35,19 @@
(let ((*read-eval* nil))
(read-from-string
(coerce (cons last-char
- (loop do (setf last-char (read-char))
+ (loop do (setf last-char (get-char))
while (or (digit-char-p last-char)
(char= last-char #\.))
collecting last-char))
'string))))
'tok-number)
((eql last-char #\#) ; comment until end of line
- (loop do (setf last-char (read-char))
+ (loop do (setf last-char (get-char))
until (find last-char '(nil #\linefeed #\return)))
(if (null last-char) 'tok-eof (read-token)))
(t
(let ((this-char last-char))
- (setf last-char (read-char))
+ (setf last-char (get-char))
this-char))))))
;;; abstract syntax tree
@@ -147,7 +147,7 @@
:message "unknown token when expecting an expression"))))
(defun parse-bin-op-rhs (expression-precedence lhs)
- (do () ()
+ (do () (nil)
(let ((token-precedence (get-precedence *current-token*)))
(if (< token-precedence expression-precedence)
(return-from parse-bin-op-rhs lhs)
View
14 tutorial/chapter3.lisp
@@ -15,15 +15,15 @@
(defun read-token ()
"Returns either a character or one of 'tok-eof, 'tok-def, 'tok-extern,
'tok-identifier, or 'tok-number."
- (flet ((read-char () (read-char *standard-input* nil nil)))
+ (flet ((get-char () (read-char *standard-input* nil nil)))
(loop while (find last-char +whitespace+)
- do (setf last-char (read-char)))
+ do (setf last-char (get-char)))
(cond ((eql last-char nil) ; check for EOF, do not eat
'tok-eof)
((alpha-char-p last-char)
(setf *identifier-string*
(coerce (cons last-char
- (loop do (setf last-char (read-char))
+ (loop do (setf last-char (get-char))
while (alphanumericp last-char)
collecting last-char))
'string))
@@ -35,19 +35,19 @@
(let ((*read-eval* nil))
(read-from-string
(coerce (cons last-char
- (loop do (setf last-char (read-char))
+ (loop do (setf last-char (get-char))
while (or (digit-char-p last-char)
(char= last-char #\.))
collecting last-char))
'string))))
'tok-number)
((eql last-char #\#) ; comment until end of line
- (loop do (setf last-char (read-char))
+ (loop do (setf last-char (get-char))
until (find last-char '(nil #\linefeed #\return)))
(if (null last-char) 'tok-eof (read-token)))
(t
(let ((this-char last-char))
- (setf last-char (read-char))
+ (setf last-char (get-char))
this-char))))))
;;; abstract syntax tree
@@ -143,7 +143,7 @@
:message "unknown token when expecting an expression"))))
(defun parse-bin-op-rhs (expression-precedence lhs)
- (do () ()
+ (do () (nil)
(let ((token-precedence (get-precedence *current-token*)))
(if (< token-precedence expression-precedence)
(return-from parse-bin-op-rhs lhs)
View
14 tutorial/chapter4.lisp
@@ -15,15 +15,15 @@
(defun read-token ()
"Returns either a character or one of 'tok-eof, 'tok-def, 'tok-extern,
'tok-identifier, or 'tok-number."
- (flet ((read-char () (read-char *standard-input* nil nil)))
+ (flet ((get-char () (read-char *standard-input* nil nil)))
(loop while (find last-char +whitespace+)
- do (setf last-char (read-char)))
+ do (setf last-char (get-char)))
(cond ((eql last-char nil) ; check for EOF, do not eat
'tok-eof)
((alpha-char-p last-char)
(setf *identifier-string*
(coerce (cons last-char
- (loop do (setf last-char (read-char))
+ (loop do (setf last-char (get-char))
while (alphanumericp last-char)
collecting last-char))
'string))
@@ -35,19 +35,19 @@
(let ((*read-eval* nil))
(read-from-string
(coerce (cons last-char
- (loop do (setf last-char (read-char))
+ (loop do (setf last-char (get-char))
while (or (digit-char-p last-char)
(char= last-char #\.))
collecting last-char))
'string))))
'tok-number)
((eql last-char #\#) ; comment until end of line
- (loop do (setf last-char (read-char))
+ (loop do (setf last-char (get-char))
until (find last-char '(nil #\linefeed #\return)))
(if (null last-char) 'tok-eof (read-token)))
(t
(let ((this-char last-char))
- (setf last-char (read-char))
+ (setf last-char (get-char))
this-char))))))
;;; abstract syntax tree
@@ -143,7 +143,7 @@
:message "unknown token when expecting an expression"))))
(defun parse-bin-op-rhs (expression-precedence lhs)
- (do () ()
+ (do () (nil)
(let ((token-precedence (get-precedence *current-token*)))
(if (< token-precedence expression-precedence)
(return-from parse-bin-op-rhs lhs)
View
15 tutorial/chapter5.lisp
@@ -1,5 +1,6 @@
(defpackage kaleidoscope.chapter5
(:use #:cl) ; would normally use #:llvm, but wanted to make usage clear
+ (:shadow #:condition)
(:export #:toplevel))
(in-package :kaleidoscope.chapter5)
@@ -15,15 +16,15 @@
(defun read-token ()
"Returns either a character or one of 'tok-eof, 'tok-def, 'tok-extern,
'tok-identifier, or 'tok-number."
- (flet ((read-char () (read-char *standard-input* nil nil)))
+ (flet ((get-char () (read-char *standard-input* nil nil)))
(loop while (find last-char +whitespace+)
- do (setf last-char (read-char)))
+ do (setf last-char (get-char)))
(cond ((eql last-char nil) ; check for EOF, do not eat
'tok-eof)
((alpha-char-p last-char)
(setf *identifier-string*
(coerce (cons last-char
- (loop do (setf last-char (read-char))
+ (loop do (setf last-char (get-char))
while (alphanumericp last-char)
collecting last-char))
'string))
@@ -40,19 +41,19 @@
(let ((*read-eval* nil))
(read-from-string
(coerce (cons last-char
- (loop do (setf last-char (read-char))
+ (loop do (setf last-char (get-char))
while (or (digit-char-p last-char)
(char= last-char #\.))
collecting last-char))
'string))))
'tok-number)
((eql last-char #\#) ; comment until end of line
- (loop do (setf last-char (read-char))
+ (loop do (setf last-char (get-char))
until (find last-char '(nil #\linefeed #\return)))
(if (null last-char) 'tok-eof (read-token)))
(t
(let ((this-char last-char))
- (setf last-char (read-char))
+ (setf last-char (get-char))
this-char))))))
;;; abstract syntax tree
@@ -215,7 +216,7 @@
:message "unknown token when expecting an expression"))))
(defun parse-bin-op-rhs (expression-precedence lhs)
- (do () ()
+ (do () (nil)
(let ((token-precedence (get-precedence *current-token*)))
(if (< token-precedence expression-precedence)
(return-from parse-bin-op-rhs lhs)
View
15 tutorial/chapter6.lisp
@@ -1,5 +1,6 @@
(defpackage kaleidoscope.chapter6
(:use #:cl) ; would normally use #:llvm, but wanted to make usage clear
+ (:shadow #:condition)
(:export #:toplevel))
(in-package :kaleidoscope.chapter6)
@@ -15,15 +16,15 @@
(defun read-token ()
"Returns either a character or one of 'tok-eof, 'tok-def, 'tok-extern,
'tok-identifier, or 'tok-number."
- (flet ((read-char () (read-char *standard-input* nil nil)))
+ (flet ((get-char () (read-char *standard-input* nil nil)))
(loop while (find last-char +whitespace+)
- do (setf last-char (read-char)))
+ do (setf last-char (get-char)))
(cond ((eql last-char nil) ; check for EOF, do not eat
'tok-eof)
((alpha-char-p last-char)
(setf *identifier-string*
(coerce (cons last-char
- (loop do (setf last-char (read-char))
+ (loop do (setf last-char (get-char))
while (alphanumericp last-char)
collecting last-char))
'string))
@@ -42,19 +43,19 @@
(let ((*read-eval* nil))
(read-from-string
(coerce (cons last-char
- (loop do (setf last-char (read-char))
+ (loop do (setf last-char (get-char))
while (or (digit-char-p last-char)
(char= last-char #\.))
collecting last-char))
'string))))
'tok-number)
((eql last-char #\#) ; comment until end of line
- (loop do (setf last-char (read-char))
+ (loop do (setf last-char (get-char))
until (find last-char '(nil #\linefeed #\return)))
(if (null last-char) 'tok-eof (read-token)))
(t
(let ((this-char last-char))
- (setf last-char (read-char))
+ (setf last-char (get-char))
this-char))))))
;;; abstract syntax tree
@@ -245,7 +246,7 @@
(make-instance 'unary-expression :opcode opcode :operand operand))))))
(defun parse-bin-op-rhs (expression-precedence lhs)
- (do () ()
+ (do () (nil)
(let ((token-precedence (get-precedence *current-token*)))
(if (< token-precedence expression-precedence)
(return-from parse-bin-op-rhs lhs)
View
15 tutorial/chapter7.lisp
@@ -1,5 +1,6 @@
(defpackage kaleidoscope.chapter7
(:use #:cl) ; would normally use #:llvm, but wanted to make usage clear
+ (:shadow #:condition)
(:export #:toplevel))
(in-package :kaleidoscope.chapter7)
@@ -15,15 +16,15 @@
(defun read-token ()
"Returns either a character or one of 'tok-eof, 'tok-def, 'tok-extern,
'tok-identifier, or 'tok-number."
- (flet ((read-char () (read-char *standard-input* nil nil)))
+ (flet ((get-char () (read-char *standard-input* nil nil)))
(loop while (find last-char +whitespace+)
- do (setf last-char (read-char)))
+ do (setf last-char (get-char)))
(cond ((eql last-char nil) ; check for EOF, do not eat
'tok-eof)
((alpha-char-p last-char)
(setf *identifier-string*
(coerce (cons last-char
- (loop do (setf last-char (read-char))
+ (loop do (setf last-char (get-char))
while (alphanumericp last-char)
collecting last-char))
'string))
@@ -43,19 +44,19 @@
(let ((*read-eval* nil))
(read-from-string
(coerce (cons last-char
- (loop do (setf last-char (read-char))
+ (loop do (setf last-char (get-char))
while (or (digit-char-p last-char)
(char= last-char #\.))
collecting last-char))
'string))))
'tok-number)
((eql last-char #\#) ; comment until end of line
- (loop do (setf last-char (read-char))
+ (loop do (setf last-char (get-char))
until (find last-char '(nil #\linefeed #\return)))
(if (null last-char) 'tok-eof (read-token)))
(t
(let ((this-char last-char))
- (setf last-char (read-char))
+ (setf last-char (get-char))
this-char))))))
;;; abstract syntax tree
@@ -279,7 +280,7 @@
(make-instance 'unary-expression :opcode opcode :operand operand))))))
(defun parse-bin-op-rhs (expression-precedence lhs)
- (do () ()
+ (do () (nil)
(let ((token-precedence (get-precedence *current-token*)))
(if (< token-precedence expression-precedence)
(return-from parse-bin-op-rhs lhs)
Please sign in to comment.
Something went wrong with that request. Please try again.