Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tekknolagi/scrapscript
A functional, content-addressable programming language.
https://github.com/tekknolagi/scrapscript
compiler cosmopolitan functional-programing functional-programming interpreter wasm
Last synced: 12 days ago
JSON representation
A functional, content-addressable programming language.
- Host: GitHub
- URL: https://github.com/tekknolagi/scrapscript
- Owner: tekknolagi
- License: other
- Created: 2023-11-16T02:57:40.000Z (12 months ago)
- Default Branch: trunk
- Last Pushed: 2024-10-23T20:40:24.000Z (19 days ago)
- Last Synced: 2024-10-26T07:21:42.090Z (17 days ago)
- Topics: compiler, cosmopolitan, functional-programing, functional-programming, interpreter, wasm
- Language: Python
- Homepage: https://scrapscript.fly.dev/repl
- Size: 856 KB
- Stars: 373
- Watchers: 6
- Forks: 10
- Open Issues: 49
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Scrapscript Interpreter
See [scrapscript.org](https://scrapscript.org/) for some more information. Keep
in mind that the syntax on the website will change a little bit in the coming
weeks to match this repository.Take a look inside [scrapscript.py](scrapscript.py) and all of its tests to get
an idea for how the language works.## Usage
We support python3.8+.
```bash
# With a file
python3 scrapscript.py eval examples/0_home/factorial.scrap# With a string literal
python3 scrapscript.py apply "1 + 2"# With a REPL
python3 scrapscript.py repl
```or with [Cosmopolitan](https://justine.lol/cosmopolitan/index.html):
```bash
./build-com# With a file
./scrapscript.com eval examples/0_home/factorial.scrap# With a string literal
./scrapscript.com apply "1 + 2"# With a REPL
./scrapscript.com repl
```(if you have an exec format error and use Zsh, either upgrade Zsh or prefix
with `sh`)or with Docker:
```bash
# With a file (mount your local directory)
docker run --mount type=bind,source="$(pwd)",target=/mnt -i -t ghcr.io/tekknolagi/scrapscript:trunk eval /mnt/examples/0_home/factorial.scrap# With a string literal
docker run -i -t ghcr.io/tekknolagi/scrapscript:trunk apply "1 + 2"# With a REPL
docker run -i -t ghcr.io/tekknolagi/scrapscript:trunk repl
```### The experimental compiler:
#### Normal ELF
```bash
./scrapscript.py compile some.scrap # produces output.c
./scrapscript.py compile some.scrap --compile # produces a.out
```#### Cosmopolitan
```bash
CC=~/Downloads/cosmos/bin/cosmocc ./scrapscript.py compile some.scrap --compile # produces a.out
```#### Wasm
```bash
CC=/opt/wasi-sdk/bin/clang \
CFLAGS=-D_WASI_EMULATED_MMAN \
LDFLAGS=-lwasi-emulated-mman \
./scrapscript.py compile some.scrap --compile # produces a.out
```## Running Tests
```bash
python3 scrapscript.py test
```