don't be a slob (fixes #3)

pull/6/head
Matthew Butterick 7 years ago
parent 9e2e7f04c8
commit 93fcabcc51

@ -652,6 +652,8 @@
pats (caddr old-list))))
nt-ids patss)
;; Build a definition for each non-term:
(let ([start-id-temp (gensym)]
[atok-id-temp (gensym)])
(loop (cdr clauses)
cfg-start
(map (lambda (nt pats handles $ctxs)
@ -704,15 +706,18 @@
[(pos ...)
(if src-pos?
#'($1-start-pos $1-end-pos)
#'(#f #f))])
;; rename `start` and `atok` to `%start` and `%atok`
#'(#f #f))]
;; rename `start` and `atok` to temp ids
;; so that "start" and "atok" can be used as literal string tokens in a grammar.
;; not sure why this works, but it passes all tests.
[%start start-id-temp]
[%atok atok-id-temp])
#`(grammar (%start [() null]
[(%atok %start) (cons $1 $2)])
(%atok [(tok) (make-tok 'tok-id 'tok $e pos ...)] ...)))
#`(start %start)
parser-clauses)))]
(with-syntax ([%start start-id-temp])
#`(start %start))
parser-clauses))))]
[(grammar . _)
(raise-syntax-error
#f

Loading…
Cancel
Save