#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)
(struct-out posn)
posn->position position->posn)
(define-struct region (source start end) #:prefab)
(define-struct posn (offset line col) #:prefab)
(define (posn->position posn)
(make-position (posn-offset posn)
(posn-line posn)
(posn-col posn)))
(define (position->posn position)
(make-posn (position-offset position)
(position-line position)
(position-col position)))
(define (region->string r)
(format "~a:~a:~a-~a:~a"
(object-name (region-source r))
(posn-line (region-start r))
(posn-col (region-start r))
(posn-line (region-end r))
(posn-col (region-end r))))
(define-struct regexp-contents (pattern global? case-insensitive?)
#:transparent)
(define-struct token (type contents location)
#:transparent)