1.9 Unwindable State
procedure
(syntax-parse-state-ref key [default]) → any/c
key : any/c default : default/c = (lambda () (error ....))
procedure
(syntax-parse-state-set! key value) → void?
key : any/c value : any/c
procedure
(syntax-parse-state-update! key update [ default]) → void? key : any/c update : (-> any/c any/c) default : default/c = (lambda () (error ....))
procedure
(syntax-parse-state-cons! key value [default]) → void?
key : any/c value : any/c default : default/c = null
Get or update the current syntax-parse state. Updates to the
state are unwound when syntax-parse backtracks. Keys are
compared using eq?.
The state can be updated only within ~do patterns (or #:do blocks). In addition, syntax-parse automatically adds identifiers that match literals (from ~literal patterns and literals declared with #:literals, but not from ~datum or #:datum-literals) under the key 'literals.
Examples:
> (define-syntax-class cond-clause #:literals (=> else) (pattern [test:expr => ~! answer:expr ...]) (pattern [else answer:expr ...]) (pattern [test:expr answer:expr ...]))
> (syntax-parse #'(cond [A => B] [else C]) [(_ c:cond-clause ...) (syntax-parse-state-ref 'literals null)]) '(#<syntax:2:0 else> #<syntax:2:0 =>>)
Added in version 6.11.0.4 of package base.