Fix incorrect parenthesis

This commit is contained in:
2024-09-10 23:05:14 -07:00
parent edd4f53a68
commit 2bdf936160
4 changed files with 60 additions and 26 deletions

View File

@ -108,26 +108,9 @@ proposition."))
(open-paren most-positive-fixnum)
(t nil)))
(defun operator-argument-count (oper)
"Return the minimum number of arguments that OPER takes as the first value,
and the maximum number (or nil for infinity) as a second value."
(case oper
(and (values 2 nil))
(or (values 2 nil))
(xor (values 2 nil))
(not (values 1 1))
(implies (values 2 2))
(converse (values 2 2))
(iff (values 2 2))
(nand (values 2 nil))
(nor (values 2 2))
(open-paren (values 0 0))
(t (error "unknown operator: ~S" oper))))
(defun unary-p (oper)
"Return whether OPER is a unary operator or not."
(when oper
(= 1 (operator-argument-count oper))))
(eq oper 'not))
(defun interpret-operand (oper-str)
"Return a symbol representing OPER-STR, or the string itself if it represents
@ -267,7 +250,7 @@ found variables."
(error 'proposition-parse-error :message "no more operators"
:position pos
:proposition prop-str))
(let ((oper-args (operator-argument-count oper))
(let ((oper-args (if (unary-p oper) 1 2))
(cur-operands (list (pop operands))))
(when (not (car cur-operands))
(error 'proposition-parse-error