From ec48da01291d82c45cd0bb83585c6d8adfb21c91 Mon Sep 17 00:00:00 2001 From: "Mike D. Lowis" Date: Wed, 11 Jul 2012 13:50:52 -0400 Subject: [PATCH] Refactored id recognition function to use while loop --- source/lexer.scm | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/source/lexer.scm b/source/lexer.scm index 862151f..5e0eaf7 100644 --- a/source/lexer.scm +++ b/source/lexer.scm @@ -112,14 +112,14 @@ (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."))) -- 2.52.0