read-position.scm (1180B)
1 (define-library (rsv read-position) 2 (import (scheme base) 3 (srfi srfi-9 gnu)) 4 (export make-position 5 position-row 6 position-column 7 add-position-row 8 add-position-column 9 add-position-row-column 10 set-position-column) 11 12 (begin 13 (define-immutable-record-type <position> 14 (make-position row column) 15 position? 16 (row position-row set-position-row) 17 (column position-column set-position-column)) 18 19 (define (add-position-row position n) 20 "Add N to POSITION's row count." 21 (set-position-row position 22 (+ (position-row position) 23 n))) 24 25 (define (add-position-column position n) 26 "Add N to POSITION's column count." 27 (set-position-column position 28 (+ (position-column position) 29 n))) 30 31 (define (add-position-row-column position n m) 32 "Add N to POSITION's row count and M to its column count." 33 (set-fields position 34 ((position-row) (add-position-row position n)) 35 ((position-column) (add-position-column position m))))))