Run Resyntax again

remotes/jackfirth/master
Jack Firth 2 years ago
parent 14949f8241
commit c339773860

@ -27,7 +27,7 @@
(define orig-insp (variable-reference->module-declaration-inspector (define orig-insp (variable-reference->module-declaration-inspector
(#%variable-reference))) (#%variable-reference)))
(define (disarm stx) (define (disarm stx)
(syntax-disarm stx orig-insp)) stx)
;; parse : syntax-object (box (list-of syntax-object)) -> s-re (see re.rkt) ;; parse : syntax-object (box (list-of syntax-object)) -> s-re (see re.rkt)
;; checks for errors and generates the plain s-exp form for s ;; checks for errors and generates the plain s-exp form for s
@ -37,10 +37,10 @@
;; seen-lex-abbrevs: id-table ;; seen-lex-abbrevs: id-table
[seen-lex-abbrevs (make-immutable-free-id-table)]) [seen-lex-abbrevs (make-immutable-free-id-table)])
(define (recur s) (define (recur s)
(loop (syntax-rearm s stx) (loop s
seen-lex-abbrevs)) seen-lex-abbrevs))
(define (recur/abbrev s id) (define (recur/abbrev s id)
(loop (syntax-rearm s stx) (loop s
(free-id-table-set seen-lex-abbrevs id id))) (free-id-table-set seen-lex-abbrevs id id)))
(syntax-case (disarm stx) (repetition union intersection complement concatenation (syntax-case (disarm stx) (repetition union intersection complement concatenation
char-range char-complement) char-range char-complement)

@ -42,7 +42,7 @@
(let loop ([p (pop)]) (let loop ([p (pop)])
(set-N p +inf.0) (set-N p +inf.0)
(hash-set! results p (f x)) (hash-set! results p (f x))
(when (not (eq? x p)) (unless (eq? x p)
(loop (pop)))))) (loop (pop))))))
;; Will map elements of 'a to 'b sets ;; Will map elements of 'a to 'b sets
(for ([x (in-list nodes)] (for ([x (in-list nodes)]

@ -143,7 +143,7 @@
(λ (state) (λ (state)
(for ([non-term (in-list (grammar-non-terms g))]) (for ([non-term (in-list (grammar-non-terms g))])
(define res (f (trans-key state non-term))) (define res (f (trans-key state non-term)))
(when (not (null? res)) (unless (null? res)
(printf "~a(~a, ~a) = ~a\n" (printf "~a(~a, ~a) = ~a\n"
name name
state state
@ -155,15 +155,15 @@
(printf "~a:\n" name) (printf "~a:\n" name)
(send a for-each-state (send a for-each-state
(λ (state) (λ (state)
(for ([non-term (in-list (grammar-non-terms g))]) (for* ([non-term (in-list (grammar-non-terms g))]
(for ([prod (in-list (grammar-prods-for-non-term g non-term))]) [prod (in-list (grammar-prods-for-non-term g non-term))])
(define res (f state prod)) (define res (f state prod))
(when (not (null? res)) (unless (null? res)
(printf "~a(~a, ~a) = ~a\n" (printf "~a(~a, ~a) = ~a\n"
name name
(kernel-index state) (kernel-index state)
(prod-index prod) (prod-index prod)
(print-output res)))))))) (print-output res)))))))
(define (print-output-terms r) (define (print-output-terms r)
(map gram-sym-symbol r)) (map gram-sym-symbol r))

Loading…
Cancel
Save