https://github.com/phantomydn/jlll
Java Lisp Like Language
https://github.com/phantomydn/jlll
Last synced: 6 months ago
JSON representation
Java Lisp Like Language
- Host: GitHub
- URL: https://github.com/phantomydn/jlll
- Owner: PhantomYdn
- License: apache-2.0
- Created: 2014-03-06T20:51:45.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2019-03-24T21:30:34.000Z (over 7 years ago)
- Last Synced: 2025-08-14T15:50:00.070Z (12 months ago)
- Language: Java
- Size: 57.6 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
```
___ _ _ _
|_ | | | | | |
| | | | | | |
| | | | | | |
/\__/ / |___| |___| |____
\____/|_____|_____|______|
```
# JLLL - Java Lisp Like Language
[](https://github.com/PhantomYdn/jlll/actions/workflows/ci.yml)
[](https://codecov.io/gh/PhantomYdn/jlll)
[](https://central.sonatype.com/artifact/ru.ydn/jlll)
[](https://openjdk.org/)
[](LICENSE)
**Lightweight, embeddable Lisp interpreter for Java.** Add scripting, DSLs, or a REPL to your project in minutes.
---
## Features
- **Lightweight** - Minimal core library for embedding in your projects
- **Full Java Interop** - Call any Java method, access fields, create objects
- **Embeddable** - Evaluate Lisp from Java with a single line of code
- **Extensible** - Add custom primitives with simple annotations
- **Rich CLI** - Interactive REPL with line editing, history, tab completion, and syntax highlighting
- **Keyword Arguments** - Optional parameters with defaults: `(define (f (x 10)) ...)`
- **Metadata** - Attach documentation and metadata to bindings: `(define x :doc "desc" 42)`
- **Built-in Libraries** - Math, List, String, SQL, and more
## Documentation
See the [docs/](docs/) folder for comprehensive language documentation:
- [Overview & Quick Start](docs/README.md)
- [Syntax](docs/syntax.md) - Atoms, lists, keywords, reader macros
- [Special Forms](docs/special-forms.md) - define, if, lambda, let, cond
- [Procedures](docs/procedures.md) - Keyword arguments, defaults, rest args
- [Metadata](docs/metadata.md) - Documentation and metadata on bindings
- [Primitives](docs/primitives.md) - Built-in functions by library
- [Macros](docs/macros.md) - Macro definition and expansion
- [Java Interop](docs/java-interop.md) - Calling Java from JLLL
---
## Quick Start
### Java API
```java
import ru.ydn.jlll.common.Jlll;
// Evaluate Lisp expressions
Object result = Jlll.eval("(+ 2 2)");
System.out.println(result); // 4
// Define and call functions
Jlll.eval("(define (square x) (* x x))");
Object squared = Jlll.eval("(square 5)");
System.out.println(squared); // 25
```
### Command-Line Interface
Build and run the interactive interpreter:
```bash
mvn package
java -jar target/jlll-*-cli.jar
```
CLI options:
```bash
java -jar jlll-*-cli.jar --help # Show help
java -jar jlll-*-cli.jar --version # Show version
java -jar jlll-*-cli.jar -e '(+ 1 2 3)' # Evaluate expression
java -jar jlll-*-cli.jar script.jlll # Run script file
java -jar jlll-*-cli.jar # Start interactive REPL
```
REPL features:
- **Line editing** - Arrow keys, history navigation (Up/Down), search (Ctrl+R)
- **Tab completion** - Complete symbols, primitives, keywords
- **Multi-line input** - Automatic continuation for unbalanced parentheses
- **Syntax highlighting** - Colorized keywords, strings, numbers
Example session:
```
jlll> (define (factorial n)
....> (if (<= n 1)
....> 1
....> (* n (factorial (- n 1)))))
jlll> (factorial 10)
3628800
jlll> (invoke "hello world" 'toUpperCase)
HELLO WORLD
```
---
## Installation
### Maven
```xml
ru.ydn
jlll
2.0.0
```
### Gradle
```groovy
implementation 'ru.ydn:jlll:2.0.0'
```
---
## Examples
### Basic Operations
```lisp
(+ 2 2) ; => 4
(cons 'a 'b) ; => (a . b)
(append '(a b) '(c d)) ; => (a b c d)
```
### Functions
```lisp
(define (inc x) (+ x 1))
(inc 2) ; => 3
(lambda (x y) (+ x y)) ; anonymous function
((lambda (x) (* x x)) 4) ; => 16
```
### Java Interop
```lisp
; Call static methods
(invoke-static 'java.lang.Math 'cos 0.0) ; => 1.0
(invoke-static 'java.lang.Math 'max 10 20) ; => 20
; Call instance methods
(invoke "hello" 'length) ; => 5
(invoke "hello" 'substring 1 3) ; => "el"
; Create objects
(new 'java.util.ArrayList)
```
---
## License
[Apache License 2.0](LICENSE)