Use `syntax-parse` in `support.rkt`

remotes/jackfirth/master
Jack Firth 2 years ago
parent a20f1b5a32
commit d33149d20b

@ -1,9 +1,9 @@
#lang racket/base #lang racket/base
(require yaragg/parser-tools/lex (require (for-syntax racket/base
syntax/parse)
yaragg/parser-tools/lex
racket/string racket/string
racket/struct (prefix-in : yaragg/parser-tools/lex-sre))
(prefix-in : yaragg/parser-tools/lex-sre)
(for-syntax racket/base))
(provide (all-from-out yaragg/parser-tools/lex) (provide (all-from-out yaragg/parser-tools/lex)
(all-from-out yaragg/parser-tools/lex-sre) (all-from-out yaragg/parser-tools/lex-sre)
[struct-out token-struct] [struct-out token-struct]
@ -107,23 +107,23 @@
(provide from/to) (provide from/to)
(define-lex-trans from/to (define-lex-trans from/to
(λ(stx) (λ (stx)
(syntax-case stx () (syntax-parse stx
[(_ OPEN CLOSE) [(_ OPEN CLOSE)
#'(:seq (from/stop-before OPEN CLOSE) CLOSE)]))) #'(:seq (from/stop-before OPEN CLOSE) CLOSE)])))
(provide from/stop-before) (provide from/stop-before)
(define-lex-trans from/stop-before (define-lex-trans from/stop-before
(λ(stx) (λ (stx)
(syntax-case stx () (syntax-parse stx
[(_ OPEN CLOSE) [(_ OPEN CLOSE)
;; (:seq any-string CLOSE any-string) pattern makes it non-greedy ;; (:seq any-string CLOSE any-string) pattern makes it non-greedy
#'(:seq OPEN (complement (:seq any-string CLOSE any-string)))]))) #'(:seq OPEN (complement (:seq any-string CLOSE any-string)))])))
(provide uc+lc) (provide uc+lc)
(define-lex-trans uc+lc (define-lex-trans uc+lc
(λ(stx) (λ (stx)
(syntax-case stx () (syntax-parse stx
[(_ . STRS) [(_ . STRS)
(with-syntax ([(UCSTR ...) (map (compose1 string-upcase syntax->datum) (syntax->list #'STRS))] (with-syntax ([(UCSTR ...) (map (compose1 string-upcase syntax->datum) (syntax->list #'STRS))]
[(LCSTR ...) (map (compose1 string-downcase syntax->datum) (syntax->list #'STRS))]) [(LCSTR ...) (map (compose1 string-downcase syntax->datum) (syntax->list #'STRS))])

Loading…
Cancel
Save