diff --git a/brag/private/internal-support.rkt b/brag/private/internal-support.rkt index 404cf98..aaad582 100755 --- a/brag/private/internal-support.rkt +++ b/brag/private/internal-support.rkt @@ -15,12 +15,12 @@ (make-parameter (lambda (tok-name tok-value offset line col span) (raise (exn:fail:parsing - (format "Encountered parsing error near ~e (token ~e) while parsing ~e [line=~a, column=~a, offset=~a]" - tok-value tok-name - (current-source) - line col offset) - (current-continuation-marks) - (list (srcloc (current-source) line col offset span))))))) + (format "Encountered parsing error near ~e (token ~e) while parsing ~e [line=~a, column=~a, offset=~a]" + tok-value tok-name + (current-source) + line col offset) + (current-continuation-marks) + (list (srcloc (current-source) line col offset span))))))) ;; When a tokenization error happens, we call the current-tokenizer-error-handler. (define current-tokenizer-error-handler @@ -28,7 +28,10 @@ (lambda (tok-type tok-value offset line column span) (raise (exn:fail:parsing (string-append - (format "Encountered unexpected token ~e (~e) while parsing" tok-type tok-value) + (format "Encountered unexpected token of type ~e (value ~e) while parsing" + (if (memq tok-type (map string->symbol '("\n" "\t" "\r"))) + (format "~a" tok-type) + tok-type) tok-value) (if (or (current-source) line column offset) (format " ~e [line=~a, column=~a, offset=~a]" (current-source) line column offset) "")) diff --git a/brag/test/test-0n1.rkt b/brag/test/test-0n1.rkt index 5611f6e..077b5d8 100755 --- a/brag/test/test-0n1.rkt +++ b/brag/test/test-0n1.rkt @@ -46,5 +46,5 @@ (check-exn exn:fail:parsing? (lambda () (parse '("zero" "one" "zero")))) (check-exn (regexp (regexp-quote - "Encountered unexpected token \"zero\" (\"zero\") while parsing")) + "Encountered unexpected token of type \"zero\" (value \"zero\") while parsing")) (lambda () (parse '("zero" "one" "zero"))))