Skip to content

Commit 779a649

Browse files
committed
when we're not in can-return-hash mode then just use racket-lexer instead of racket-lexer*
1 parent 907dd27 commit 779a649

File tree

2 files changed

+31
-3
lines changed

2 files changed

+31
-3
lines changed

syntax-color-lib/syntax-color/module-lexer.rkt

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,15 @@ to delegate to the racket-lexer (in the no-lang-line mode).
124124
(if can-return-attribs-hash? type (attribs->symbol type))
125125
data new-token-start new-token-end 0 (no-lang-line #f))])])]
126126
[(no-lang-line? mode)
127-
(define-values (lexeme type data new-token-start new-token-end backup new-mode)
128-
(racket-lexer* in offset (no-lang-line-racket-lexer-mode mode)))
129-
(values lexeme type data new-token-start new-token-end backup (no-lang-line new-mode))]
127+
(cond
128+
[can-return-attribs-hash?
129+
(define-values (lexeme type data new-token-start new-token-end backup new-mode)
130+
(racket-lexer* in offset (no-lang-line-racket-lexer-mode mode)))
131+
(values lexeme type data new-token-start new-token-end backup (no-lang-line new-mode))]
132+
[else
133+
(define-values (lexeme type data new-token-start new-token-end)
134+
(racket-lexer in))
135+
(values lexeme type data new-token-start new-token-end 0 mode)])]
130136
[(pair? mode)
131137
;; #lang-selected language consumes and produces a mode:
132138
(let-values ([(lexeme type data new-token-start new-token-end backup-delta new-mode)

syntax-color-test/tests/syntax-color/module-lexer.rkt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,28 @@
183183
(")" #hash((comment? . #t) (type . parenthesis)) 17 18 no-lang-line)
184184
(,eof eof #f #f no-lang-line)))
185185

186+
;; it is possible that the first #; comment should actually be match the results
187+
;; from the first (or maybe the other way around, possibly) but since the code
188+
;; was already working like that and we're not using this lexer much let's just
189+
;; leave a note here giving someone permission to change this test case....
190+
(check-equal? (lex "#;(a b)\n1\n#;(a b)" #t #:modes (list module-lexer))
191+
`(("#;" sexp-comment 1 3 #f)
192+
("(" comment 3 4 before-lang-line)
193+
("a" comment 4 5 before-lang-line)
194+
(" " white-space 5 6 before-lang-line)
195+
("b" comment 6 7 before-lang-line)
196+
(")" comment 7 8 before-lang-line)
197+
("\n" white-space 8 9 before-lang-line)
198+
("1" constant 9 10 before-lang-line)
199+
("\n" white-space 10 11 no-lang-line)
200+
("#;" sexp-comment 11 13 no-lang-line)
201+
("(" parenthesis 13 14 no-lang-line)
202+
("a" symbol 14 15 no-lang-line)
203+
(" " white-space 15 16 no-lang-line)
204+
("b" symbol 16 17 no-lang-line)
205+
(")" parenthesis 17 18 no-lang-line)
206+
(,eof eof #f #f no-lang-line)))
207+
186208
(check same?
187209
(lex "#lang at-exp racket/base\n1\n" #t)
188210
`(("#lang at-exp racket/base" other 1 25 #f)

0 commit comments

Comments
 (0)