All Projects → objecthub → Swift Lispkit

objecthub / Swift Lispkit

Licence: apache-2.0
Interpreter framework for Lisp-based extension and scripting languages on macOS and iOS. LispKit is based on the R7RS standard for Scheme. Its compiler generates bytecode for a virtual machine. LispKit is fully implemented in Swift 5.

Programming Languages

swift
15916 projects
scheme
763 projects
lisp
113 projects

Projects that are alternatives of or similar to Swift Lispkit

Lioness
The Lioness Programming Language
Stars: ✭ 155 (-32.02%)
Mutual labels:  compiler, interpreter, virtual-machine
Openj9
Eclipse OpenJ9: A Java Virtual Machine for OpenJDK that's optimized for small footprint, fast start-up, and high throughput. Builds on Eclipse OMR (https://github.com/eclipse/omr) and combines with the Extensions for OpenJDK for OpenJ9 repo.
Stars: ✭ 2,802 (+1128.95%)
Mutual labels:  compiler, interpreter, virtual-machine
Quickjs
The official repo is at bellard/quickjs.
Stars: ✭ 1,429 (+526.75%)
Mutual labels:  compiler, interpreter, virtual-machine
V8
The official mirror of the V8 Git repository
Stars: ✭ 18,808 (+8149.12%)
Mutual labels:  compiler, interpreter, virtual-machine
Go.vm
A simple virtual machine - compiler & interpreter - written in golang
Stars: ✭ 178 (-21.93%)
Mutual labels:  compiler, interpreter, virtual-machine
Ph7
An Embedded Implementation of PHP (C Library)
Stars: ✭ 422 (+85.09%)
Mutual labels:  compiler, interpreter, virtual-machine
Umka Lang
Umka: a statically typed embeddable scripting language
Stars: ✭ 308 (+35.09%)
Mutual labels:  compiler, interpreter, virtual-machine
Cymbal
Yet another Rust implementation of the Monkey language from "Writing an Interpreter in Go" and "Writing a Compiler in Go"
Stars: ✭ 49 (-78.51%)
Mutual labels:  compiler, interpreter, virtual-machine
Cub
The Cub Programming Language
Stars: ✭ 198 (-13.16%)
Mutual labels:  compiler, interpreter, virtual-machine
Simple
The Simple Intelligent and Modular Programming Language and Environment
Stars: ✭ 120 (-47.37%)
Mutual labels:  interpreter, virtual-machine
Cperl
A perl5 with classes, types, compilable, company friendly, security
Stars: ✭ 125 (-45.18%)
Mutual labels:  compiler, interpreter
Kivm
🌟This is a pure C++ implementation of Java Virtual Machine (only Java 8 is supported). Inspired by Hotspot In Action.
Stars: ✭ 137 (-39.91%)
Mutual labels:  interpreter, virtual-machine
Brain
An esoteric programming language compiler on top of LLVM based on Brainfuck
Stars: ✭ 112 (-50.88%)
Mutual labels:  compiler, interpreter
Tinyscript
自制的一个编译器, 用于学习,完整实现了词法分析,语法分析,中间代码(SSA)生成,机器码生成,和基于寄存器的虚拟机
Stars: ✭ 132 (-42.11%)
Mutual labels:  compiler, virtual-machine
Libforth
libforth: A small Forth interpreter that can be used as a library written in c99
Stars: ✭ 107 (-53.07%)
Mutual labels:  interpreter, virtual-machine
Lawvere
A categorical programming language with effects
Stars: ✭ 142 (-37.72%)
Mutual labels:  compiler, interpreter
Forge
A lightweight, elegant scripting language with built-in Rust-FFI.
Stars: ✭ 153 (-32.89%)
Mutual labels:  compiler, interpreter
Fanx
A portable programming language
Stars: ✭ 101 (-55.7%)
Mutual labels:  compiler, virtual-machine
Emacs Cl
Common Lisp implemented in Emacs Lisp.
Stars: ✭ 140 (-38.6%)
Mutual labels:  compiler, interpreter
Quickjs
QuickJS是一个小型并且可嵌入的Javascript引擎,它支持ES2020规范,包括模块,异步生成器和代理器。
Stars: ✭ 2,199 (+864.47%)
Mutual labels:  compiler, virtual-machine

LispKit Swift LispKit

Platform: macOS | iOS Language: Swift 5.3 IDE: Xcode 12.4 Carthage: compatible License: Apache

Overview

LispKit is a framework for building Lisp-based extension and scripting languages for macOS and iOS applications. LispKit is fully written in the programming language Swift. LispKit implements a core language based on the R7RS (small) Scheme standard. It is extensible, allowing the inclusion of new native libraries written in Swift, of new libraries written in Scheme, as well as custom modifications of the core environment consisting of a compiler, a virtual machine as well as the core libraries.

So far, performance was not a priority in the development of LispKit. The LispKit compiler does not perform many code optimizations and the performance of the system is below state of the art Lisp and Scheme implementations.

The NumericalScheme demo showcases how to create a derived LispKit interpreter that inherits everything from LispKit (without code duplication) and defines a new native as well as Scheme-based library.

The iOS version of the LispKit framework is work in progress. All libraries except for (lispkit draw) are supported, but there are currently a few individual (system) procedures that require porting. The differences between the macOS and iOS version of the framework are minor, but require documentation. Interestingly, the iPhone 12 Pro seems to outperform the MacBook Pro 16" for simple benchmarks.

LispPad implements a simple, lightweight, integrated development environment for LispKit on macOS with a Cocoa-based UI. The LispPad Library Reference documents the core LispPad and LispKit libraries in PDF form. A simpler command-line tool with similar functionality is provided by the LispKit framework itself (see below).

Features

LispKit provides support for the following core features, many of which are based on R7RS:

LispKit is incompatible or incomplete with respect to the following R7RS features:

  • Lists are immutable. Mutable cons-cells are supported in a way similar to Racket
  • Literals in syntax-rules are not matched based on their definition but their symbol identity
  • Datum comments introduced via #; do not always work as in other Scheme dialects.

The following SRFI libraries have been ported to LispKit and are included in the framework:

Project

The project defines three different targets:

  • LispKit: the core interpreter framework, including all support files
  • LispKitTools: a framework for tools supporting LispKit; e.g. a read-eval-print framework
  • LispKitRepl: a command-line tool implementing a read-eval-print loop

Architecture

From an architectural perspective, LispKit consists of:

  1. a compiler translating LispKit expressions into bytecode,
  2. a virtual machine for interpreting the generated bytecode. The virtual machine is stack-based, handles tail calls and continuations, and provides a garbage collector.
  3. a large range of libraries, all packaged together with the framework.

Details can be found in the LispKit Wiki.

Command-line tool

Overview

This project also includes a command-line tool, called the LispKit Shell, for executing LispKit applications in the terminal. It can be used to try out and experiment with the LispKit framework. The command-line tool can also be used interactively as a read-eval-print loop. The read-eval-print loop parses the entered LispKit expression, compiles it to bytecode, executes it, and displays the result.

Downloading the source code

First, clone the LispKit repository via git. The following command will create a directory swift-lispkit.

> git clone https://github.com/objecthub/swift-lispkit.git
Cloning into 'swift-lispkit'...
remote: Enumerating objects: 14, done.
remote: Counting objects: 100% (14/14), done.
remote: Compressing objects: 100% (12/12), done.
remote: Total 5300 (delta 1), reused 14 (delta 1), pack-reused 5286
Receiving objects: 100% (5300/5300), 1.76 MiB | 132.00 KiB/s, done.
Resolving deltas: 100% (3724/3724), done.

Next, switch to Xcode and build the LispKit command-line tool via scheme LispKitRepl:

> open LispKit.xcodeproj

Compiling the command-line tool with the Swift Package Manager

A debug binary can be built in the following way:

> cd swift-lispkit
> swift build -Xswiftc "-D" -Xswiftc "SPM"
Fetching https://github.com/objecthub/swift-numberkit.git
Fetching https://github.com/objecthub/swift-commandlinekit.git
Fetching https://github.com/objecthub/swift-markdownkit.git
Completed resolution in 6.47s
Cloning https://github.com/objecthub/swift-numberkit.git
Resolving https://github.com/objecthub/swift-numberkit.git at 2.3.2
Cloning https://github.com/objecthub/swift-markdownkit.git
Resolving https://github.com/objecthub/swift-markdownkit.git at 0.2.0
Cloning https://github.com/objecthub/swift-commandlinekit.git
Resolving https://github.com/objecthub/swift-commandlinekit.git at 0.3.1
[124/124] Linking LispKitRepl

The debug binary can be run by invoking .build/debug/LispKitRepl -d LispKit assuming that directory ~/Documents/LispKit contains a copy of the resources directory needed to run the command-line tool.

A release binary can be built like this:

> cd swift-lispkit
> swift build -c release -Xswiftc "-D" -Xswiftc "SPM"
Fetching https://github.com/objecthub/swift-numberkit.git
Fetching https://github.com/objecthub/swift-commandlinekit.git
Fetching https://github.com/objecthub/swift-markdownkit.git
Completed resolution in 4.02s
Cloning https://github.com/objecthub/swift-numberkit.git
Resolving https://github.com/objecthub/swift-numberkit.git at 2.3.2
Cloning https://github.com/objecthub/swift-markdownkit.git
Resolving https://github.com/objecthub/swift-markdownkit.git at 0.2.0
Cloning https://github.com/objecthub/swift-commandlinekit.git
Resolving https://github.com/objecthub/swift-commandlinekit.git at 0.3.1
[6/6] Linking LispKitRepl

The release binary can be run by invoking .build/release/LispKitRepl -r Sources/LispKit/Resources in the directory swift-lispkit (in which the binary was build above).

Assuming that directory ~/Documents/LispKit contains a copy of the resources directory, it is also possible to run the release binary by invoking .build/release/LispKitRepl -d LispKit.

Requirements

The following technologies are needed to build the components of the LispKit framework. For building the command-line tool, all that is needed is the Swift Package Manager. For compiling the framework and trying the command-line tool directly in Xcode, the Swift Package Manager is not needed.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].