Skip to content

Commit

Permalink
syntax-rules fix case with (??? . x) #43
Browse files Browse the repository at this point in the history
  • Loading branch information
jcubic committed Aug 21, 2020
1 parent a30a3f1 commit da27a7e
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 25 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![Join the chat at https://gitter.im/jcubic/lips](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/jcubic/lips)
[![npm](https://img.shields.io/badge/npm-DEV-blue.svg)](https://www.npmjs.com/package/@jcubic/lips)
[![travis](https://travis-ci.org/jcubic/lips.svg?branch=devel&f5a7a13b142683d67ff90fc0d880c6f298841692)](https://travis-ci.org/jcubic/lips)
[![travis](https://travis-ci.org/jcubic/lips.svg?branch=devel&a30a3f1e6a7663a7d33596ced712734b05910635)](https://travis-ci.org/jcubic/lips)
[![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&2c48907438a7265935a7b21e6931008d)](https://coveralls.io/github/jcubic/lips?branch=devel)


Expand Down
31 changes: 17 additions & 14 deletions dist/lips.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
* Copyright (c) 2014-present, Facebook, Inc.
* released under MIT license
*
* build: Fri, 21 Aug 2020 10:42:32 +0000
* build: Fri, 21 Aug 2020 12:12:50 +0000
*/
(function () {
'use strict';
Expand Down Expand Up @@ -4451,19 +4451,22 @@
if (_result2 !== nil) {
_result2 = _result2.reverse();
} // case if (x ... y ...) second spread is not processed
// and (??? . x) last symbol
// by ellipsis transformation


if (expr.cdr instanceof Pair && expr.cdr.cdr instanceof Pair) {
var node = traverse(expr.cdr.cdr, {
disabled: disabled
});
if (expr.cdr instanceof Pair) {
if (expr.cdr.cdr instanceof Pair || expr.cdr.cdr instanceof LSymbol) {
var node = traverse(expr.cdr.cdr, {
disabled: disabled
});

if (is_null) {
return node;
}
if (is_null) {
return node;
}

_result2.append(node);
_result2.append(node);
}
}

return _result2;
Expand Down Expand Up @@ -7227,9 +7230,9 @@
pprint: doc(function (arg) {
if (arg instanceof Pair) {
arg = new lips.Formatter(arg.toString(true))["break"]().format();
this.get('stdout').write.call(this, arg);
} else {
this.get('display').call(this, arg);
} else {
this.get('write').call(this, arg);
}

this.get('newline').call(this);
Expand Down Expand Up @@ -10235,10 +10238,10 @@

var banner = function () {
// Rollup tree-shaking is removing the variable if it's normal string because
// obviously 'Fri, 21 Aug 2020 10:42:32 +0000' == '{{' + 'DATE}}'; can be removed
// obviously 'Fri, 21 Aug 2020 12:12:50 +0000' == '{{' + 'DATE}}'; can be removed
// but disablig Tree-shaking is adding lot of not used code so we use this
// hack instead
var date = LString('Fri, 21 Aug 2020 10:42:32 +0000').valueOf();
var date = LString('Fri, 21 Aug 2020 12:12:50 +0000').valueOf();

var _date = date === '{{' + 'DATE}}' ? new Date() : new Date(date);

Expand Down Expand Up @@ -10275,7 +10278,7 @@
var lips = {
version: 'DEV',
banner: banner,
date: 'Fri, 21 Aug 2020 10:42:32 +0000',
date: 'Fri, 21 Aug 2020 12:12:50 +0000',
exec: exec,
parse: parse,
tokenize: tokenize,
Expand Down
4 changes: 2 additions & 2 deletions dist/lips.min.js

Large diffs are not rendered by default.

15 changes: 9 additions & 6 deletions src/lips.js
Original file line number Diff line number Diff line change
Expand Up @@ -2792,14 +2792,17 @@
result = result.reverse();
}
// case if (x ... y ...) second spread is not processed
// and (??? . x) last symbol
// by ellipsis transformation
if (expr.cdr instanceof Pair &&
expr.cdr.cdr instanceof Pair) {
const node = traverse(expr.cdr.cdr, { disabled });
if (is_null) {
return node;
if (expr.cdr instanceof Pair) {
if (expr.cdr.cdr instanceof Pair ||
expr.cdr.cdr instanceof LSymbol) {
const node = traverse(expr.cdr.cdr, { disabled });
if (is_null) {
return node;
}
result.append(node);
}
result.append(node);
}
return result;
}
Expand Down
4 changes: 2 additions & 2 deletions tests/syntax.scm
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@
(t.is (F 10) 3628800)))


(test_ "syntax-rules: join macros"
(test "syntax-rules: join macros"
(lambda (t)

(define-syntax join_1
Expand Down Expand Up @@ -410,7 +410,7 @@
(t.is result '(((bar 1) (bar 2)) ((baz 3) (baz 4))))))


(test_f "syntax-rules: R6RS do macro"
(test_ "syntax-rules: R6RS do macro"
(lambda (t)
(define-syntax do
(syntax-rules ()
Expand Down

0 comments on commit da27a7e

Please sign in to comment.