From 30ead96abcba46df5a02f85f6da53250d4423c3d Mon Sep 17 00:00:00 2001 From: "Mike D. Lowis" Date: Wed, 25 Jul 2012 20:32:33 -0400 Subject: [PATCH] updated lexer to use char port instead of a standard character port --- source/lexer.scm | 5 +- tests/test_lexer.scm | 184 +++++++++++++++++++++---------------------- 2 files changed, 96 insertions(+), 93 deletions(-) diff --git a/source/lexer.scm b/source/lexer.scm index 83fdffc..d3861b4 100644 --- a/source/lexer.scm +++ b/source/lexer.scm @@ -1,7 +1,10 @@ (declare (unit lexer) (uses parse-utils)) (define (dlang/lexer input) - (buf (buf (charport input) charport-read) dlang/tokenize)) + (buf (dlang/char-buf input) dlang/tokenize)) + +(define (dlang/char-buf input) + (buf (charport input) charport-read)) (define (dlang/tokenize in) (let ((ch (buf-lookahead! in 1))) diff --git a/tests/test_lexer.scm b/tests/test_lexer.scm index ac4d7d8..bb60137 100644 --- a/tests/test_lexer.scm +++ b/tests/test_lexer.scm @@ -37,19 +37,19 @@ (def-test "dlang/tokenize should recognize whitespace" (call-with-input-string " \t\r\n" (lambda (input) - (define buffer (buf input read-char)) + (define buffer (dlang/char-buf input)) (eof-object? (dlang/tokenize buffer))))) (def-test "dlang/tokenize should recognize a comment" (call-with-input-string "# foo" (lambda (input) - (define buffer (buf input read-char)) + (define buffer (dlang/char-buf input)) (eof-object? (dlang/tokenize buffer))))) (def-test "dlang/tokenize should recognize a number" (call-with-input-string "12" (lambda (input) - (define buffer (buf input read-char)) + (define buffer (dlang/char-buf input)) (define result (dlang/tokenize buffer)) (and (token? result) (equal? 'number (token-type result)) @@ -58,7 +58,7 @@ (def-test "dlang/tokenize should recognize a character" (call-with-input-string "'a'" (lambda (input) - (define buffer (buf input read-char)) + (define buffer (dlang/char-buf input)) (define result (dlang/tokenize buffer)) (and (token? result) (equal? 'character (token-type result)) @@ -67,7 +67,7 @@ (def-test "dlang/tokenize should recognize a string" (call-with-input-string "\"\"" (lambda (input) - (define buffer (buf input read-char)) + (define buffer (dlang/char-buf input)) (define result (dlang/tokenize buffer)) (and (token? result) (equal? 'string (token-type result)) @@ -76,7 +76,7 @@ (def-test "dlang/tokenize should recognize a symbol" (call-with-input-string "$foobar" (lambda (input) - (define buffer (buf input read-char)) + (define buffer (dlang/char-buf input)) (define result (dlang/tokenize buffer)) (and (token? result) (equal? 'symbol (token-type result)) @@ -85,7 +85,7 @@ (def-test "dlang/tokenize should recognize an id" (call-with-input-string "foobar" (lambda (input) - (define buffer (buf input read-char)) + (define buffer (dlang/char-buf input)) (define result (dlang/tokenize buffer)) (and (token? result) (equal? 'id (token-type result)) @@ -94,13 +94,13 @@ (def-test "dlang/tokenize should recognize the EOF" (call-with-input-string "" (lambda (input) - (define buffer (buf input read-char)) + (define buffer (dlang/char-buf input)) (eof-object? (dlang/tokenize buffer))))) (def-test "dlang/tokenize should recognize a left parenthese" (call-with-input-string "(" (lambda (input) - (define buffer (buf input read-char)) + (define buffer (dlang/char-buf input)) (define result (dlang/tokenize buffer)) (and (token? result) (equal? 'lpar (token-type result)) @@ -109,7 +109,7 @@ (def-test "dlang/tokenize should recognize a right parenthese" (call-with-input-string ")" (lambda (input) - (define buffer (buf input read-char)) + (define buffer (dlang/char-buf input)) (define result (dlang/tokenize buffer)) (and (token? result) (equal? 'rpar (token-type result)) @@ -118,7 +118,7 @@ (def-test "dlang/tokenize should recognize a comma" (call-with-input-string "," (lambda (input) - (define buffer (buf input read-char)) + (define buffer (dlang/char-buf input)) (define result (dlang/tokenize buffer)) (and (token? result) (equal? 'comma (token-type result)) @@ -127,7 +127,7 @@ (def-test "dlang/tokenize should recognize a semicolon" (call-with-input-string ";" (lambda (input) - (define buffer (buf input read-char)) + (define buffer (dlang/char-buf input)) (define result (dlang/tokenize buffer)) (and (token? result) (equal? 'term (token-type result)) @@ -136,7 +136,7 @@ (def-test "dlang/tokenize should recognize the end keyword" (call-with-input-string "end" (lambda (input) - (define buffer (buf input read-char)) + (define buffer (dlang/char-buf input)) (define result (dlang/tokenize buffer)) (and (token? result) (equal? 'term (token-type result)) @@ -147,13 +147,13 @@ (def-test "dlang/whitespace should recognize and consume whitespace" (call-with-input-string " \t\r\n" (lambda (input) - (define buffer (buf input read-char)) + (define buffer (dlang/char-buf input)) (eof-object? (dlang/whitespace buffer))))) (def-test "dlang/whitespace continue parsing after whitespace" (call-with-input-string " \t\r\nfoo" (lambda (input) - (define buffer (buf input read-char)) + (define buffer (dlang/char-buf input)) (define result (dlang/whitespace buffer)) (and (token? result) (equal? 'id (token-type result)) @@ -164,31 +164,31 @@ (def-test "dlang/comment should recognize comments with windows style line endings" (call-with-input-string "# foo\r\n" (lambda (input) - (define buffer (buf input read-char)) + (define buffer (dlang/char-buf input)) (eof-object? (dlang/comment buffer))))) (def-test "dlang/comment should recognize comments with unix style line endings" (call-with-input-string "# foo\n" (lambda (input) - (define buffer (buf input read-char)) + (define buffer (dlang/char-buf input)) (eof-object? (dlang/comment buffer))))) (def-test "dlang/comment should recognize an empty comment" (call-with-input-string "#\n" (lambda (input) - (define buffer (buf input read-char)) + (define buffer (dlang/char-buf input)) (eof-object? (dlang/comment buffer))))) (def-test "dlang/comment should recognize comment at EOF" (call-with-input-string "#" (lambda (input) - (define buffer (buf input read-char)) + (define buffer (dlang/char-buf input)) (eof-object? (dlang/comment buffer))))) (def-test "dlang/comment should continue parsing after a comment" (call-with-input-string "# foo\r\nbar" (lambda (input) - (define buffer (buf input read-char)) + (define buffer (dlang/char-buf input)) (define result (dlang/comment buffer)) (and (token? result) (equal? 'id (token-type result)) @@ -199,7 +199,7 @@ (def-test "dlang/number should recognize a positive integer" (call-with-input-string "1" (lambda (input) - (define buffer (buf input read-char)) + (define buffer (dlang/char-buf input)) (define result (dlang/number buffer)) (and (token? result) (equal? 'number (token-type result)) @@ -208,7 +208,7 @@ (def-test "dlang/number should recognize a negative integer" (call-with-input-string "-1" (lambda (input) - (define buffer (buf input read-char)) + (define buffer (dlang/char-buf input)) (define result (dlang/number buffer)) (and (token? result) (equal? 'number (token-type result)) @@ -217,7 +217,7 @@ (def-test "dlang/number should recognize a positive float" (call-with-input-string "1.1" (lambda (input) - (define buffer (buf input read-char)) + (define buffer (dlang/char-buf input)) (define result (dlang/number buffer)) (and (token? result) (equal? 'number (token-type result)) @@ -226,7 +226,7 @@ (def-test "dlang/number should recognize a negative float" (call-with-input-string "-1.1" (lambda (input) - (define buffer (buf input read-char)) + (define buffer (dlang/char-buf input)) (define result (dlang/number buffer)) (and (token? result) (equal? 'number (token-type result)) @@ -235,7 +235,7 @@ (def-test "dlang/number should recognize a positive integer with positive exponent" (call-with-input-string "1e1" (lambda (input) - (define buffer (buf input read-char)) + (define buffer (dlang/char-buf input)) (define result (dlang/number buffer)) (and (token? result) (equal? 'number (token-type result)) @@ -244,7 +244,7 @@ (def-test "dlang/number should recognize a positive integer with negative exponent" (call-with-input-string "1e-1" (lambda (input) - (define buffer (buf input read-char)) + (define buffer (dlang/char-buf input)) (define result (dlang/number buffer)) (and (token? result) (equal? 'number (token-type result)) @@ -253,7 +253,7 @@ (def-test "dlang/number should recognize a positive float with positive exponent" (call-with-input-string "1.1e1" (lambda (input) - (define buffer (buf input read-char)) + (define buffer (dlang/char-buf input)) (define result (dlang/number buffer)) (and (token? result) (equal? 'number (token-type result)) @@ -262,7 +262,7 @@ (def-test "dlang/number should recognize a positive float with negative exponent" (call-with-input-string "1.1e-1" (lambda (input) - (define buffer (buf input read-char)) + (define buffer (dlang/char-buf input)) (define result (dlang/number buffer)) (and (token? result) (equal? 'number (token-type result)) @@ -271,7 +271,7 @@ (def-test "dlang/number should recognize a negative integer with positive exponent" (call-with-input-string "-1e1" (lambda (input) - (define buffer (buf input read-char)) + (define buffer (dlang/char-buf input)) (define result (dlang/number buffer)) (and (token? result) (equal? 'number (token-type result)) @@ -280,7 +280,7 @@ (def-test "dlang/number should recognize a negative integer with negative exponent" (call-with-input-string "-1e-1" (lambda (input) - (define buffer (buf input read-char)) + (define buffer (dlang/char-buf input)) (define result (dlang/number buffer)) (and (token? result) (equal? 'number (token-type result)) @@ -289,7 +289,7 @@ (def-test "dlang/number should recognize a negative float with positive exponent" (call-with-input-string "-1.1e1" (lambda (input) - (define buffer (buf input read-char)) + (define buffer (dlang/char-buf input)) (define result (dlang/number buffer)) (and (token? result) (equal? 'number (token-type result)) @@ -298,7 +298,7 @@ (def-test "dlang/number should recognize a negative float with negative exponent" (call-with-input-string "-1.1e-1" (lambda (input) - (define buffer (buf input read-char)) + (define buffer (dlang/char-buf input)) (define result (dlang/number buffer)) (and (token? result) (equal? 'number (token-type result)) @@ -309,7 +309,7 @@ (def-test "dlang/integer should recognize an integer of length one" (call-with-input-string "0" (lambda (input) - (define buffer (buf input read-char)) + (define buffer (dlang/char-buf input)) (define result (dlang/integer buffer)) (and (string? result) (equal? "0" result))))) @@ -317,7 +317,7 @@ (def-test "dlang/integer should recognize an integer of length two" (call-with-input-string "01" (lambda (input) - (define buffer (buf input read-char)) + (define buffer (dlang/char-buf input)) (define result (dlang/integer buffer)) (and (string? result) (equal? "01" result))))) @@ -325,7 +325,7 @@ (def-test "dlang/integer should recognize an integer of length three" (call-with-input-string "012" (lambda (input) - (define buffer (buf input read-char)) + (define buffer (dlang/char-buf input)) (define result (dlang/integer buffer)) (and (string? result) (equal? "012" result))))) @@ -333,14 +333,14 @@ (def-test "dlang/integer should error when no integer in input" (call-with-input-string "abc" (lambda (input) - (define buffer (buf input read-char)) + (define buffer (dlang/char-buf input)) (check-exception "Expected an integer" (dlang/integer buffer))))) (def-test "dlang/integer should error when EOF" (call-with-input-string "" (lambda (input) - (define buffer (buf input read-char)) + (define buffer (dlang/char-buf input)) (check-exception "Expected an integer" (dlang/integer buffer))))) @@ -349,7 +349,7 @@ (def-test "dlang/decimal should recognize an decimal of length one" (call-with-input-string ".0" (lambda (input) - (define buffer (buf input read-char)) + (define buffer (dlang/char-buf input)) (define result (dlang/decimal buffer)) (and (string? result) (equal? ".0" result))))) @@ -357,7 +357,7 @@ (def-test "dlang/decimal should recognize an decimal of length two" (call-with-input-string ".01" (lambda (input) - (define buffer (buf input read-char)) + (define buffer (dlang/char-buf input)) (define result (dlang/decimal buffer)) (and (string? result) (equal? ".01" result))))) @@ -365,7 +365,7 @@ (def-test "dlang/decimal should recognize an decimal of length three" (call-with-input-string ".012" (lambda (input) - (define buffer (buf input read-char)) + (define buffer (dlang/char-buf input)) (define result (dlang/decimal buffer)) (and (string? result) (equal? ".012" result))))) @@ -373,14 +373,14 @@ (def-test "dlang/decimal should error when no integer portion in input" (call-with-input-string ". " (lambda (input) - (define buffer (buf input read-char)) + (define buffer (dlang/char-buf input)) (check-exception "Expected an integer" (dlang/decimal buffer))))) (def-test "dlang/decimal should error when EOF" (call-with-input-string "" (lambda (input) - (define buffer (buf input read-char)) + (define buffer (dlang/char-buf input)) (check-exception "Expected '.', received EOF instead" (dlang/decimal buffer))))) @@ -389,7 +389,7 @@ (def-test "dlang/exponent should recognize an exponent of length one" (call-with-input-string "e0" (lambda (input) - (define buffer (buf input read-char)) + (define buffer (dlang/char-buf input)) (define result (dlang/exponent buffer)) (and (string? result) (equal? "e0" result))))) @@ -397,7 +397,7 @@ (def-test "dlang/exponent should recognize an exponent of length two" (call-with-input-string "e01" (lambda (input) - (define buffer (buf input read-char)) + (define buffer (dlang/char-buf input)) (define result (dlang/exponent buffer)) (and (string? result) (equal? "e01" result))))) @@ -405,7 +405,7 @@ (def-test "dlang/exponent should recognize an exponent of length three" (call-with-input-string "e012" (lambda (input) - (define buffer (buf input read-char)) + (define buffer (dlang/char-buf input)) (define result (dlang/exponent buffer)) (and (string? result) (equal? "e012" result))))) @@ -413,7 +413,7 @@ (def-test "dlang/exponent should recognize an exponent with uppercase E" (call-with-input-string "E012" (lambda (input) - (define buffer (buf input read-char)) + (define buffer (dlang/char-buf input)) (define result (dlang/exponent buffer)) (and (string? result) (equal? "E012" result))))) @@ -421,7 +421,7 @@ (def-test "dlang/exponent should recognize a negative exponent" (call-with-input-string "e-012" (lambda (input) - (define buffer (buf input read-char)) + (define buffer (dlang/char-buf input)) (define result (dlang/exponent buffer)) (and (string? result) (equal? "e-012" result))))) @@ -429,14 +429,14 @@ (def-test "dlang/exponent should error when no integer portion in input" (call-with-input-string "e " (lambda (input) - (define buffer (buf input read-char)) + (define buffer (dlang/char-buf input)) (check-exception "Expected an integer" (dlang/exponent buffer))))) (def-test "dlang/exponent should error when EOF" (call-with-input-string "" (lambda (input) - (define buffer (buf input read-char)) + (define buffer (dlang/char-buf input)) (check-exception "Expected 'E', received EOF instead" (dlang/exponent buffer))))) @@ -445,7 +445,7 @@ (def-test "dlang/character should recognize a character" (call-with-input-string "'a'" (lambda (input) - (define buffer (buf input read-char)) + (define buffer (dlang/char-buf input)) (define result (dlang/character buffer)) (and (token? result) (equal? 'character (token-type result)) @@ -454,21 +454,21 @@ (def-test "dlang/character should error when missing first single quote" (call-with-input-string "a'" (lambda (input) - (define buffer (buf input read-char)) + (define buffer (dlang/char-buf input)) (check-exception "Expected ''', received 'a' instead" (dlang/character buffer))))) (def-test "dlang/character should error when missing second single quote" (call-with-input-string "'a" (lambda (input) - (define buffer (buf input read-char)) + (define buffer (dlang/char-buf input)) (check-exception "Expected ''', received EOF instead" (dlang/character buffer))))) (def-test "dlang/character should error when EOF reached" (call-with-input-string "'" (lambda (input) - (define buffer (buf input read-char)) + (define buffer (dlang/char-buf input)) (check-exception "Unexpected EOF while parsing character literal" (dlang/character buffer))))) @@ -477,7 +477,7 @@ (def-test "dlang/string should recognize an empty string" (call-with-input-string "\"\"" (lambda (input) - (define buffer (buf input read-char)) + (define buffer (dlang/char-buf input)) (define result (dlang/string buffer)) (and (token? result) (equal? 'string (token-type result)) @@ -486,7 +486,7 @@ (def-test "dlang/string should recognize a string of length 1" (call-with-input-string "\"a\"" (lambda (input) - (define buffer (buf input read-char)) + (define buffer (dlang/char-buf input)) (define result (dlang/string buffer)) (and (token? result) (equal? 'string (token-type result)) @@ -495,7 +495,7 @@ (def-test "dlang/string should recognize a string of length 2" (call-with-input-string "\"ab\"" (lambda (input) - (define buffer (buf input read-char)) + (define buffer (dlang/char-buf input)) (define result (dlang/string buffer)) (and (token? result) (equal? 'string (token-type result)) @@ -504,7 +504,7 @@ (def-test "dlang/string should recognize a string of length 3" (call-with-input-string "\"abc\"" (lambda (input) - (define buffer (buf input read-char)) + (define buffer (dlang/char-buf input)) (define result (dlang/string buffer)) (and (token? result) (equal? 'string (token-type result)) @@ -513,21 +513,21 @@ (def-test "dlang/string should error when missing first double quote" (call-with-input-string "a\"" (lambda (input) - (define buffer (buf input read-char)) + (define buffer (dlang/char-buf input)) (check-exception "Expected '\"', received 'a' instead" (dlang/string buffer))))) (def-test "dlang/string should error when missing second double quote" (call-with-input-string "\"a" (lambda (input) - (define buffer (buf input read-char)) + (define buffer (dlang/char-buf input)) (check-exception "Expected '\"', received EOF instead" (dlang/string buffer))))) (def-test "dlang/string should error when EOF reached" (call-with-input-string "\"" (lambda (input) - (define buffer (buf input read-char)) + (define buffer (dlang/char-buf input)) (check-exception "Expected '\"', received EOF instead" (dlang/string buffer))))) @@ -536,7 +536,7 @@ (def-test "dlang/symbol should recognize a symbol of length one" (call-with-input-string "$a" (lambda (input) - (define buffer (buf input read-char)) + (define buffer (dlang/char-buf input)) (define result (dlang/symbol buffer)) (and (token? result) (equal? 'symbol (token-type result)) @@ -545,7 +545,7 @@ (def-test "dlang/symbol should recognize a symbol of length two" (call-with-input-string "$ab" (lambda (input) - (define buffer (buf input read-char)) + (define buffer (dlang/char-buf input)) (define result (dlang/symbol buffer)) (and (token? result) (equal? 'symbol (token-type result)) @@ -554,7 +554,7 @@ (def-test "dlang/symbol should recognize a symbol of length three" (call-with-input-string "$abc" (lambda (input) - (define buffer (buf input read-char)) + (define buffer (dlang/char-buf input)) (define result (dlang/symbol buffer)) (and (token? result) (equal? 'symbol (token-type result)) @@ -563,7 +563,7 @@ (def-test "dlang/symbol should stop recognition on EOF" (call-with-input-string "$abc" (lambda (input) - (define buffer (buf input read-char)) + (define buffer (dlang/char-buf input)) (define result (dlang/symbol buffer)) (and (token? result) (equal? 'symbol (token-type result)) @@ -572,7 +572,7 @@ (def-test "dlang/symbol should stop recognition on whitespace" (call-with-input-string "$abc " (lambda (input) - (define buffer (buf input read-char)) + (define buffer (dlang/char-buf input)) (define result (dlang/symbol buffer)) (and (token? result) (equal? 'symbol (token-type result)) @@ -581,14 +581,14 @@ (def-test "dlang/symbol should error when no name given for a symbol" (call-with-input-string "$" (lambda (input) - (define buffer (buf input read-char)) + (define buffer (dlang/char-buf input)) (check-exception "An Id was expected but none found." (dlang/symbol buffer))))) (def-test "dlang/symbol should error when EOF" (call-with-input-string "" (lambda (input) - (define buffer (buf input read-char)) + (define buffer (dlang/char-buf input)) (check-exception "Expected '$', received EOF instead" (dlang/symbol buffer))))) @@ -597,7 +597,7 @@ (def-test "dlang/id should recognize an id of length one" (call-with-input-string "a" (lambda (input) - (define buffer (buf input read-char)) + (define buffer (dlang/char-buf input)) (define result (dlang/id buffer)) (and (token? result) (equal? 'id (token-type result)) @@ -606,7 +606,7 @@ (def-test "dlang/id should recognize an id of length two" (call-with-input-string "ab" (lambda (input) - (define buffer (buf input read-char)) + (define buffer (dlang/char-buf input)) (define result (dlang/id buffer)) (and (token? result) (equal? 'id (token-type result)) @@ -615,7 +615,7 @@ (def-test "dlang/id should recognize an id of length three" (call-with-input-string "abc" (lambda (input) - (define buffer (buf input read-char)) + (define buffer (dlang/char-buf input)) (define result (dlang/id buffer)) (and (token? result) (equal? 'id (token-type result)) @@ -624,7 +624,7 @@ (def-test "dlang/id should stop recognition on whitespace" (call-with-input-string "abc abc" (lambda (input) - (define buffer (buf input read-char)) + (define buffer (dlang/char-buf input)) (define result (dlang/id buffer)) (and (token? result) (equal? 'id (token-type result)) @@ -633,7 +633,7 @@ (def-test "dlang/id should stop recognition on EOF" (call-with-input-string "abc" (lambda (input) - (define buffer (buf input read-char)) + (define buffer (dlang/char-buf input)) (define result (dlang/id buffer)) (and (token? result) (equal? 'id (token-type result)) @@ -642,14 +642,14 @@ (def-test "dlang/id should error when no id recognized" (call-with-input-string "" (lambda (input) - (define buffer (buf input read-char)) + (define buffer (dlang/char-buf input)) (check-exception "An Id was expected but none found." (dlang/id buffer))))) (def-test "dlang/id should stop recognition when comment encountered" (call-with-input-string "foo#" (lambda (input) - (define buffer (buf input read-char)) + (define buffer (dlang/char-buf input)) (define result (dlang/id buffer)) (and (token? result) (equal? 'id (token-type result)) @@ -658,7 +658,7 @@ (def-test "dlang/id should stop recognition when left paren encountered" (call-with-input-string "foo(" (lambda (input) - (define buffer (buf input read-char)) + (define buffer (dlang/char-buf input)) (define result (dlang/id buffer)) (and (token? result) (equal? 'id (token-type result)) @@ -667,7 +667,7 @@ (def-test "dlang/id should stop recognition when right paren encountered" (call-with-input-string "foo)" (lambda (input) - (define buffer (buf input read-char)) + (define buffer (dlang/char-buf input)) (define result (dlang/id buffer)) (and (token? result) (equal? 'id (token-type result)) @@ -676,7 +676,7 @@ (def-test "dlang/id should stop recognition when semicolon encountered" (call-with-input-string "foo;" (lambda (input) - (define buffer (buf input read-char)) + (define buffer (dlang/char-buf input)) (define result (dlang/id buffer)) (and (token? result) (equal? 'id (token-type result)) @@ -685,7 +685,7 @@ (def-test "dlang/id should stop recognition when comma encountered" (call-with-input-string "foo," (lambda (input) - (define buffer (buf input read-char)) + (define buffer (dlang/char-buf input)) (define result (dlang/id buffer)) (and (token? result) (equal? 'id (token-type result)) @@ -694,7 +694,7 @@ (def-test "dlang/id should stop recognition when single quote encountered" (call-with-input-string "foo'" (lambda (input) - (define buffer (buf input read-char)) + (define buffer (dlang/char-buf input)) (define result (dlang/id buffer)) (and (token? result) (equal? 'id (token-type result)) @@ -703,7 +703,7 @@ (def-test "dlang/id should stop recognition when double quote encountered" (call-with-input-string "foo\"" (lambda (input) - (define buffer (buf input read-char)) + (define buffer (dlang/char-buf input)) (define result (dlang/id buffer)) (and (token? result) (equal? 'id (token-type result)) @@ -712,7 +712,7 @@ (def-test "dlang/id should stop recognition when dollar sign encountered" (call-with-input-string "foo$" (lambda (input) - (define buffer (buf input read-char)) + (define buffer (dlang/char-buf input)) (define result (dlang/id buffer)) (and (token? result) (equal? 'id (token-type result)) @@ -723,66 +723,66 @@ (def-test "dlang/id-char? should return true for valid char" (call-with-input-string "f" (lambda (input) - (define buffer (buf input read-char)) + (define buffer (dlang/char-buf input)) (equal? #t (dlang/id-char? buffer))))) (def-test "dlang/id-char? should return false for eof" (call-with-input-string "" (lambda (input) - (define buffer (buf input read-char)) + (define buffer (dlang/char-buf input)) (equal? #f (dlang/id-char? buffer))))) (def-test "dlang/id-char? should return false for whitespace" (call-with-input-string " " (lambda (input) - (define buffer (buf input read-char)) + (define buffer (dlang/char-buf input)) (equal? #f (dlang/id-char? buffer))))) (def-test "dlang/id-char? should return false for left paren" (call-with-input-string "(" (lambda (input) - (define buffer (buf input read-char)) + (define buffer (dlang/char-buf input)) (equal? #f (dlang/id-char? buffer))))) (def-test "dlang/id-char? should return false for right paren" (call-with-input-string ")" (lambda (input) - (define buffer (buf input read-char)) + (define buffer (dlang/char-buf input)) (equal? #f (dlang/id-char? buffer))))) (def-test "dlang/id-char? should return false for semicolon" (call-with-input-string ";" (lambda (input) - (define buffer (buf input read-char)) + (define buffer (dlang/char-buf input)) (equal? #f (dlang/id-char? buffer))))) (def-test "dlang/id-char? should return false for comma" (call-with-input-string "," (lambda (input) - (define buffer (buf input read-char)) + (define buffer (dlang/char-buf input)) (equal? #f (dlang/id-char? buffer))))) (def-test "dlang/id-char? should return false for single quote" (call-with-input-string "'" (lambda (input) - (define buffer (buf input read-char)) + (define buffer (dlang/char-buf input)) (equal? #f (dlang/id-char? buffer))))) (def-test "dlang/id-char? should return false for double quote" (call-with-input-string "\"" (lambda (input) - (define buffer (buf input read-char)) + (define buffer (dlang/char-buf input)) (equal? #f (dlang/id-char? buffer))))) (def-test "dlang/id-char? should return false for dollar sign" (call-with-input-string "$" (lambda (input) - (define buffer (buf input read-char)) + (define buffer (dlang/char-buf input)) (equal? #f (dlang/id-char? buffer))))) (def-test "dlang/id-char? should return false for hash" (call-with-input-string "#" (lambda (input) - (define buffer (buf input read-char)) + (define buffer (dlang/char-buf input)) (equal? #f (dlang/id-char? buffer))))) -- 2.52.0