0.20.3 • Published 1 year ago

@jcubic/lips v0.20.3

Weekly downloads
26
License
MIT
Repository
github
Last release
1 year ago

LIPS - Scheme Based Powerful Lisp Language

npm travis Coverage Status Join Gitter Chat

LIPS is Powerful Lisp based language. It's based on Scheme dialect and R5RS specification (and part on R7RS), it have extensions that make it easier to interact with JavaScript, it work in Browser and Node.js.

Demo

Devel Beta demo

Features

  • Almost fully Compatible with R5RS,
  • Lisp macros, backquote and macroexpand,
  • Scheme Hygienic Macros with sytnax-rules,
  • Parser Syntax extensions and string representation,
  • RegExp-es are first class objects,
  • 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 JavaScript library,
  • Almost no dependencies (only bn.js for big integers),
  • Easy extension using JavaScript using Macros or functions,
  • Builtin pretty printer,
  • JavaScript object literals with &(:foo 10) (created using parser extensions),
  • Builtin help system like in Emacs Lisp,
  • You can access __doc__ and __code__ of any defined functions,
  • You can access and modify function code while function is running,
  • BigInt support, if your browser don't support them, you will need to use bn.js,
  • Almost everything is first class object including macros, functions and environments,
  • Functions code introspection/manipulation at runtime, give more power to the programmer,
  • Optional dynamic scope (can be used to build Emacs Lisp interpreter on top of LIPS).

Installation

To install you can use use npm (or yarn):

npm install @jcubic/lips

or yarn:

yarn add @jcubic/lips

To install 1.0.0 beta version use:

npm install @jcubic/lips@beta

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-scheme">
(let ((what "world")
      (greet "hello"))
   (display (string-append "hello" " " what)))
</script>

or use src attribute:

<script type="text/x-scheme" 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 Scheme Interpreter 1.0.0-beta.1 (2020-08-14)
Copyright (c) 2018-2020 Jakub T. Jankiewicz <https://jcubic.pl/me>

Type (env) to see environment with functions macros and variables.
You can also use (help name) to display help for specic function or macro.

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 (string-append "Hello " what)))'

and you can run a file using:

cat > foo.scm <<EOF
(let ((what "World"))
  (display (string-append "Hello " what))
  (newline))
EOF

lips foo.scm

You can also write executable files that use lips using shebang (SRFI-22)

cat foo.scm
#!/usr/bin/env lips

(let ((what "World"))
  (display (string-append "Hello " what))
  (newline))

chmod a+x foo.scm
./foo.scm

Executable also return S-Expression according to SRFI-176 use lips --version or lips -V.

Name

The name LIPS is recursive acronym which expand into LIPS Is Pretty Simple. This name was used because first version was very simple implementation. It's not that simple anymore, but still it should be pretty easy to modify. Note that some parts of the code may be more complex.

License

Released under MIT license

Copyright (c) 2018-2020 Jakub T. Jankiewicz

1.0.0-beta.19

1 year ago

1.0.0-beta.18.1

1 year ago

1.0.0-beta.18

1 year ago

1.0.0-beta.17.3

2 years ago

1.0.0-beta.17

2 years ago

1.0.0-beta.17.2

2 years ago

1.0.0-beta.17.1

2 years ago

1.0.0-beta.16

4 years ago

1.0.0-beta.15

4 years ago

1.0.0-beta.14

4 years ago

0.20.3

4 years ago

0.20.2

4 years ago

1.0.0-beta.12

4 years ago

1.0.0-beta.11

4 years ago

1.0.0-beta.10

5 years ago

1.0.0-beta.9

5 years ago

1.0.0-beta.8

5 years ago

1.0.0-beta.7

5 years ago

1.0.0-beta.6

5 years ago

1.0.0-beta.5

5 years ago

1.0.0-beta.4

5 years ago

1.0.0-beta.2

5 years ago

1.0.0-beta.3

5 years ago

1.0.0-beta.1

5 years ago

0.20.1

5 years ago

0.20.0

5 years ago

0.19.0

5 years ago

0.18.2

5 years ago

0.18.1

5 years ago

0.18.0

6 years ago

0.17.2

6 years ago

0.16.3

6 years ago

0.17.0

6 years ago

0.17.1

6 years ago

0.16.2

6 years ago

0.16.1

6 years ago

0.16.0

6 years ago

0.15.4

6 years ago

0.15.3

6 years ago

0.15.2

6 years ago

0.15.1

6 years ago

0.15.0

6 years ago

0.14.0

6 years ago

0.12.0

6 years ago

0.11.2

6 years ago

0.11.1

6 years ago

0.11.0

6 years ago

0.10.4

6 years ago

0.10.3

6 years ago

0.10.2

6 years ago

0.10.1

6 years ago

0.10.0

6 years ago

0.9.1

6 years ago

0.9.0

6 years ago

0.8.1

7 years ago

0.8.0

7 years ago

0.7.1

7 years ago

0.7.0

7 years ago

0.6.2

7 years ago

0.6.1

7 years ago

0.6.0

7 years ago

0.5.4

7 years ago

0.5.3

7 years ago

0.5.2

7 years ago

0.5.1

7 years ago

0.5.0

7 years ago

0.4.2

7 years ago

0.4.1

7 years ago

0.4.0

7 years ago

0.3.0

7 years ago

0.2.2

7 years ago

0.2.1

7 years ago

0.2.0

7 years ago

0.1.0

7 years ago