Skip to content

spawnlang/spawn

Repository files navigation

Spawn logo

Spawn Compiler & Toolchain

Installing Spawn from source

git clone https://github.com/spawnlang/spawn
cd spawn
make build     # or make release for fastest build
make build-fmt # optional, to install formatter

Add SPAWN_ROOT environment variable to your shell profile:

echo "export SPAWN_ROOT=$(pwd)" >> ~/.bashrc
source ~/.bashrc

To use spawnc executable anywhere, run:

sudo ./spawnc --symlink

On Unix systems, it creates a /usr/local/bin/spawnc symlink to compiler executable.

Build other tools:

make build-fmt

To build spawnprof see spawnprof repository

Editor/IDE support

JetBrains IDEs (Clion, IntelliJ IDEA, etc.)

Currently, the best support is provided in the IntelliJ IDEA family of IDEs with the Spawn plugin. It provides syntax highlighting, code completion, error highlighting, and more.

To install the plugin, go to Plugin Repository and follow instruction about manual installation.

VS Code

VS Code extension provides only syntax highlighting at the moment.

To install an extension, go to Extension Releases on GitHub. Download .vsix file, open VS Code, press Ctrl+Shift+P, type Install from VSIX, and select downloaded file. After restarting VS Code, you should see syntax highlighting for Spawn files.

You can try to install an experimental LSP server for Spawn. It is quite unstable and not recommended for use. To install it, run the following commands:

git clone https://github.com/spawnlang/spawn-analyzer
cd spawn-analyzer
spawnc . -o spawn-analyzer

Then in VS Code set the following settings:

{
    "spawn.serverPath": "/path/to/spawn-analyzer",
    "spawn.connectionMode": "tcp",
    "spawn.tcpMode.port": 5010
}

And reload VS Code.

Vim

Vim plugin provides only syntax highlighting at the moment.

To install a plugin, go to Plugin Repository and follow instruction about installation.

Editors with tree-sitter support (Zed, Neovim, etc.)

Spawn has a tree-sitter grammar that can be used in editors that support tree-sitter. To use it, go to tree-sitter-spawn repository to download the grammar. Then follow the instructions in your editor's documentation to install the grammar.

Tests

v install srackham.pcre2

// linux
apt install libpcre2-dev

// macos
brew install pcre2
make build-tester
./bin/tester

See TESTS.md for more details.

Usage

spawnc file.sp             # only compile
spawnc --run file.sp       # compile and run
spawnc -g file.sp          # compile with debug info
spawnc --opt file.sp       # compile with optimization and safety features
spawnc --opt-fast file.sp  # compile with optimization and no safety features

spawnc --test file_test.sp # compile and run test
spawnc --test ./           # compile and run test from directory

spawnc --profile cpu.prof file.sp     # profile cpu
spawnc --mem-profile mem.prof file.sp # profile memory

spawnprof cpu.prof                # show cpu profile as list
spawnprof cpu.prof --web          # open cpu profile graph in browser
spawnprof cpu.prof --graph g.svg  # save cpu profile graph as svg

./cmd/sfmt -w file.sp           # format file

Docker

This repository contains two Dockerfiles:

  • Dockerfile.v is used to create an image with optimized V compiler. This Dockerfile has nothing to do with Spawn, but it was placed here for organizational purposes. You don't need to use it at all (except for development). You can build V image with a command sudo docker build -t spawnlang/spawn -f Dockerfile.v ..
  • Dockerfile is used to create and image of optimized Spawn compiler + optimized tools (fmt, prof, pkg). This image also contains a GCC compiler. This image depends on the previously mentioned V image. You can build Spawn image with a command sudo docker build -t spawnlang/spawn -f Dockerfile ..

You can also access these and other Docker images on Spawn's DockerHub.

License

Spawn is licensed under the MIT license. See LICENSE for the full license text.

About

The Spawn programming language

Resources

License

Stars

Watchers

Forks

Contributors