Sigil, the programming language https://github.com/rdenadai/sigil
  • Python 95.8%
  • C 4.2%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-10-06 20:07:18 +00:00
.forgejo/workflows ci(workflows): skip test job on docs-only changes 2026-09-23 14:28:06 -03:00
.vscode feat: Sigil Lexer v0.0.1 2025-09-17 22:11:14 -03:00
bin chore(tools): add bin/sigilc wrapper for the compiler CLI 2026-09-21 17:41:34 -03:00
docs feat(parser): implement ordered comparison chains 2026-10-06 16:47:26 -03:00
src feat(parser): implement ordered comparison chains 2026-10-06 16:47:26 -03:00
static docs: Readme improvements 2025-09-20 00:47:02 -03:00
stdlib docs: Update Sigil grammar and examples 2026-09-04 11:57:10 -03:00
tests feat(parser): implement ordered comparison chains 2026-10-06 16:47:26 -03:00
.gitignore chore: ignore local worktree notes 2026-09-16 12:03:23 -03:00
AGENTS.md docs: consolidate SEP index 2026-09-23 17:10:12 -03:00
conftest.py test: Add CLI and performance test suites 2026-09-04 18:27:39 -03:00
LICENSE Initial commit 2025-09-16 09:44:01 -03:00
pyproject.toml test: add native compiler end-to-end coverage 2026-09-13 07:53:59 -03:00
README.md docs: consolidate SEP index 2026-09-23 17:10:12 -03:00
uv.lock lexer+parser: tokenize bare _ as PLACEHOLDER and accept it at identifier sites (§11.1 Option A) 2026-09-06 18:29:43 -03:00

Sigil

Sigil programming language logo

A modern programming language.


Warning

Sigil is a work in progress and is not yet stable. It is under active development, and breaking changes are expected.

Language Documentation

The user-facing reference is organized by feature complexity in docs/lang/. Runnable examples live in docs/examples/; future, partial, reserved, and rejected features live in docs/proposals/, indexed in the proposal index.

Requirements

To build and run Sigil, you need the following dependencies installed on your system:

  • Python 3.13+: Can be installed using pyenv or asdf.
  • uv: A fast Python package installer from Astral.
  • LLVM: The compiler infrastructure.
  • C compiler: cc on Linux/BSD, clang on macOS, or cl.exe on Windows.

Architecture

The Sigil compiler is built with a modular architecture, following a classic multi-stage compilation pipeline. The entire frontend is written in Python.

+------------------------------------------+
|      Frontend (Python)                   |
+------------------------------------------+
|                                          |
|      Source Code (.sl)                   |
|           |                              |
|           v                              |
|         Lexer --(Tokens)-->              |
|           |                              |
|           v                              |
|         Parser --(AST)-->                |
|           |                              |
|           v                              |
|   Semantic Analyzer --(Validated AST)--> |
|           |                              |
|           v                              |
|     Code Generator                       |
|           | (LLVM IR)                    |
|           v                              |
+------------------------------------------+
              |
              v
+------------------------------------------+
|    Backend (LLVM Toolchain)              |
+------------------------------------------+
|                                          |
|       LLVM IR (.ll)                      |
|           |                              |
|     +-----+------+                       |
|     |            |                       |
|     v            v                       |
| opt (Optional)   llc                     |
|     |            ^                       |
| (Optimized IR)   |                       |
|     |            |                       |
|     +------>-----+                       |
|                  | (Object File .o)      |
|                  v                       |
|                 gcc                      |
|                  | (Executable)          |
|                  v                       |
|             Executable                   |
|                                          |
+------------------------------------------+
  1. Lexical Analysis (Lexer): The source code is first processed by the lexer, which scans the text and converts it into a stream of tokens. This stage handles indentation, comments, and the basic elements of the language like keywords, identifiers, and operators.

  2. Syntactic Analysis (Parser): The parser takes the stream of tokens and constructs an Abstract Syntax Tree (AST). This tree represents the hierarchical structure of the code and validates it against the language's grammar.

  3. Semantic Analysis (Analyzer): The semantic analyzer traverses the AST to check for semantic correctness. It builds a symbol table to track variables, functions, and types, ensuring that the code is logically sound (e.g., type checking, scope resolution).

  4. Code Generation (CodeGenerator): After analysis, the code generator walks the AST and translates it into LLVM Intermediate Representation (IR).

  5. Backend Compilation: The generated LLVM IR is then passed to the LLVM toolchain:

    • opt: An optional step to optimize the LLVM IR.
    • llc: Compiles the IR into a native object file (.o).
    • C compiler: Links the object file to produce a final executable.

How to Run

Use the bin/sigilc wrapper, or uv run python -m src.main directly. Examples live in docs/examples/; build artifacts land in build/. Paths in the CLI are resolved relative to the repo root, so the same command works from any subdir.

Compile:

bin/sigilc docs/examples/01-basics/02-variables.sl

Compile and run:

bin/sigilc docs/examples/01-basics/02-variables.sl --run

Compile with optimizations:

To enable LLVM optimizations at the -O3 level, use the --optimize flag. This flag is experimental and currently only effective once code generation produces real LLVM IR; other optimization levels are not available. --optm is kept as a temporary alias.

bin/sigilc docs/examples/01-basics/02-variables.sl --optimize --run

Stop after semantic analysis (no codegen, no build artifacts):

bin/sigilc <file.sl> --check

JSON diagnostics on stdout (used by the VS Code extension on every keystroke):

bin/sigilc <file.sl> --check --format=json