|
|
@ -1,5 +1,6 @@
|
|
|
|
(module stx mzscheme
|
|
|
|
(module stx mzscheme
|
|
|
|
(require "util.ss")
|
|
|
|
(require (lib "boundmap.ss" "syntax")
|
|
|
|
|
|
|
|
"util.ss")
|
|
|
|
|
|
|
|
|
|
|
|
(provide parse)
|
|
|
|
(provide parse)
|
|
|
|
|
|
|
|
|
|
|
@ -28,10 +29,13 @@
|
|
|
|
((char-range-arg #'"1" #'here) (char->integer #\1)))
|
|
|
|
((char-range-arg #'"1" #'here) (char->integer #\1)))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;; parse : syntax-object -> s-re (see re.ss)
|
|
|
|
;; parse : syntax-object (box (list-of syntax-object)) -> s-re (see re.ss)
|
|
|
|
;; checks for errors and generates the plain s-exp form for s
|
|
|
|
;; checks for errors and generates the plain s-exp form for s
|
|
|
|
;; Expands lex-abbrevs and applies lex-trans.
|
|
|
|
;; Expands lex-abbrevs and applies lex-trans.
|
|
|
|
(define (parse stx)
|
|
|
|
(define (parse stx disappeared-uses)
|
|
|
|
|
|
|
|
(let ((parse
|
|
|
|
|
|
|
|
(lambda (stx)
|
|
|
|
|
|
|
|
(parse stx disappeared-uses))))
|
|
|
|
(syntax-case stx (repetition union intersection complement concatenation
|
|
|
|
(syntax-case stx (repetition union intersection complement concatenation
|
|
|
|
char-range char-complement)
|
|
|
|
char-range char-complement)
|
|
|
|
(_
|
|
|
|
(_
|
|
|
@ -41,6 +45,7 @@
|
|
|
|
(raise-syntax-error 'regular-expression
|
|
|
|
(raise-syntax-error 'regular-expression
|
|
|
|
"undefined abbreviation"
|
|
|
|
"undefined abbreviation"
|
|
|
|
stx))
|
|
|
|
stx))
|
|
|
|
|
|
|
|
(set-box! disappeared-uses (cons stx (unbox disappeared-uses)))
|
|
|
|
(parse (lex-abbrev-abbrev expansion))))
|
|
|
|
(parse (lex-abbrev-abbrev expansion))))
|
|
|
|
(_
|
|
|
|
(_
|
|
|
|
(or (char? (syntax-e stx)) (string? (syntax-e stx)))
|
|
|
|
(or (char? (syntax-e stx)) (string? (syntax-e stx)))
|
|
|
@ -105,7 +110,9 @@
|
|
|
|
`(char-complement ,parsed))))
|
|
|
|
`(char-complement ,parsed))))
|
|
|
|
((op form ...)
|
|
|
|
((op form ...)
|
|
|
|
(identifier? (syntax op))
|
|
|
|
(identifier? (syntax op))
|
|
|
|
(let ((expansion (syntax-local-value (syntax op) (lambda () #f))))
|
|
|
|
(let* ((o (syntax op))
|
|
|
|
|
|
|
|
(expansion (syntax-local-value o (lambda () #f))))
|
|
|
|
|
|
|
|
(set-box! disappeared-uses (cons o (unbox disappeared-uses)))
|
|
|
|
(cond
|
|
|
|
(cond
|
|
|
|
((lex-trans? expansion)
|
|
|
|
((lex-trans? expansion)
|
|
|
|
(parse ((lex-trans-f expansion) stx)))
|
|
|
|
(parse ((lex-trans-f expansion) stx)))
|
|
|
@ -121,7 +128,7 @@
|
|
|
|
(raise-syntax-error
|
|
|
|
(raise-syntax-error
|
|
|
|
'regular-expression
|
|
|
|
'regular-expression
|
|
|
|
"not a char, string, identifier, or (op args ...)"
|
|
|
|
"not a char, string, identifier, or (op args ...)"
|
|
|
|
stx))))
|
|
|
|
stx)))))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|