From 6c361edd571c3d8c36d407716585655c9bff561d Mon Sep 17 00:00:00 2001 From: "Mike D. Lowis" Date: Fri, 20 Jul 2012 13:44:28 -0400 Subject: [PATCH] Refactored lexer rule for string by adding a string character recognition predicate --- source/lexer.scm | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/source/lexer.scm b/source/lexer.scm index c1426c9..c4d1fe8 100644 --- a/source/lexer.scm +++ b/source/lexer.scm @@ -114,13 +114,17 @@ (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 -- 2.52.0