Skip to content

Commit

Permalink
fix undefined + and macro & fix parsing dot comma
Browse files Browse the repository at this point in the history
  • Loading branch information
jcubic committed Aug 20, 2021
1 parent 6f78bbe commit 6636441
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 17 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

[![npm](https://img.shields.io/badge/npm-1.0.0%E2%80%93beta.14-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)
[![travis](https://travis-ci.com/jcubic/lips.svg?branch=devel&ec4290c64c134d8a8602f25d9cc9447874547ca3)](https://travis-ci.com/jcubic/lips)
[![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&c334f01ef6adfd0dfee899a5e7439fe2)](https://coveralls.io/github/jcubic/lips?branch=devel)
[![travis](https://travis-ci.com/jcubic/lips.svg?branch=devel&6f78bbe8ae9d28de94ac337be6b307d7eead416a)](https://travis-ci.com/jcubic/lips)
[![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&506b588b164ff71be41bc85140cbd88d)](https://coveralls.io/github/jcubic/lips?branch=devel)
[![Join Gitter Chat](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/jcubic/lips)
[![GitHub license](https://img.shields.io/github/license/jcubic/lips.svg)](https://github.com/jcubic/lips/blob/master/LICENSE)
![NPM Download Count](https://img.shields.io/npm/dm/@jcubic/lips)
Expand Down
22 changes: 12 additions & 10 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, 20 Aug 2021 19:40:34 +0000
* build: Fri, 20 Aug 2021 20:38:07 +0000
*/
(function () {
'use strict';
Expand Down Expand Up @@ -3030,7 +3030,8 @@
Lexer.b_symbol = Symbol["for"]('b_symbol');
Lexer.b_comment = Symbol["for"]('b_comment');
Lexer.i_comment = Symbol["for"]('i_comment');
Lexer.l_datum = Symbol["for"]('l_datum'); // ----------------------------------------------------------------------
Lexer.l_datum = Symbol["for"]('l_datum');
Lexer.dot = Symbol["for"]('dot'); // ----------------------------------------------------------------------

Lexer.boundary = /^$|[\s()[\]]/; // ----------------------------------------------------------------------

Expand All @@ -3045,7 +3046,8 @@
[/;/, /^$|[^#]/, null, null, Lexer.comment], [/[\s\S]/, null, /\n/, Lexer.comment, null], [/\s/, null, null, Lexer.comment, Lexer.comment], // block comment
[/#/, null, /\|/, null, Lexer.b_comment], [/\s/, null, null, Lexer.b_comment, Lexer.b_comment], [/#/, /\|/, null, Lexer.b_comment, null], // inline commentss
[/#/, null, /;/, null, Lexer.i_comment], [/;/, /#/, null, Lexer.i_comment, null], // datum label
[/#/, null, /[0-9]/, null, Lexer.l_datum], [/=/, /[0-9]/, null, Lexer.l_datum, null], [/#/, /[0-9]/, null, Lexer.l_datum, null], // block symbols
[/#/, null, /[0-9]/, null, Lexer.l_datum], [/=/, /[0-9]/, null, Lexer.l_datum, null], [/#/, /[0-9]/, null, Lexer.l_datum, null], // for dot comma `(a .,b)
[/\./, Lexer.boundary, /,/, null, null], // block symbols
[/\|/, null, null, null, Lexer.b_symbol], [/\s/, null, null, Lexer.b_symbol, Lexer.b_symbol], [/\|/, null, Lexer.boundary, Lexer.b_symbol, null]]; // ----------------------------------------------------------------------

Lexer._brackets = [[/[()[\]]/, null, null, null, null]]; // ----------------------------------------------------------------------
Expand Down Expand Up @@ -13411,15 +13413,15 @@
}
}

var arg = args.shift();

if (typeof arg === 'undefined') {
if (!args.length) {
if (result !== false) {
return result;
} else {
return false;
}
} else {
var arg = args.shift();

var value = _evaluate(arg, {
env: self,
dynamic_scope: dynamic_scope,
Expand Down Expand Up @@ -14215,7 +14217,7 @@
} // -------------------------------------------------------------------------


var compile = exec_collect(function (code, value) {
var compile = exec_collect(function (code) {
return code;
}); // -------------------------------------------------------------------------

Expand Down Expand Up @@ -14870,10 +14872,10 @@

var banner = function () {
// Rollup tree-shaking is removing the variable if it's normal string because
// obviously 'Fri, 20 Aug 2021 19:40:34 +0000' == '{{' + 'DATE}}'; can be removed
// obviously 'Fri, 20 Aug 2021 20:38:07 +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, 20 Aug 2021 19:40:34 +0000').valueOf();
var date = LString('Fri, 20 Aug 2021 20:38:07 +0000').valueOf();

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

Expand Down Expand Up @@ -14918,7 +14920,7 @@
var lips = {
version: 'DEV',
banner: banner,
date: 'Fri, 20 Aug 2021 19:40:34 +0000',
date: 'Fri, 20 Aug 2021 20:38:07 +0000',
exec: exec,
// unwrap async generator into Promise<Array>
parse: compose(uniterate_async, parse),
Expand Down
4 changes: 2 additions & 2 deletions dist/lips.min.js

Large diffs are not rendered by default.

10 changes: 7 additions & 3 deletions src/lips.js
Original file line number Diff line number Diff line change
Expand Up @@ -1268,6 +1268,7 @@
Lexer.b_comment = Symbol.for('b_comment');
Lexer.i_comment = Symbol.for('i_comment');
Lexer.l_datum = Symbol.for('l_datum');
Lexer.dot = Symbol.for('dot');
// ----------------------------------------------------------------------
Lexer.boundary = /^$|[\s()[\]]/;
// ----------------------------------------------------------------------
Expand Down Expand Up @@ -1320,6 +1321,9 @@
[/=/, /[0-9]/, null, Lexer.l_datum, null],
[/#/, /[0-9]/, null, Lexer.l_datum, null],

// for dot comma `(a .,b)
[/\./, Lexer.boundary, /,/, null, null],

// block symbols
[/\|/, null, null, null, Lexer.b_symbol],
[/\s/, null, null, Lexer.b_symbol, Lexer.b_symbol],
Expand Down Expand Up @@ -9244,14 +9248,14 @@
return loop();
}
}
var arg = args.shift();
if (typeof arg === 'undefined') {
if (!args.length) {
if (result !== false) {
return result;
} else {
return false;
}
} else {
var arg = args.shift();
var value = evaluate(arg, { env: self, dynamic_scope, error });
return unpromise(value, next);
}
Expand Down Expand Up @@ -9878,7 +9882,7 @@
}
}
// -------------------------------------------------------------------------
const compile = exec_collect(function(code, value) {
const compile = exec_collect(function(code) {
return code;
});
// -------------------------------------------------------------------------
Expand Down
5 changes: 5 additions & 0 deletions tests/core.scm
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,11 @@
(t.is '|\x3BB;| )
(t.is '|\x9;\x9;| '|\t\t|)))

(test "core: dot comma"
(lambda (t)
;; found in https://doc.scheme.org/surveys/DotComma/
(t.is (let ((b 312)) `(a .,b)) '(a . 312))))

(test "core: if"
(lambda (t)
(t.is (if (newline) 1 2) 1)
Expand Down

0 comments on commit 6636441

Please sign in to comment.