From 83b00c0cf19478654729e71b2e13a6a25c770547 Mon Sep 17 00:00:00 2001 From: Robby Findler Date: Tue, 22 Feb 2011 20:42:19 -0600 Subject: [PATCH] adjust the module-lexer so it explicitly notes malformed #lang lines before going into "no-lang-line" mode closes PR 11766 --- collects/syntax-color/module-lexer.rkt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/collects/syntax-color/module-lexer.rkt b/collects/syntax-color/module-lexer.rkt index c4273174eb..bf21c26a2d 100644 --- a/collects/syntax-color/module-lexer.rkt +++ b/collects/syntax-color/module-lexer.rkt @@ -61,7 +61,12 @@ to delegate to the scheme-lexer (in the 'no-lang-line mode). scheme-lexer))] [else (read-string (file-position lexer-port) in) ;; sync ports - (values lexeme type data new-token-start new-token-end 0 'no-lang-line)])])] + (if (and (eq? type 'other) + (string? lexeme) + ;; the read-language docs say that this is all it takes to commit to a #lang + (regexp-match #rx"^#[!l]" lexeme)) + (values lexeme 'error data new-token-start new-token-end 0 'no-lang-line) + (values lexeme type data new-token-start new-token-end 0 'no-lang-line))])])] [(eq? mode 'no-lang-line) (let-values ([(lexeme type data new-token-start new-token-end) (scheme-lexer in)])