this repo has no description
1# Scrapscript Interpreter
2
3See [scrapscript.org](https://scrapscript.org/) for some more information. Keep
4in mind that the syntax on the website will change a little bit in the coming
5weeks to match this repository.
6
7Take a look inside [scrapscript.py](scrapscript.py) and all of its tests to get
8an idea for how the language works.
9
10## Usage
11
12We support python3.8+.
13
14```bash
15# With a file
16python3 scrapscript.py eval examples/0_home/factorial.scrap
17
18# With a string literal
19python3 scrapscript.py apply "1 + 2"
20
21# With a REPL
22python3 scrapscript.py repl
23```
24
25or with [Cosmopolitan](https://justine.lol/cosmopolitan/index.html):
26
27```bash
28./util/build-com
29
30# With a file
31./scrapscript.com eval examples/0_home/factorial.scrap
32
33# With a string literal
34./scrapscript.com apply "1 + 2"
35
36# With a REPL
37./scrapscript.com repl
38```
39
40(if you have an exec format error and use Zsh, either upgrade Zsh or prefix
41with `sh`)
42
43or with Docker:
44
45```bash
46# With a file (mount your local directory)
47docker run --mount type=bind,source="$(pwd)",target=/mnt -i -t ghcr.io/tekknolagi/scrapscript:trunk eval /mnt/examples/0_home/factorial.scrap
48
49# With a string literal
50docker run -i -t ghcr.io/tekknolagi/scrapscript:trunk apply "1 + 2"
51
52# With a REPL
53docker run -i -t ghcr.io/tekknolagi/scrapscript:trunk repl
54```
55
56### The experimental compiler:
57
58#### Normal ELF
59
60```bash
61./scrapscript.py compile some.scrap # produces output.c
62./scrapscript.py compile some.scrap --compile # produces a.out
63```
64
65#### Cosmopolitan
66
67```bash
68CC=~/Downloads/cosmos/bin/cosmocc ./scrapscript.py compile some.scrap --compile # produces a.out
69```
70
71#### Wasm
72
73```bash
74CC=/opt/wasi-sdk/bin/clang \
75CFLAGS=-D_WASI_EMULATED_MMAN \
76LDFLAGS=-lwasi-emulated-mman \
77./scrapscript.py compile some.scrap --compile # produces a.out
78```
79
80## Development Workflow
81
82### Running Tests
83
84```bash
85python scrapscript_tests.py
86```
87
88### Type Checking the Python Sources
89```bash
90mypy --strict scrapscript.py
91```
92
93### Formatting the Python Sources
94```bash
95ruff format scrapscript.py
96```
97
98### Checking for Format Errors
99```bash
100ruff check scrapscript.py
101```
102
103### Using `uv`
104If you choose to use `uv` to manage development dependencies, you can run any of the previous four commands by prefixing them with `uv run`, e.g.:
105
106```bash
107uv run python scrapscript_tests.py
108```