Skip to content

RealOrko/sindarin

Repository files navigation

Sindarin (Sn) Programming Language

THIS PROJECT HAS MOVED TO: https://github.com/SindarinSDK/sindarin-compiler/blob/main/README.md

Sindarin is a statically-typed procedural programming language that compiles to C. It features clean arrow-based syntax, powerful string interpolation, and built-in array operations.

.sn source → Sn Compiler → C code → GCC/Clang → executable

Features

  • Static typing with explicit type annotations
  • Arrow syntax (=>) for clean, readable code blocks
  • String interpolation with $"Hello {name}!"
  • Arrays with built-in operations (push, pop, slice, join, etc.)
  • Structs for structured data and C library interop
  • String methods (toUpper, toLower, trim, split, splitLines, isBlank, etc.)
  • File I/O with TextFile and BinaryFile types
  • Control flow with for, for-each, while, break, continue
  • Module imports for code organization
  • Arena memory with shared/private scopes and copy semantics
  • C interoperability with native functions, pointers, and callbacks
  • SDK modules for compression, math, and more

Installation

Linux (Debian/Ubuntu)

# Download the .deb package from the latest release
sudo dpkg -i sindarin_*.deb

# Dependencies (gcc, zlib) are installed automatically
sn --version

Linux (Fedora/RHEL)

# Download the .rpm package from the latest release
sudo rpm -i sindarin-*.rpm

sn --version

Linux (Arch)

# Download PKGBUILD from the release
curl -LO https://github.com/RealOrko/sindarin/releases/latest/download/PKGBUILD

# Build and install
makepkg -si

macOS (Homebrew)

# Download the formula from the release
curl -LO https://github.com/RealOrko/sindarin/releases/latest/download/sindarin.rb

# Install (will prompt for Xcode CLT if needed)
brew install --formula ./sindarin.rb

Linux/macOS (Tarball)

# Download and extract
tar xzf sindarin-*-linux-x64.tar.gz   # or macos-x64
cd sindarin-*/

# Add to PATH or copy to /usr/local
export PATH="$PWD/bin:$PATH"
sn --version

Windows

Option 1: Winget (local manifest)

# Download winget-manifests.zip from the release
Expand-Archive winget-manifests.zip -DestinationPath winget-manifests
winget install --manifest ./winget-manifests

Option 2: Manual installation

# Download and extract the ZIP
Expand-Archive sindarin-*-windows-x64.zip -DestinationPath C:\sindarin

# Add to PATH
$env:PATH += ";C:\sindarin\bin"
sn --version

Prerequisite for Windows: LLVM-MinGW is required (provides clang).

Build from Source

# Prerequisites: CMake, Ninja, GCC or Clang, zlib

cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release
cmake --build build

bin/sn --version

See docs/building.md for detailed build instructions.

Quick Start

# Compile a program
sn samples/main.sn -o myprogram
./myprogram

# Or emit C code only
sn samples/main.sn --emit-c -o output.c

Example

fn is_prime(n: int): bool =>
  if n <= 1 =>
    return false
  var i: int = 2
  while i * i <= n =>
    if n % i == 0 =>
      return false
    i = i + 1
  return true

fn main(): void =>
  var primes: int[] = {}
  for var n: int = 2; n <= 50; n++ =>
    if is_prime(n) =>
      primes.push(n)
  print($"Primes: {primes.join(\", \")}\n")

Documentation

Language

Document Description
Overview Language philosophy, syntax overview, examples
Building Build instructions for Linux, macOS, Windows
Strings String methods and interpolation
Arrays Array operations and slicing
Structs Struct declarations and C interop
Lambdas Lambda expressions and closures
Memory Arena memory management
Threading Threading with spawn and sync
Namespaces Namespaced imports for collision resolution
Interop C interoperability and native functions
Interceptors Function interception for debugging and mocking

SDK Modules

Document Description
SDK Overview All SDK modules
Date Calendar date operations
Time Time and duration operations
Random Random number generation
UUID UUID generation and manipulation
Environment Environment variable access
Process Process execution and output capture
File I/O TextFile, BinaryFile, Path, Directory
Networking TCP and UDP operations

Architecture

Source (.sn)
    ↓
Lexer → Parser → Type Checker → Optimizer → Code Gen → GCC
    ↓
Executable

See src/ for compiler implementation details.

Testing

The unified Python test runner works on all platforms (Linux, macOS, Windows):

python scripts/run_tests.py unit              # Unit tests
python scripts/run_tests.py integration       # Integration tests
python scripts/run_tests.py explore           # Exploratory tests
python scripts/run_tests.py sdk               # SDK tests
python scripts/run_tests.py all               # All test suites

Options:

  • -j N / --parallel N - Run tests with N parallel workers (default: CPU count)
  • -v / --verbose - Show detailed output on failures
  • --exclude TESTS - Comma-separated list of tests to skip

Project Structure

├── src/           # Compiler source code
├── sdk/           # SDK modules (date, time, io, net, etc.)
├── tests/         # Unit, integration, exploratory, and SDK tests
├── samples/       # Example .sn programs
├── docs/          # Language and SDK documentation
├── scripts/       # Build and test scripts
├── packaging/     # Platform packages (deb, rpm, homebrew, etc.)
├── benchmark/     # Performance benchmarks
├── bin/           # Compiled outputs (sn, tests)
├── build/         # CMake build directory
├── cmake/         # CMake modules
├── vcpkg/         # vcpkg dependencies
└── CMakeLists.txt # CMake build configuration

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Run tests with make test
  4. Submit a pull request

License

MIT License - feel free to use, modify, and distribute!


Named after the Elvish language from Tolkien's legendarium

About

An experimental compiler in C

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors