#lang scheme/base
(require (only-in parser-tools/lex
position struct:position make-position position?
position-offset position-line position-col
set-position-offset! set-position-line! set-position-col!))
(provide (all-defined-out)
(struct-out position))
(define-struct region (source start end)
#:property prop:custom-write (lambda (r port write?)
(fprintf port
"#<region:~a:~a-~a:~a>"
(position-line (region-start r))
(position-col (region-start r))
(position-line (region-end r))
(position-col (region-end r)))))
(define (region->string r)
(format "~a:~a:~a-~a:~a"
(object-name (region-source r))
(position-line (region-start r))
(position-col (region-start r))
(position-line (region-end r))
(position-col (region-end r))))
(define-struct regexp-contents (pattern global? case-insensitive?)
#:transparent)
(define-struct token (type contents location)
#:transparent)