Skip to content

Commit

Permalink
Update expand.ss to check locally defined low-level macro expansion
Browse files Browse the repository at this point in the history
Signed-off-by: yamacir-kit <[email protected]>
  • Loading branch information
yamacir-kit committed Aug 28, 2024
1 parent 3e7f303 commit f20d106
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 5 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ Procedures for each standard are provided by the following R7RS-style libraries:
cmake -B build -DCMAKE_BUILD_TYPE=Release
cd build
make package
sudo apt install build/meevax_0.5.220_amd64.deb
sudo apt install build/meevax_0.5.221_amd64.deb
```

or
Expand Down Expand Up @@ -122,9 +122,9 @@ sudo rm -rf /usr/local/share/meevax

| Target Name | Description
|-------------|-------------
| `all` | Build shared-library `libmeevax.0.5.220.so` and executable `meevax`
| `all` | Build shared-library `libmeevax.0.5.221.so` and executable `meevax`
| `test` | Test executable `meevax`
| `package` | Generate debian package `meevax_0.5.220_amd64.deb`
| `package` | Generate debian package `meevax_0.5.221_amd64.deb`
| `install` | Copy files into `/usr/local` directly

## Usage
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.5.220
0.5.221
79 changes: 78 additions & 1 deletion test/expand.ss
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,25 @@
x))
1 2))

(check (strip '(let ((x 1)
(y 2))
(let-syntax ((local-sc-swap!
(sc-macro-transformer
(lambda (form on-use)
(let ((a (make-syntactic-closure on-use '() (cadr form)))
(b (make-syntactic-closure on-use '() (caddr form))))
`(let ((x ,a))
(set! ,a ,b)
(set! ,b x)))))))
(local-sc-swap! x y))))
=> '((lambda (x y)
((lambda (local-sc-swap!)
((lambda (x)
(set! x y)
(set! y x))
x))))
1 2))

(eval '(define-syntax rsc-swap!
(rsc-macro-transformer
(lambda (form environment)
Expand All @@ -132,6 +151,28 @@
x))
1 2))

(check (strip '(let ((x 1)
(y 2))
(let-syntax ((local-rsc-swap!
(rsc-macro-transformer
(lambda (form environment)
(let ((a (cadr form))
(b (caddr form))
(x (make-syntactic-closure environment '() 'x))
(let (make-syntactic-closure environment '() 'let))
(set! (make-syntactic-closure environment '() 'set!)))
`(,let ((,x ,a))
(,set! ,a ,b)
(,set! ,b ,x)))))))
(local-rsc-swap! x y))))
=> '((lambda (x y)
((lambda (local-rsc-swap!)
((lambda (x)
(set! x y)
(set! y x))
x))))
1 2))

(eval '(define-syntax er-swap!
(er-macro-transformer
(lambda (form rename compare)
Expand All @@ -152,6 +193,25 @@
x))
1 2))

(check (strip '(let ((x 1)
(y 2))
(let-syntax ((local-er-swap!
(er-macro-transformer
(lambda (form rename compare)
(let ((a (cadr form))
(b (caddr form)))
`(,(rename 'let) ((,(rename 'x) ,a))
(,(rename 'set!) ,a ,b)
(,(rename 'set!) ,b ,(rename 'x))))))))
(local-er-swap! x y))))
=> '((lambda (x y)
((lambda (local-er-swap!)
((lambda (x)
(set! x y)
(set! y x))
x))))
1 2))

(eval '(define-syntax swap!
(syntax-rules ()
((swap! a b)
Expand All @@ -170,6 +230,23 @@
x))
1 2))

(check (strip '(let ((x 1)
(y 2))
(let-syntax ((local-swap!
(syntax-rules ()
((swap! a b)
(let ((x a))
(set! a b)
(set! b x))))))
(local-swap! x y))))
=> '((lambda (x y)
((lambda (local-swap!)
((lambda (x)
(set! x y)
(set! y x))
x))))
1 2))

(check (strip '(cond-expand
(r5rs 'r5rs)
(r6rs 'r6rs)
Expand All @@ -179,4 +256,4 @@

(check-report)

(exit (check-passed? 11))
(exit (check-passed? 15))

0 comments on commit f20d106

Please sign in to comment.