syntax/parse: fix for deterministic compilation
Lift compile-time gensyms to vars bound to run-time gensyms.
This commit is contained in:
parent
accb87eddc
commit
1acaf0111d
|
@ -283,6 +283,20 @@ Some optimizations:
|
||||||
|
|
||||||
;; ----
|
;; ----
|
||||||
|
|
||||||
|
(begin-for-syntax
|
||||||
|
;; gensym=>var : Hash[(cons Symbol LiftTarget) => Syntax]
|
||||||
|
(define gensym=>var (make-hash))
|
||||||
|
|
||||||
|
;; lift-gensym : Symbol -> Syntax
|
||||||
|
;; For deterministic compilation. Maps compile-time gensyms used by
|
||||||
|
;; action:post to expressions whose values preserve distinctness.
|
||||||
|
(define (lift-gensym g)
|
||||||
|
(define key (cons g (syntax-local-lift-context)))
|
||||||
|
(hash-ref! gensym=>var key
|
||||||
|
(lambda () (syntax-local-lift-expression #'(gensym))))))
|
||||||
|
|
||||||
|
;; ----
|
||||||
|
|
||||||
#|
|
#|
|
||||||
Conventions:
|
Conventions:
|
||||||
- rhs : RHS
|
- rhs : RHS
|
||||||
|
@ -733,8 +747,10 @@ Conventions:
|
||||||
[#s(action:do _ (stmt ...))
|
[#s(action:do _ (stmt ...))
|
||||||
#'(let () (no-shadow stmt) ... (#%expression k))]
|
#'(let () (no-shadow stmt) ... (#%expression k))]
|
||||||
[#s(action:post _ pattern group index)
|
[#s(action:post _ pattern group index)
|
||||||
#'(let ([pr* (ps-add-post pr 'group 'index)])
|
(with-syntax ([group* (let ([group (syntax->datum #'group)])
|
||||||
(parse:A x cx pattern pr* es k))])]))
|
(if group (lift-gensym group) #'#f))])
|
||||||
|
#'(let ([pr* (ps-add-post pr group* 'index)])
|
||||||
|
(parse:A x cx pattern pr* es k)))])]))
|
||||||
|
|
||||||
;; (bind/sides clauses k) : expr[Ans]
|
;; (bind/sides clauses k) : expr[Ans]
|
||||||
;; In k: attrs(clauses) are bound.
|
;; In k: attrs(clauses) are bound.
|
||||||
|
|
|
@ -79,7 +79,7 @@ A ActionPattern is one of
|
||||||
* (action:and Base (listof ActionPattern))
|
* (action:and Base (listof ActionPattern))
|
||||||
(action:parse Base SinglePattern stx)
|
(action:parse Base SinglePattern stx)
|
||||||
(action:do Base (listof stx))
|
(action:do Base (listof stx))
|
||||||
(action:post Base ActionPattern Quotable Nat)
|
(action:post Base ActionPattern (U UninternedSymbol #f) Nat)
|
||||||
|
|
||||||
action:and is desugared below in create-* procedures
|
action:and is desugared below in create-* procedures
|
||||||
|#
|
|#
|
||||||
|
|
Loading…
Reference in New Issue
Block a user