add `from/stop-before`

pull/10/head
Matthew Butterick 7 years ago
parent 0f576805ac
commit eab018a9a2

@ -1053,5 +1053,9 @@ characters.}
A string that is bounded by @racket[open] and @racket[close]. Matching is non-greedy (meaning, it stops at the first occurence of @racket[close]). The resulting lexeme includes @racket[open] and @racket[close]. To remove them, see @racket[trim-ends].}
@defform[(from/stop-before open close)]{
Like @racket[from/to], a string that is bounded by @racket[open] and @racket[close], except that @racket[close] is not included in the resulting lexeme. Matching is non-greedy (meaning, it stops at the first occurence of @racket[close]).}
@close-eval[my-eval]

@ -92,8 +92,16 @@
(λ(stx)
(syntax-case stx ()
[(_ OPEN CLOSE)
;; (:seq any-string CLOSE any-string) pattern makes it non-greedy
#'(:seq OPEN (complement (:seq any-string CLOSE any-string)) CLOSE)])))
(provide from/stop-before)
(define-lex-trans from/stop-before
(λ(stx)
(syntax-case stx ()
[(_ OPEN CLOSE)
#'(:seq OPEN (:* (:~ CLOSE)))])))
(provide uc+lc)
(define-lex-trans uc+lc
(λ(stx)

Loading…
Cancel
Save