@jcubic/lips

0.20.3 • Public • Published

LIPS - Scheme Based Powerful Lisp Language

npm travis Coverage Status

LIPS is a powerful Scheme-based, Lisp language written in JavaScript.

The name is a recursive acronym which stands for LIPS Is Pretty Simple.

Demo

Demo

1.0 Beta 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

Package Sidebar

Install

npm i @jcubic/lips

Weekly Downloads

17

Version

0.20.3

License

MIT

Unpacked Size

496 kB

Total Files

8

Last publish

Collaborators

  • jcubic