Skip to content

Commit

Permalink
Allow nanopass parsers without run-time dependency
Browse files Browse the repository at this point in the history
Removed np-parse-fail-token as a run-time dependency by making it a macro.
The whole parser really needs to be revisited, but this should make it
possible to generate compilers with intermediate language parser that do
not have a run-time dependency on the nanopass framework.
  nanopass/parser.ss, nanopass/helpers.ss,
  nanopass/implementation-helpers.chezscheme.sls,
  nanopass/implementation-helpers.ikarus.ss,
  nanopass/implementation-helpers.ironscheme.sls,
  nanopass/implementation-helpers.vicare.sls# Please enter the commit message for your changes. Lines starting
  • Loading branch information
akeep committed Oct 18, 2020
1 parent a86cf73 commit 68990d0
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 28 deletions.
10 changes: 10 additions & 0 deletions LOG
Original file line number Diff line number Diff line change
Expand Up @@ -820,3 +820,13 @@ LATEST
nano-syntax-dispatch) library. With this change the pattern no longer
needs to be quoted in the output of define-parser.
nanopass/nano-syntax-dispatch.ss, nanopass/parser.ss
2020-10-18 -
* Removed np-parse-fail-token as a run-time dependency by making it a macro.
The whole parser really needs to be revisited, but this should make it
possible to generate compilers with intermediate language parser that do
not have a run-time dependency on the nanopass framework.
nanopass/parser.ss, nanopass/helpers.ss,
nanopass/implementation-helpers.chezscheme.sls,
nanopass/implementation-helpers.ikarus.ss,
nanopass/implementation-helpers.ironscheme.sls,
nanopass/implementation-helpers.vicare.sls
3 changes: 0 additions & 3 deletions nanopass/helpers.ss
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,6 @@
;; the base record, so that we can use gensym syntax
define-nanopass-record

;; failure token so that we can know when parsing fails with a gensym
np-parse-fail-token

;; handy syntactic stuff
with-implicit with-r6rs-quasiquote with-extended-quasiquote
extended-quasiquote with-auto-unquote
Expand Down
6 changes: 0 additions & 6 deletions nanopass/implementation-helpers.chezscheme.sls
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@
;; the base record, so that we can use gensym syntax
define-nanopass-record

;; failure token so that we can know when parsing fails with a gensym
np-parse-fail-token

;; handy syntactic stuff
with-implicit

Expand All @@ -75,9 +72,6 @@
(nongenerative #{nanopass-record d47f8omgluol6otrw1yvu5-0})
(fields (immutable tag nanopass-record-tag))))])))

;; another gensym listed into this library
(define np-parse-fail-token '#{np-parse-fail-token dlkcd4b37swscag1dvmuiz-13})

;; the following should get moved into Chez Scheme proper (and generally
;; cleaned up with appropriate new Chez Scheme primitives for support)
(define regensym
Expand Down
6 changes: 0 additions & 6 deletions nanopass/implementation-helpers.ikarus.ss
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@
;; the base record, so that we can use gensym syntax
define-nanopass-record

;; failure token so that we can know when parsing fails with a gensym
np-parse-fail-token

;; handy syntactic stuff
with-implicit

Expand Down Expand Up @@ -80,9 +77,6 @@
(nongenerative #{nanopass-record d47f8omgluol6otrw1yvu5-0})
(fields (immutable tag nanopass-record-tag))))])))

;; another gensym listed into this library
(define np-parse-fail-token '#{np-parse-fail-token dlkcd4b37swscag1dvmuiz-13})

(define-syntax eq-hashtable-set! (identifier-syntax hashtable-set!))
(define-syntax eq-hashtable-ref (identifier-syntax hashtable-ref))

Expand Down
7 changes: 0 additions & 7 deletions nanopass/implementation-helpers.ironscheme.sls
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@
;; the base record, so that we can use gensym syntax
define-nanopass-record

;; failure token so that we can know when parsing fails with a gensym
np-parse-fail-token

;; handy syntactic stuff
with-implicit

Expand Down Expand Up @@ -89,10 +86,6 @@
(nongenerative nanopass-record-d47f8omgluol6otrw1yvu5-0)
(fields (immutable tag nanopass-record-tag))))])))

;; another gensym listed into this library
;; what is this used for?
(define np-parse-fail-token 'np-parse-fail-token-dlkcd4b37swscag1dvmuiz-13)

(define-syntax eq-hashtable-set! (identifier-syntax hashtable-set!))
(define-syntax eq-hashtable-ref (identifier-syntax hashtable-ref))

Expand Down
6 changes: 0 additions & 6 deletions nanopass/implementation-helpers.vicare.sls
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@
;; the base record, so that we can use gensym syntax
define-nanopass-record

;; failure token so that we can know when parsing fails with a gensym
np-parse-fail-token

;; handy syntactic stuff
with-implicit

Expand Down Expand Up @@ -84,9 +81,6 @@
(nongenerative #{nanopass-record d47f8omgluol6otrw1yvu5-0})
(fields (immutable tag nanopass-record-tag))))])))

;; another gensym listed into this library
(define np-parse-fail-token '#{np-parse-fail-token dlkcd4b37swscag1dvmuiz-13})

(define-syntax eq-hashtable-set! (identifier-syntax hashtable-set!))
(define-syntax eq-hashtable-ref (identifier-syntax hashtable-ref))

Expand Down
9 changes: 9 additions & 0 deletions nanopass/parser.ss
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@
(nanopass syntaxconvert)
(nanopass nano-syntax-dispatch))

(define-syntax np-parse-fail-token
(let ([sym (datum->syntax #'* (gensym "np-parse-fail-token"))])
(make-variable-transformer
(lambda (x)
(syntax-case x ()
[id (identifier? #'id) (with-syntax ([sym sym]) #''sym)]
[(set! _ e) (syntax-violation 'np-parse-fail-token "misplaced use of keyword" x)]
[(_ e ...) (syntax-violation 'np-parse-fail-token "misplaced use of keyword" x)])))))

(define-syntax parse-or
(syntax-rules (on-error)
[(_ (on-error ?err0)) ?err0]
Expand Down

0 comments on commit 68990d0

Please sign in to comment.