Skip to content

Commit

Permalink
fix syntax-rules macro that manipulate code
Browse files Browse the repository at this point in the history
  • Loading branch information
jcubic committed Feb 4, 2024
1 parent fd3c0c1 commit bc7af27
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 21 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
* fix Dark Mode colors and scrolling of the page when using Bookmarklet on English Wikipedia
* remove dependencies on `cond` from `-->` macro so you can use use `-->` inside `cond`
* fix handling of recursive `flatten` `syntax-rules` macro [#304](https://github.com/jcubic/lips/issues/304)
* fix macro that manipulate code (see tests/syntax.scm and undswap macro)

## 1.0.0-beta.18
### Breaking
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
[![npm](https://img.shields.io/badge/npm-1.0.0%E2%80%93beta.18.1-blue.svg)](https://www.npmjs.com/package/@jcubic/lips)
![1.0.0 Complete](https://img.shields.io/github/milestones/progress-percent/jcubic/lips/1?label=1.0.0%20Complete)
[![Build and test](https://github.com/jcubic/lips/actions/workflows/build.yaml/badge.svg?branch=devel&event=push)](https://github.com/jcubic/lips/actions/workflows/build.yaml)
[![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&317fbf1b89c2edde12f59a2d1552c802)](https://coveralls.io/github/jcubic/lips?branch=devel)
[![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&9e9d6f8ae74a8a0c59e64c6d8e5b5889)](https://coveralls.io/github/jcubic/lips?branch=devel)
[![Join Gitter Chat](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/jcubic/lips)
![NPM Download Count](https://img.shields.io/npm/dm/@jcubic/lips)
![JSDelivr Download count](https://img.shields.io/jsdelivr/npm/hm/@jcubic/lips)
Expand Down
14 changes: 9 additions & 5 deletions dist/lips.cjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 9 additions & 5 deletions dist/lips.esm.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions dist/lips.esm.min.js

Large diffs are not rendered by default.

14 changes: 9 additions & 5 deletions dist/lips.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions dist/lips.min.js

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion src/lips.js
Original file line number Diff line number Diff line change
Expand Up @@ -4438,7 +4438,11 @@ function is_env(o) {
}
// ----------------------------------------------------------------------
function is_callable(o) {
return is_function(o) || is_continuation(o) || is_parameter(o);
return is_function(o) || is_continuation(o) || is_parameter(o) || is_macro(o);
}
// ----------------------------------------------------------------------
function is_macro(o) {
return o instanceof Macro || o instanceof SyntaxParameter;
}
// ----------------------------------------------------------------------
function is_promise(o) {
Expand Down
13 changes: 13 additions & 0 deletions tests/syntax.scm
Original file line number Diff line number Diff line change
Expand Up @@ -1517,3 +1517,16 @@
(t.is (let-slim (x 10 y 20)
(+ x y))
30)))

(test "syntax: undswap"
(lambda (t)
;; ref: https://stackoverflow.com/a/58965190/387194
(define-syntax undswap
(syntax-rules (_)
((undswap val (e ...))
((undswap val e) ...))
((undswap val _) val)
((undswap val e) e)))

(t.is (undswap 3 (if _ (+ 3 _ )))
6)))

0 comments on commit bc7af27

Please sign in to comment.