]> git.mdlowis.com Git - archive/dlang-scm.git/commitdiff
Refactored id recognition function to use while loop
authorMike D. Lowis <mike@mdlowis.com>
Wed, 11 Jul 2012 17:50:52 +0000 (13:50 -0400)
committerMike D. Lowis <mike@mdlowis.com>
Wed, 11 Jul 2012 17:50:52 +0000 (13:50 -0400)
source/lexer.scm

index 862151f417201d769b84f50a163358ef4eed7962..5e0eaf7128c8fdd49a0cb456a32532577a7a0486 100644 (file)
       (token-text (dlang/id in)))))
 
 (define (dlang/id in)
-  (let loop ((acc "")
-             (ch  (buf-lookahead! in 1)))
-    (if
-      (and (not (char-whitespace? ch))
+  (define acc "")
+  (define ch (buf-lookahead! in 1))
+  (while (and (not (char-whitespace? ch))
            (not (eof-object? ch))
            (not (char=? ch #\#)))
-      (loop (string-append acc (string (buf-consume! in))) (buf-lookahead! in 1))
-      (if (> (string-length acc) 0)
-        (token 'id acc)
-        (error "An Id was expected but none found.")))))
+    (set! acc (string-append acc (string (buf-consume! in))))
+    (set! ch (buf-lookahead! in 1)))
+  (if (> (string-length acc) 0)
+    (token 'id acc)
+    (error "An Id was expected but none found.")))