|
|
@ -6,8 +6,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
(provide drracket-lexer)
|
|
|
|
(provide drracket-lexer)
|
|
|
|
|
|
|
|
|
|
|
|
(define drracket-lexer
|
|
|
|
(define in-racket-expr? #f)
|
|
|
|
(let ([in-racket-expr? #f])
|
|
|
|
|
|
|
|
|
|
|
|
(define (at-racket-boundary? input-port)
|
|
|
|
|
|
|
|
(equal? (peek-string 2 0 input-port) "$@"))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(module+ test
|
|
|
|
|
|
|
|
(require rackunit)
|
|
|
|
|
|
|
|
(check-true (at-racket-boundary? (open-input-string "$@foo")))
|
|
|
|
|
|
|
|
(check-false (at-racket-boundary? (open-input-string "foo$@"))))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(define (drracket-lexer input-port)
|
|
|
|
|
|
|
|
(define this-lexer
|
|
|
|
(lexer
|
|
|
|
(lexer
|
|
|
|
[(eof) (values lexeme 'eof #f #f #f)]
|
|
|
|
[(eof) (values lexeme 'eof #f #f #f)]
|
|
|
|
["@$" (begin
|
|
|
|
["@$" (begin
|
|
|
@ -19,6 +29,7 @@
|
|
|
|
[(:seq "//" (:* (char-complement #\newline)))
|
|
|
|
[(:seq "//" (:* (char-complement #\newline)))
|
|
|
|
(values lexeme 'comment #f (position-offset start-pos) (position-offset end-pos))]
|
|
|
|
(values lexeme 'comment #f (position-offset start-pos) (position-offset end-pos))]
|
|
|
|
[any-char
|
|
|
|
[any-char
|
|
|
|
(if in-racket-expr?
|
|
|
|
(values lexeme 'string #f (position-offset start-pos) (position-offset end-pos))]))
|
|
|
|
(racket-lexer (transplant-input-port (open-input-string lexeme) #f (position-offset start-pos)))
|
|
|
|
(if (and in-racket-expr? (not (at-racket-boundary? input-port)))
|
|
|
|
(values lexeme 'string #f (position-offset start-pos) (position-offset end-pos)))])))
|
|
|
|
(racket-lexer input-port)
|
|
|
|
|
|
|
|
(this-lexer input-port)))
|