Skip to content

Commit

Permalink
merge with devel
Browse files Browse the repository at this point in the history
  • Loading branch information
jcubic committed Dec 13, 2020
2 parents a779fea + 8e844aa commit 1381bca
Show file tree
Hide file tree
Showing 70 changed files with 37,589 additions and 2,195 deletions.
3 changes: 2 additions & 1 deletion .babelrc
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"presets": [ "@babel/preset-env" ]
"presets": [ "@babel/preset-env" ],
"plugins": [ "@babel/plugin-proposal-unicode-property-regex", { "useUnicodeFlag": false } ]
}
4 changes: 3 additions & 1 deletion .gitignore
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ node_modules
coverage
.htaccess
npm-debug.log
error.log
\#*
.\#*
.DEV
.[0-9]*
www
_*
/_*
*/_*
.nyc_output
5 changes: 3 additions & 2 deletions .npmignore
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
spec
*~
coverage
docs
todo.html
*.lips
Makefile
Expand All @@ -12,7 +13,7 @@ rollup.config.js
\#*#
.*
src/banner.js
tests/
test.js*
tests
assets
examples
scripts
51 changes: 50 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,52 @@
## 1.0.0-beta.10
### Breaking
* change behavior of `and` and `or` to work like `if` (`#f` only falsy value)
* vectors and object literals are immutable (to prevent weird sharing data bugs)
### Features
* add `promise?` function
* improve `append`/`append!` to work according to spec and accept multiple arguments
* set `global` and `window` to undefined when not in Node or Window respectively
* add `self` as global context for Node, browser and worker
* add repr of global object
* add repr of classes
* add support for creating anonymous classes
* add `do-iterator` macro
* add repr of `Map` and `Set`
* add `digit-value` function
* add `#d` prefix for decimal numbers
* add `include` macro
* add `--debug` option to executable (that load src file instead of dist)
* add `cond-expand` syntax macro
* add new `native-symbol?` function
* add warning about using `` quote, with code example to execute to enable it
* add `__dirname` and `__filename` variables to Node
* add support for variables in method properties of classes (like in JS)
### Bugfix
* fix load file that have shebang
* fix repr of eof object
* fix read from input-string-port [#85](https://github.com/jcubic/lips/issues/85)
* fix running web worker from file generated by babel (dist)
* fix repr of lambda function (no `:lambda` as name)
* fix parse complex big num (e.g.: `100e+100i`)
* fix repr of scheme functions if Function.prototype.toString was modified
* fix repr of iterators
* fix access symbol properties of binded functions (LIPS internals)
* fix duplicated line in executable [#89](https://github.com/jcubic/lips/issues/89)
* fix `char-numeric?` and `char-alphabetic?` to handle all unicode
* fix characters with more then one code point
* fix `repr` of functions that are created by `self.eval`
* fix formatting strings in REPL
* fix `set!` `nil` to object field
* fix `lambda` in `define-class` that have improper list as arguments
* throw exception when applying function to improper list
* fix `join` with nil
* fix accessing JavaScript objects in syntax-rules macros
* fix write of strings with newline
* fix indent of `when` and `unless`
* fix usage of Drag&Drop with bookmarklet on pdf files
* fix accessing methods on pattern variables in syntax macros [#83](https://github.com/jcubic/lips/issues/83)
* fix quasiquote to work like quote if not unquotes (R7RS spec)

## 1.0.0-beta.9
### Breaking
* throw exception when calling `(-)`
Expand All @@ -6,7 +55,7 @@
* add `let-values`, `let*-values` and `define-values` syntax macros
* add `exact-integer?` and `vector-append` functions
* add `stderr` port and `current-error-port` function
* add environment as second argument to load (according to R7RS spec)
* add environment as second argument to `load` (according to R7RS spec)
### Bugfix
* fix empty vector literal
* fix edge case in nested syntax-rules when variable in parent got expanded into identifier
Expand Down
13 changes: 11 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
.PHONY: publish test coveralls lint
.PHONY: publish test coveralls lint zero

VERSION=1.0.0-beta.9
VERSION_DASH=`echo -n "1.0.0-beta.9" | sed "s/-/%E2%80%93/"`
BRANCH=`git branch | grep '^*' | sed 's/* //'`
DATE=`date -uR`
YEAR=`date +%Y`
DATE_SHORT=`date +%Y-%m-%d`
TESTS_CHECKSUM=`cat test.js tests/*.scm | md5sum spec/lips.spec.js | cut -d' ' -f 1`
TESTS_CHECKSUM=`cat tests/test.js tests/*.scm | md5sum | cut -d' ' -f 1`
COMMIT=`git rev-parse HEAD`
URL=`git config --get remote.origin.url`
UNICODE=https://unicode.org/Public/UNIDATA/UnicodeData.txt

MAKE=make
GIT=git
Expand All @@ -19,6 +20,8 @@ RM=rm
TEST=test
CAT=cat
NPM=npm
NODE=node
WGET=wget
ESLINT=./node_modules/.bin/eslint
COVERALLS=./node_modules/.bin/coveralls
JEST=./node_modules/.bin/jest
Expand Down Expand Up @@ -75,6 +78,12 @@ jest-test: dist/lips.js
test: dist/lips.js
@$(NPM) run test

zero:
@$(WGET) $(UNICODE) -O ./assets/UnicodeData.txt

unicode: assets/UnicodeData.txt
@$(NODE) ./scripts/numerals.js

watch-test:
@inotifywait -m -e close_write src/lips.js tests/*.scm | while read even; do $(MAKE) --no-print-directory test; done

Expand Down
76 changes: 48 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
![LIPS - Scheme Based Powerful Lisp Language](https://github.com/jcubic/lips/blob/master/assets/lips.svg?raw=true)
![LIPS - Scheme Based Powerful Lisp Language](https://github.com/jcubic/lips/blob/devel/assets/lips.svg?raw=true)

[![npm](https://img.shields.io/badge/npm-1.0.0%E2%80%93beta.9-blue.svg)](https://www.npmjs.com/package/@jcubic/lips)
[![travis](https://travis-ci.org/jcubic/lips.svg?branch=master&f3777575930af349115617b543f29306d3b20023)](https://travis-ci.org/jcubic/lips)
[![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=master&2c48907438a7265935a7b21e6931008d)](https://coveralls.io/github/jcubic/lips?branch=master)
![1.0.0 Complete](https://img.shields.io/github/milestones/progress-percent/jcubic/lips/1?label=1.0.0%20Complete)
[![travis](https://travis-ci.org/jcubic/lips.svg?branch=devel&943695f973b09669f49d7ddc5e9b04197dfd5657)](https://travis-ci.org/jcubic/lips)
[![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&4ad2a0cc51eda574815b5c09cef1fa86)](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)
[![GitHub stars](https://img.shields.io/github/stars/jcubic/lips.svg?style=social&label=Star&maxAge=2592000)](https://github.com/jcubic/lips/stargazers/)
<a href="https://twitter.com/intent/tweet?text=Powerful%20Scheme%20based%20lisp%20language%20written%20in%20JavaScript.%20It%20makes%20life%20easier%20by%20better%20interaction%20with%20JS.%20Use%20full%20power%20of%20JavaScript%2C%20lisp%20and%20npm%20to%20create%20your%20applications%20via%20@jcubic&url=https://github.com/jcubic/lips&hashtags=javascript,opensource,lisp,scheme,language,programming">
<img src="https://github.com/jcubic/lips/blob/master/assets/tweet-shield.svg?raw=true" alt="Tweet" height="20"/>
<img src="https://github.com/jcubic/lips/blob/devel/assets/tweet-shield.svg?raw=true" alt="Tweet" height="20"/>
</a>
![NPM Download Count](https://img.shields.io/npm/dm/@jcubic/lips)
![JSDelivr Download count](https://img.shields.io/jsdelivr/npm/hm/@jcubic/lips)

![Matomo trakcing piksel](https://piwik.jcubic.pl/matomo.php?idsite=7&rec=1&action_name=bookmark&url=https%3A%2F%2Fgit.luolix.top%2Fjcubic%2Flips)
[![LIPS at Product Hunt](https://api.producthunt.com/widgets/embed-image/v1/featured.svg?post_id=273619&theme=dark)](https://www.producthunt.com/posts/lips)

[LIPS is a powerful Scheme-based, Lisp language written in JavaScript](https://lips.js.org).
Expand Down Expand Up @@ -92,11 +98,10 @@ find a link that you can drag to your bookmarks.

## Usage


The simplest way is to include the lips code in the script tag:

```html
<script type="text/x-scheme">
<script type="text/x-scheme" bootstrap>
(let ((what "world")
(greet "hello"))
(display (string-append "hello" " " what)))
Expand All @@ -106,42 +111,57 @@ The simplest way is to include the lips code in the script tag:
or use the `src` attribute:

```html
<script type="text/x-scheme" src="example.scm"></script>
<script type="text/x-scheme" bootstrap src="example.scm"></script>
```

## Boostraping Scheme system

To have fully working Scheme environment, you need to bootstrap the language and load
all scheme code written in LIPS. To do that you can use this:
Big part of LIPS is written in LIPS itself, but to use full power of LIPS you need
to load those additional Scheme files. The easiest way is to add `bootstrap` attribute
on first script tag with `text/x-scheme` type. By default it will use CDN from
[jsdelivr](https://www.jsdelivr.com/). To load each file using builtin load function
(that will fetch the file using ajax and evaluate it).

Second option (before beta.10 it was the only option) you can bootstrap LIPS yourself.

You can call this Scheme code:

```
(let-env lips.env.__parent__
(load "./lib/bootstrap.scm")
(load "./lib/R5RS.scm")
(load "./lib/R7RS.scm"))
(let ((e lips.env.__parent__))
(load "./lib/bootstrap.scm" e)
(load "./lib/R5RS.scm" e)
(load "./lib/R7RS.scm" e))
```

you need to use path to lib files, you can host them yourself or use CDN.

```
(let-env lips.env.__parent__
(let ((path "https://cdn.jsdelivr.net/gh/jcubic/lips@devel/lib/"))
(load (concat path "bootstrap.scm"))
(load (concat path "R5RS.scm"))
(load (concat path "R7RS.scm"))))
(let ((e lips.env.__parent__)
(path "https://cdn.jsdelivr.net/gh/jcubic/lips@devel/lib/"))
(load (concat path "bootstrap.scm") e)
(load (concat path "R5RS.scm") e)
(load (concat path "R7RS.scm" e)))
```

The last option is to create one big file by concatenation of LIPS files and your own code:

```bash
cat ./node_modules/@jcubic/lips/lib/*.scm app.scm > all.scm
```

and load that in script tag:

```
<script src="all.scm" type="text/x-scheme"></script>
```

If you use server you will need to enable CORS if your website is on different domain,
because load will use AJAX to get the files.
This is not ideal because if your project have multiple files you will not be able to use
`load`.

**NOTE:** as of now there is not other solution, but it may change when version 1.0 is out.
Because the files use syntax extensions that modify the parser you can't combine those
files into one bigger file. Here is issue
[Make parser ES generator #80](https://github.com/jcubic/lips/issues/80)
that will make this possible. Other idea is to add `data-path=""` attribute on script tag
that will bootstrap the system from given path.
Solution may be to process the file like Webpack and create a one bundle, (replace load
calls with the code itself).

Running programmatically:
## Running LIPS programmatically

```javascript
var {exec} = require('@jcubic/lips'); // node
Expand Down Expand Up @@ -176,7 +196,7 @@ npm install -g @jcubic/lips

you can run the interpreter from the terminal:

![LIPS: Scheme interactive terminal](https://github.com/jcubic/lips/blob/master/assets/screencast.gif?raw=true)
![LIPS: Scheme interactive terminal](https://github.com/jcubic/lips/blob/devel/assets/screencast.gif?raw=true)


You can also run code in a string with:
Expand Down
Loading

0 comments on commit 1381bca

Please sign in to comment.