Skip to content

Commit 5949f1f

Browse files
committed
fix: webserver
1 parent 8fd9150 commit 5949f1f

File tree

4 files changed

+28
-24
lines changed

4 files changed

+28
-24
lines changed

fix-quicklisp.lisp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
11
(eval-when (:load-toplevel :execute)
22
(pushnew (truename (sb-unix:posix-getcwd/)) ql:*local-project-directories* )
3-
(ql:register-local-projects))
3+
(ql:register-local-projects)
4+
5+
;; install ultralisp if necessary
6+
(unless (member "ultralisp" (ql-dist:all-dists)
7+
:key 'ql-dist:name
8+
:test 'string=)
9+
(ql-dist:install-dist "http://dist.ultralisp.org/"
10+
:prompt nil)))

lisp-inference.asd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
:depends-on (:lisp-inference
3232
:weblocks
3333
:weblocks-ui
34+
:clack-handler-hunchentoot
3435
:find-port
3536
:str)
3637
:pathname "web"

src/pratt.lisp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22

33
(defparameter *binding-precedence*
44
'(
5-
("^" . 80)
5+
("^" . 80)
66
("v" . 70)
7-
("[+]" . 60)
7+
("[+]" . 60)
88
("=>" . 50)
9-
("<=>" . 40)))
9+
("->" . 50)
10+
("<=>" . 40)
11+
("<->" . 40)))
1012

1113
(defvar *tokens* nil)
1214
(defvar *pos* 0)
@@ -22,11 +24,11 @@
2224
((member c '(#\Space #\Tab #\Newline)) (read-char stream) (read-token stream))
2325
((alpha-char-p c)
2426
(let ((sym (read stream)))
25-
(list (string-downcase (string sym)))))
27+
(list (string-downcase (string sym)))))
2628
(t
2729
(let ((token (with-output-to-string (out)
2830
(loop for ch = (peek-char nil stream nil nil)
29-
while (and ch (find ch "<=>[+]"))
31+
while (and ch (find ch "<=>-[+]"))
3032
do (write-char (read-char stream) out)))))
3133
(if (string= token "") (list (string (read-char stream))) (list token)))))))))
3234

@@ -36,10 +38,10 @@
3638
while token
3739
append token)))
3840

39-
(defun next-token ()
41+
(defun next-token ()
4042
(nth *pos* *tokens*))
4143

42-
(defun advance ()
44+
(defun advance ()
4345
(prog1 (next-token) (incf *pos*)))
4446

4547
(defun match (tok)
@@ -73,4 +75,4 @@
7375
(defun parse-logic (input)
7476
(setf *tokens* (tokenize input)
7577
*pos* 0)
76-
(parse-expression))
78+
(parse-expression))

web/webapp.lisp

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@
2222
(defvar *proposition* "P => Q" "Default proposition")
2323
(defvar *port* (find-port:find-port))
2424
(defvar *notes*
25-
'("My lexer doesn't work very well with parenthesis."
26-
"Please, don't be evil. Use less than 10 variables."
25+
'("Please, don't be evil. Use less than 10 variables."
2726
"Yes, [+] it's a XOR. Mathematically: p ⊕ q."
2827
"(=> ->) and (<=> <->) are aliases."))
2928

@@ -43,24 +42,19 @@
4342
(defun truth-table (exp)
4443
(with-output-to-string (s)
4544
(let ((inference:*output-stream* s))
46-
(inference:print-truth-table exp))))
45+
(inference:print-truth-table (inference:parse-logic exp)))))
4746

48-
(defun create-table (exp)
47+
(defun create-table (exp-string)
4948
(make-instance 'table
50-
:prop (format nil "~a" exp)
51-
:truth (truth-table exp)))
49+
:prop exp-string
50+
:truth (truth-table exp-string)))
5251

5352
(defgeneric update-table (table exp))
5453

55-
(defmethod update-table (table (exp list))
56-
(setf (prop table) (format nil "~a" exp))
57-
(setf (truth table) (truth-table exp)
58-
(update table))
59-
6054
(defmethod update-table (table (exp string))
61-
(update-table
62-
table
63-
(inference:parse-logic exp)))
55+
(setf (prop table) exp)
56+
(setf (truth table) (truth-table exp))
57+
(update table))
6458

6559
(defmethod render ((table table))
6660
(with-html
@@ -93,7 +87,7 @@
9387

9488
(defmethod weblocks/session:init ((app truth-table))
9589
(declare (ignorable app))
96-
(create-table (parse-string *proposition*)))
90+
(create-table *proposition*))
9791

9892
(defun start (&optional (port *port*))
9993
(weblocks/debug:on)

0 commit comments

Comments
 (0)