#lang scheme/base
(require "../scat-tx.ss")
(define (single-next code state)
(syntax-case code ()
(()
state)
((thing . code+)
(let ((next (lambda (state+)
(single-next #'code+ state+))))
(syntax-case #'thing (quote)
((quote name)
(next #`(name . #,state)))
((code ...)
(next #`((code ...) . #,state)))
(mode
(syntax-case state ()
((name body . dictionary)
(next #`((name mode #,(stx-srcloc #'name) body)
. dictionary))))))))))
(define (stx-srcloc stx)
#`(list #,(syntax-source stx)
#,(syntax-line stx)
#,(syntax-column stx)
#,(syntax-position stx)
#,(syntax-span stx)))