-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement ellipsis escaping, as per R7RS
In Section 4.3.2 of R7RS (page 23 of the PDF), it is said that a <template> can be one of: 1. (<element> ...) 2. (<element> <element> ... . <template>) 3. (<ellipsis> <template>) 4. #(<element> ...) Number (3) is an escaping pattern. Inside ir, ellipses are treated like a symbol, and not like the syntax-rules ellipsis. And that template *must* have only two elements. (<ellipsis> <template>) should be transformed into <template> but protecting the ellipses (they have no special meaning there). So (... a) => a (... (a b ... c) => (a b ... c) (... ...) => ... (... a b) => error (too many elements) but the ellipses on the right side are ignored by syntax-rules. The implementation is: 1. In MBE, include a check for malformed escapes (as in the last case above, (... a b)) 2. In MBE: (mbe:subst-ellipsis expr ell new-ell) will go through expr, and substitute *only* the sublists that match the form of an escaping ellipsis, doing the appropriate transform. However, inside the subtemplate, the ellipses will be transformed into a symbol which is internal to MBE, produced by gensym (so no match will be possible). This is in find-clause 3. in MBE, "replace" can be used to get the original ellipses back. This is also in find-clause 4. In runtime-macros, syntax-rules calls the internal MBE procedure check-wrong-ellipsis-escape 5. In MBE, let-syntax also does that. Some tests, including the example in R7RS, were added.
- Loading branch information
1 parent
4fef53c
commit 6c085cd
Showing
3 changed files
with
205 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters