]> git.mdlowis.com Git - archive/dlang-scm.git/commitdiff
Refactored lexer rule for string by adding a string character recognition predicate
authorMike D. Lowis <mike@mdlowis.com>
Fri, 20 Jul 2012 17:44:28 +0000 (13:44 -0400)
committerMike D. Lowis <mike@mdlowis.com>
Fri, 20 Jul 2012 17:44:28 +0000 (13:44 -0400)
source/lexer.scm

index c1426c939bd86c2e01031605973b49e08459bc66..c4d1fe82c50ed2ccfd2fdd82f1ee27c01ddc0a85 100644 (file)
 
 (define (dlang/string in)
   (define text (string (char-match in #\")))
-  (while (and (not (eof-object? (buf-lookahead! in 1)))
-              (not (char=? #\newline (buf-lookahead! in 1)))
-              (not (char=? #\" (buf-lookahead! in 1))))
+  (while (dlang/string-char? in)
     (set! text (string-append text (string (buf-consume! in)))))
   (set! text (string-append text (string (char-match in #\"))))
   (token 'string text))
 
+(define (dlang/string-char? in)
+  (define ch (buf-lookahead! in 1))
+  (and (not (eof-object? ch))
+       (not (char=? #\newline ch))
+       (not (char=? #\" ch))))
+
 (define (dlang/symbol in)
   (token 'symbol
     (string-append