obscurity

pull/6/head
Matthew Butterick 7 years ago
parent 93fcabcc51
commit 79cddb19f2

@ -489,6 +489,12 @@
(fail-k max-depth tasks))))]) (fail-k max-depth tasks))))])
(k end max-depth tasks new-got-k new-fail-k)))]))))) (k end max-depth tasks new-got-k new-fail-k)))])))))
;; These temp identifiers can't be `gensym` or `generate-temporary`
;; because they have to be consistent between module loads
;; (IIUC, the parser is multi-threaded, and this approach is not thread-safe)
;; so I see no alternative to the old standby of making them ludicrously unlikely
(define-for-syntax start-id-temp 'start_jihqolbbafscgxvsufnepvmxqipnxgmlpxukmdoqxqzmzgaogaftbkbyqjttwwfimifowdxfyekjiixdmtprfkcvfciraehoeuaz)
(define-for-syntax atok-id-temp 'atok_wrutdjgecmybyfipiwsgjlvsveryodlgassuzcargiuznzgdghrykfqfbwcjgzdhdoeqxcucmtjkuyucskzethozhqkasphdwbht)
(define-syntax (cfg-parser stx) (define-syntax (cfg-parser stx)
(syntax-case stx () (syntax-case stx ()
[(_ clause ...) [(_ clause ...)
@ -652,8 +658,6 @@
pats (caddr old-list)))) pats (caddr old-list))))
nt-ids patss) nt-ids patss)
;; Build a definition for each non-term: ;; Build a definition for each non-term:
(let ([start-id-temp (gensym)]
[atok-id-temp (gensym)])
(loop (cdr clauses) (loop (cdr clauses)
cfg-start cfg-start
(map (lambda (nt pats handles $ctxs) (map (lambda (nt pats handles $ctxs)
@ -717,7 +721,7 @@
(%atok [(tok) (make-tok 'tok-id 'tok $e pos ...)] ...))) (%atok [(tok) (make-tok 'tok-id 'tok $e pos ...)] ...)))
(with-syntax ([%start start-id-temp]) (with-syntax ([%start start-id-temp])
#`(start %start)) #`(start %start))
parser-clauses))))] parser-clauses)))]
[(grammar . _) [(grammar . _)
(raise-syntax-error (raise-syntax-error
#f #f

Loading…
Cancel
Save