Fix parser

This commit is contained in:
2025-10-05 19:55:28 -07:00
parent 87b47f9c94
commit 65970adfe1

View File

@ -90,12 +90,12 @@ proposition."))
"Return t if STR is only alphabetical characters." "Return t if STR is only alphabetical characters."
(not (find-if-not 'alpha-char-p str))) (not (find-if-not 'alpha-char-p str)))
(defparameter *longest-non-alpha-operator* (defparameter *longest-alpha-operator*
(apply 'max (mapcar (apply 'max (mapcar
(lambda (entry) (lambda (entry)
(apply 'max (apply 'max 0
(mapcar 'length (mapcar 'length
(remove-if 'alpha-string-p (cdr entry))))) (remove-if-not 'alpha-string-p (cdr entry)))))
*operator-symbol-table*)) *operator-symbol-table*))
"The longest operator in `*operator-symbol-table*' such that `alpha-string-p' "The longest operator in `*operator-symbol-table*' such that `alpha-string-p'
returns t.") returns t.")
@ -224,7 +224,7 @@ a variable."
"Return the operator symbol for TOKEN, if it is an operator. As a second "Return the operator symbol for TOKEN, if it is an operator. As a second
value, return the matched portion of TOKEN. If no match is found, return value, return the matched portion of TOKEN. If no match is found, return
(values nil nil)." (values nil nil)."
(loop for len downfrom (min *longest-non-alpha-operator* (length token)) to 1 (loop for len downfrom (min *longest-alpha-operator* (length token)) to 1
for cur-test = (subseq token 0 len) for cur-test = (subseq token 0 len)
for oper-sym = (operator-symbol cur-test) for oper-sym = (operator-symbol cur-test)
when oper-sym do when oper-sym do
@ -446,7 +446,7 @@ found variables."
(push-operator value token-pos))))) (push-operator value token-pos)))))
;; remove implicit-and ;; remove implicit-and
(when (eq 'implicit-and (peek-operator)) (when (eq 'implicit-and (peek-operator))
(pop-operator)) (pop-operator))
(loop for (top-oper . top-pos) = (car operators) (loop for (top-oper . top-pos) = (car operators)
while top-oper while top-oper
when (eq top-oper 'open-paren) do when (eq top-oper 'open-paren) do