Developer's Guide

Welcome to the Swalang Engine development guide. This resource explains how to configure, compile, test, and contribute to the core interpreter, standard library, and auxiliary tooling.

System Requirements

The Swalang parser and runtime are built using Go, while various performance-critical native extensions (such as SQLite, Mongoose, and SDL2) are cross-compiled using Zig.

  • Go Compiler: Version 1.23 or newer is required.
  • Zig Toolchain: Version 0.13.0 is recommended to drive cross-compilation of C/C++ dependencies without relying on complex system-specific C compilers.

Repository Structure

The project workspace is organized logically into core packages, dynamic extension targets, and compiler automation scripts:

cmd/interpreter/

Main entry point for the standard Swalang CLI and REPL shell.

internal/lexer/

Converts source code characters into parsed streams of structured tokens.

internal/parser/

Constructs the Abstract Syntax Tree (AST) from the token stream.

internal/interpreter/

Core runtime engine that walks the AST to evaluate expressions and statements.

Local Build & Compilation

Follow these steps to compile the Swalang binary and standard shared libraries for local development:

1. Clone the codebase

git clone https://github.com/deniskipeles/swalang-beta.git
cd swalang-beta

2. Compile Shared Libraries

This script will download the source files for extensions and compile them into platform-specific shared libraries under the bin/ folder.

./scripts/build-shared-libs.sh

3. Build the Core Interpreter

This script links all components, bundles the standard library, and generates the final executables inside the builds/ folder.

./scripts/build-interpreter.sh

Running Unit Tests

Verify the integrity of changes by executing the suite of unit tests. Tests cover lexing, AST generation, and runtime evaluation:

go test ./tests/...

Extending the Language

If you are proposing additions to Swalang's syntax (such as introducing new keywords or tokens), update the pipeline in the following sequence:

  1. Define Keywords: Register the text of your keyword inside the localization files located in internal/constants/lexer_en.go and lexer_sw.go.
  2. Map Tokens: Bind the constant value to a matching TokenType inside internal/lexer/token.go.
  3. Write Parser Logic: Open internal/parser/parser.go to define prefix or infix parsing operations so the compiler understands the keyword's position in the AST tree.

Ready to submit your changes?

Review your code formatting, make sure all tests pass, and submit a pull request on GitHub.