Skip to content

spy16/slurp

Repository files navigation

Slurp

GoDoc Go Report Card Code Change

Slurp is a highly customisable, embeddable LISP toolkit for Go applications.

Why Slurp

I've just received word that the Emperor has dissolved the MIT computer science program permanently.

Slurp is for developers who want to design and embed an interpreted language inside of a Go program.

Slurp provides composable building-blocks that make it easy to design a custom lisp, even if you've never written an interpreter before. Since Slurp is written in pure Go, your new language can be embedded into any Go program by importing it — just like any other library.

NOTE: Slurp is NOT an implementation of a particular LISP dialect.

It provides pieces that can be used to build a LISP dialect or can be used as a scripting layer.

Slurp is designed around three core values:

  1. Simplicity: The library is small and has few moving parts.
  2. Batteries Included: There are no external dependencies and little configuration required.
  3. Go Interoperability: Slurp can call Go code and fully supports Go's concurrency features.

We hope that you will find Slurp to be powerful, useful and fun to use. We look forward to seeing what you build with it!

Features

  • Highly customizable, safe and powerful reader/parser through a read table (Inspired by Clojure) (See Reader)
  • Immutable datatypes including: nil, bool, string, int & float, character, keyword, symbol, list, vector & map.
  • Multiple number formats supported: decimal, octal, hexadecimal, radix and scientific notations.
  • Full unicode support. Symbols, keywords etc. can include unicode characters (Example: find-δ, π etc.) and 🧠, 🏃 etc. (yes, smileys too).
  • Character Literals with support for:
    1. simple literals (e.g., \a for a)
    2. special literals (e.g., \newline, \tab etc.)
    3. unicode literals (e.g., \u00A5 for ¥ etc.)
  • Full interoperability with Go: call native Go functions/libraries, and manipulate native Go datatypes from your language.
  • Support for macros.
  • Easy to extend. See Wiki.
  • Tiny & powerful REPL package.
  • Zero dependencies (outside of tests).

Usage

Slurp requires Go 1.14 or higher. It can be installed using go get:

go get -u github.com/spy16/slurp

What can you use it for?

  1. Embedded script engine to provide dynamic behavior without requiring re-compilation of your application (example).
  2. Business rule engine exposing specific, composable rules (example).
  3. To build DSLs.
  4. To build your own LISP dialect (example).

Refer ./examples for more usage examples.

Documentation

In addition to the GoDocs, we maintain in-depth tutorials on the GitHub wiki. The following pages are good starting points:

  1. Getting Started
  2. Customizing Syntax
  3. Customizing Evaluation