Skip to content
/ lips Public
forked from jcubic/lips

Scheme based powerful and modern lisp language in JavaScript

License

Notifications You must be signed in to change notification settings

precisely/lips

This branch is 2258 commits behind jcubic/lips:master.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

1206332 · Jul 20, 2020
Jul 20, 2020
Feb 29, 2020
Mar 21, 2020
Mar 21, 2020
Mar 21, 2020
Mar 21, 2020
Jul 20, 2020
May 21, 2019
May 21, 2019
May 11, 2018
Jan 8, 2019
Sep 15, 2018
Mar 21, 2020
Jan 6, 2019
Mar 21, 2020
Jul 20, 2020
Oct 8, 2018
May 11, 2018
Mar 9, 2018
Jul 16, 2020
Mar 21, 2020
May 25, 2019
Dec 1, 2019
Dec 1, 2019
Feb 25, 2018

Repository files navigation

LIPS - Scheme Based Powerful Lisp Language

npm travis Coverage Status

LIPS is powerfull and modern Lisp, based on Scheme written in JavaScript.

Demo

Key features

  • Full lisp macros, backquote and macroexpand,
  • Functions in lips are normal JavaScript functions,
  • You can invoke native JavaScript functions and methods from Lips,
  • Promises are treated as values they resolve to (so async code look like sync - like auto async/await),
  • Library agnostic - you can use it with any library,
  • Easy extension using JavaScript using Macros or functions,
  • RegExp-es are first class objects,
  • BigInt support, if your browser don't support them, you will need to use bn.js,
  • Almost everything is first class object including macros and functions,
  • Functions code introspection/manipulation at runtime give more power to the programmer,
  • Optional dynamic scope.

Installation

use npm

npm install @jcubic/lips

then include the file in script tag, You can grab the version from unpkg.com

https://unpkg.com/@jcubic/lips

or from rawgit

https://cdn.rawgit.com/jcubic/lips/devel/dist/lips.min.js

Usage

Simplest way is to include the lips code in script tag:

<script type="text/x-lips">
(let ((what "world")
      (greet "hello"))
   (display (concat "hello" " " what)))
</script>

or use src attribute:

<script type="text/x-lips" src="example.lips"></script>

Running programmatically:

var {exec} = require('@jcubic/lips'); // node
// or
var {exec} = lips; // browser

exec(string).then(function(results) {
     results.forEach(function(result) {
        console.log(result.toString());
     });
});

More documentation in Getting Started Guide and in docs page.

Standalone executable

if you install lips globally with:

npm install -g @jcubic/lips

you can run interpreter from terminal:

$ lips
LIPS Interpreter (Simple Scheme like Lisp)
Copyright (c) 2018-2019 Jakub T. Jankiewicz <https://jcubic.pl/me>

lips> (define (square x)
...     (* x x))
lips> (square 10)
100
lips>

One feature of LIPS REPL is that it auto indent the lines when you press enter and didn't finish the code.

You can also run code as string with:

lips -c '(let ((what "World")) (display (concat "Hello " what)))'

and you can run a file using:

cat > foo.lips <<EOF
(let ((what "World"))
  (display (concat "Hello " what)))
EOF

lips foo.lips

You can also write executable files that use lips shebang

cat > foo.lips <<EOF
#!/usr/bin/env lips
(let ((what "World"))
  (display (concat "Hello " what)))
EOF
chmod a+x foo.lips
foo.lips
cat <<EOF
something
EOF

if just example of using cat to create multiline file from bash, you should use proper editor for writing files.

License

Released under MIT license

Copyright (c) 2018-2019 Jakub T. Jankiewicz

About

Scheme based powerful and modern lisp language in JavaScript

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 93.3%
  • Scheme 3.4%
  • Makefile 1.7%
  • HTML 1.5%
  • Shell 0.1%