@jcubic/lips v0.20.3
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.
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 year ago
1 year ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago