adjust module lexer to handle the case of specials in the editor properly

This commit is contained in:
Robby Findler 2011-03-01 15:14:36 -06:00
parent 0b63012e9e
commit 68b5d2abf8

View File

@ -34,7 +34,9 @@ to delegate to the scheme-lexer (in the 'no-lang-line mode).
(cond
[(or (eq? type 'comment) (eq? type 'white-space))
(define lexer-end (file-position lexer-port))
(read-string lexer-end in) ;; sync ports
;; sync ports
(for ([i (in-range 0 lexer-end)])
(read-char-or-special in))
(values lexeme type data new-token-start new-token-end 0 'before-lang-line)]
[else
;; look for #lang:
@ -44,7 +46,9 @@ to delegate to the scheme-lexer (in the 'no-lang-line mode).
(cond
[(procedure? get-info)
(define end-pos (file-position p))
(read-string end-pos in) ;; sync ports
;; sync ports
(for ([i (in-range 0 end-pos)])
(read-char-or-special in))
;; Produce language as first token:
(values
"#lang"
@ -60,7 +64,9 @@ to delegate to the scheme-lexer (in the 'no-lang-line mode).
v)))
scheme-lexer))]
[else
(read-string (file-position lexer-port) in) ;; sync ports
;; sync ports
(for ([i (in-range 0 (file-position lexer-port))])
(read-char-or-special in))
(if (and (eq? type 'other)
(string? lexeme)
;; the read-language docs say that this is all it takes to commit to a #lang