|
|
@ -184,37 +184,36 @@
|
|
|
|
(define id (lambda (x) x))
|
|
|
|
(define id (lambda (x) x))
|
|
|
|
|
|
|
|
|
|
|
|
(define (do-match lb first-pos longest-match-length length longest-match-action wrap?)
|
|
|
|
(define (do-match lb first-pos longest-match-length length longest-match-action wrap?)
|
|
|
|
(if (not longest-match-action)
|
|
|
|
(unless longest-match-action
|
|
|
|
(let* ((match (read-string length lb))
|
|
|
|
(let* ((match (read-string length lb))
|
|
|
|
(end-pos (get-position lb)))
|
|
|
|
(end-pos (get-position lb)))
|
|
|
|
(if (not longest-match-action)
|
|
|
|
(raise-read-error
|
|
|
|
(raise-read-error
|
|
|
|
(format "lexer: No match found in input starting with: ~a" match)
|
|
|
|
(format "lexer: No match found in input starting with: ~a" match)
|
|
|
|
(file-path)
|
|
|
|
(file-path)
|
|
|
|
(position-line first-pos)
|
|
|
|
(position-line first-pos)
|
|
|
|
(position-col first-pos)
|
|
|
|
(position-col first-pos)
|
|
|
|
(position-offset first-pos)
|
|
|
|
(position-offset first-pos)
|
|
|
|
(- (position-offset end-pos) (position-offset first-pos)))))
|
|
|
|
(- (position-offset end-pos) (position-offset first-pos)))))
|
|
|
|
(let* ((match (read-string longest-match-length lb))
|
|
|
|
(let* ((match (read-string longest-match-length lb))
|
|
|
|
(end-pos (get-position lb)))
|
|
|
|
(end-pos (get-position lb)))
|
|
|
|
(cond
|
|
|
|
(cond
|
|
|
|
(wrap?
|
|
|
|
(wrap?
|
|
|
|
(let/ec ret
|
|
|
|
(let/ec ret
|
|
|
|
(list (longest-match-action
|
|
|
|
(list (longest-match-action
|
|
|
|
first-pos
|
|
|
|
first-pos
|
|
|
|
end-pos
|
|
|
|
end-pos
|
|
|
|
match
|
|
|
|
match
|
|
|
|
ret
|
|
|
|
ret
|
|
|
|
lb)
|
|
|
|
lb)
|
|
|
|
first-pos
|
|
|
|
first-pos
|
|
|
|
end-pos)))
|
|
|
|
end-pos)))
|
|
|
|
(else
|
|
|
|
(else
|
|
|
|
(longest-match-action
|
|
|
|
(longest-match-action
|
|
|
|
first-pos
|
|
|
|
first-pos
|
|
|
|
end-pos
|
|
|
|
end-pos
|
|
|
|
match
|
|
|
|
match
|
|
|
|
id
|
|
|
|
id
|
|
|
|
lb)))))
|
|
|
|
lb))))))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(define-struct position (offset line col))
|
|
|
|
(define-struct position (offset line col))
|
|
|
|