~akarle/fisl

cc09a2c6751112a0146037e21114ecfb2e2e5ee6 — Alex Karle 1 year, 3 months ago 29210ae main
refactor: Use aslist-ref instead of assoc/cadr

The joys of learning the base library over time :)
1 files changed, 16 insertions(+), 17 deletions(-)

M scanner.scm
M scanner.scm => scanner.scm +16 -17
@@ 19,23 19,22 @@
        (and (char<=? #\A c) (char>=? #\Z c)))))

(define (get-keyword k)
  (let ((kpair (assoc k '(("and"    AND)
                          ("class"  CLASS)
                          ("else"   ELSE)
                          ("false"  FALSE)
                          ("for"    FOR)
                          ("fun"    FUN)
                          ("if"     IF)
                          ("nil"    NIL)
                          ("or"     OR)
                          ("print"  PRINT)
                          ("return" RETURN)
                          ("super"  SUPER)
                          ("this"   THIS)
                          ("true"   TRUE)
                          ("var"    VAR)
                          ("while"  WHILE)))))
    (if kpair (cadr kpair) #f)))
  (alist-ref k '(("and"   . AND)
		 ("class" . CLASS)
		 ("else"  . ELSE)
		 ("false" . FALSE)
		 ("for"   . FOR)
		 ("fun"   . FUN)
		 ("if"    . IF)
		 ("nil"   . NIL)
		 ("or"    . OR)
		 ("print" . PRINT)
		 ("return". RETURN)
		 ("super" . SUPER)
		 ("this"  . THIS)
		 ("true"  . TRUE)
		 ("var"   . VAR)
		 ("while" . WHILE)) equal?))

(define (alnum? c)
  (and c (or (alpha? c) (digit? c))))