fix 2d lexer for the case when the #2d expression
isn't in the leftmost column original commit: 93bf0cd663070e5b6df4cda8377be9f7f8f5463f
This commit is contained in:
parent
06ca5775a5
commit
23f6a46faf
|
@ -115,14 +115,12 @@ todo:
|
||||||
0
|
0
|
||||||
a-2d-lexer-state)]
|
a-2d-lexer-state)]
|
||||||
[else
|
[else
|
||||||
(define port->peek-port-delta
|
|
||||||
(let-values ([(_1 _2 c-pos) (port-next-location port)])
|
|
||||||
c-pos))
|
|
||||||
(define base-position
|
(define base-position
|
||||||
;; one might think that this should depend on the length of eol-string
|
;; one might think that this should depend on the length of eol-string
|
||||||
;; but ports that have port-count-lines! enabled count the \r\n combination
|
;; but ports that have port-count-lines! enabled count the \r\n combination
|
||||||
;; as a single position in the port, not 2.
|
;; as a single position in the port, not two.
|
||||||
(+ pos port->peek-port-delta -1))
|
(let-values ([(_1 _2 c-pos) (port-next-location port)])
|
||||||
|
c-pos))
|
||||||
(define peek-port (peeking-input-port port))
|
(define peek-port (peeking-input-port port))
|
||||||
;; pull the newline out of the peek-port
|
;; pull the newline out of the peek-port
|
||||||
(for ([x (in-range (string-length eol-string))]) (read-char peek-port))
|
(for ([x (in-range (string-length eol-string))]) (read-char peek-port))
|
||||||
|
@ -154,7 +152,7 @@ todo:
|
||||||
(cond
|
(cond
|
||||||
[(exn:fail:read? failed)
|
[(exn:fail:read? failed)
|
||||||
(define error-pos (- (srcloc-position (car (exn:fail:read-srclocs failed)))
|
(define error-pos (- (srcloc-position (car (exn:fail:read-srclocs failed)))
|
||||||
port->peek-port-delta)) ;; account for the newline
|
base-position)) ;; account for the newline
|
||||||
(define peek-port2 (peeking-input-port port))
|
(define peek-port2 (peeking-input-port port))
|
||||||
(port-count-lines! peek-port2)
|
(port-count-lines! peek-port2)
|
||||||
|
|
||||||
|
@ -261,8 +259,8 @@ todo:
|
||||||
;; outermost rectangle (at a minimum, newlines); this fills those
|
;; outermost rectangle (at a minimum, newlines); this fills those
|
||||||
;; in with whitespace tokens
|
;; in with whitespace tokens
|
||||||
(define cracks-filled-in-tokens
|
(define cracks-filled-in-tokens
|
||||||
(let loop ([fst (car sorted-tokens)]
|
(let loop ([fst newline-token]
|
||||||
[tokens (cdr sorted-tokens)])
|
[tokens sorted-tokens])
|
||||||
(cond
|
(cond
|
||||||
[(null? tokens) (list fst)]
|
[(null? tokens) (list fst)]
|
||||||
[else
|
[else
|
||||||
|
@ -283,7 +281,7 @@ todo:
|
||||||
new-start
|
new-start
|
||||||
new-end)
|
new-end)
|
||||||
(loop snd (cdr tokens)))])])))
|
(loop snd (cdr tokens)))])])))
|
||||||
(cons newline-token cracks-filled-in-tokens)]))
|
cracks-filled-in-tokens]))
|
||||||
|
|
||||||
(values first-tok-string 'hash-colon-keyword #f
|
(values first-tok-string 'hash-colon-keyword #f
|
||||||
pos (+ pos (string-length first-tok-string))
|
pos (+ pos (string-length first-tok-string))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user