https://github.com/nyuichi/r7expander
R7RS expander
https://github.com/nyuichi/r7expander
scheme scheme-compiler scheme-programming-language
Last synced: about 2 months ago
JSON representation
R7RS expander
- Host: GitHub
- URL: https://github.com/nyuichi/r7expander
- Owner: nyuichi
- License: mit
- Created: 2018-08-02T08:45:41.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2021-08-18T06:10:42.000Z (almost 4 years ago)
- Last Synced: 2025-01-30T13:24:14.759Z (4 months ago)
- Topics: scheme, scheme-compiler, scheme-programming-language
- Language: Scheme
- Size: 42 KB
- Stars: 15
- Watchers: 6
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# TL;DR
```scheme
;;; test.sld
(define-library (foo bar)
(import (scheme base))
(begin
(define x 1)
(let ((y 2))
(+ x y))))
``````shell
$ make
$ ./r7expander.scm -l test.sld
(begin
(define foo.bar:x 1)
((lambda (%y.0) (+ foo.bar:x %y.0)) 2))
>
```# r7expander: a macro expander for R7RS
r7expander is a macro expander for R7RS.
This expander implements an expander for R7RS macros and libraries.
Given a r7rs program or library, it will1. resolve library import sets and manage export sets,
2. rename local/global variables, and
3. expand all macros.r7expander is inspired by Al Petrosky's alexpander.
Similarly to his system, r7expander is a simple data-in data-out program.
Some differences are listed below:- Main part of the program is implemented as reusable R7RS libraries.
- It deals with the library system.
- Technically, it uses syntactic closures as basic blocks of hygienic expansion.Produced programs will be valid R5RS programs that may contain R5RS primitives
- function calls, variables, constants,
- if, quote, set!, lambda, define (only binary ones), begin,together with
- parameterize,
- define-record-type, and
- case-lambda.Internal definitions are not translated into letrec* because outputs can have internal define-record-type, which we don't know how to expand into internal (ordinary) definitions.
# Implementation notes
Non-standard built-in libraries listed below:
- `(r7expander builtin)` exports basic keywords such as `define` and `lambda`.
- `(r7expander native)` exports all native procedures available.#### License
Licensed under MIT license.
Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in r7expander by you shall be licensed as above, without any additional terms or conditions.