A little more match.

This commit is contained in:
sforman 2023-10-11 20:36:01 -07:00
parent c4d80f6c4e
commit 205086714d
1 changed files with 11 additions and 12 deletions

View File

@ -101,10 +101,10 @@
(values (cons (joy-bool-term (car stack)) (cdr stack)) expression dict)) (values (cons (joy-bool-term (car stack)) (cdr stack)) expression dict))
(define (joy-bool-term term) (define (joy-bool-term term)
(cond ((boolean? term) term) (cond ((boolean? term) term)
((number? term) (not-equal 0 term)) ((number? term) (not-equal 0 term))
((list? term) (not (null? term))) ((list? term) (not (null? term)))
(else #t))) (else #t)))
; ██████╗ ██████╗ ███╗ ███╗██████╗ ██╗███╗ ██╗ █████╗ ████████╗ ██████╗ ██████╗ ███████╗ ; ██████╗ ██████╗ ███╗ ███╗██████╗ ██╗███╗ ██╗ █████╗ ████████╗ ██████╗ ██████╗ ███████╗
@ -166,14 +166,13 @@
(expect-right-bracket-lookahead (car tokens) (cdr tokens) acc))) (expect-right-bracket-lookahead (car tokens) (cdr tokens) acc)))
(define (expect-right-bracket-lookahead token tokens acc) (define (expect-right-bracket-lookahead token tokens acc)
(cond ((string=? token "]") (values acc tokens)) (match token
((string=? token "[") ("]" (values acc tokens))
(receive (sub_list rest) (expect-right-bracket tokens '()) ("[" (receive (sub_list rest) (expect-right-bracket tokens '())
(receive (el rrest) (expect-right-bracket rest acc) (receive (el rrest) (expect-right-bracket rest acc)
(values (cons sub_list el) rrest)))) (values (cons sub_list el) rrest))))
(else (_ (receive (el rest) (expect-right-bracket tokens acc)
(receive (el rest) (expect-right-bracket tokens acc) (values (cons (tokenator token) el) rest)))))
(values (cons (tokenator token) el) rest)))))
(define (one-token-lookahead token tokens) (define (one-token-lookahead token tokens)
(match token (match token