Skip to content

HelgeSverre/lira

Repository files navigation

Lira

Rust License: MIT Build

A modern systems programming language with Go-like fiber concurrency, pattern matching, and a clean syntax. Compiles to bytecode and runs on a custom VM.

Features

  • Fiber-based concurrency — lightweight green threads with channels
  • Pattern matching — with guards and destructuring
  • Strong typing — with type inference and generics
  • Clean syntax — inspired by Rust, Go, and Swift
  • Fast iteration — bytecode compilation for quick development cycles

Quick Start

Prerequisites

Setup

git clone https://github.com/HelgeSverre/lira.git
cd lira

# Build the compiler and VM
just build

# Run the hello world example
just run examples/hello.li

Hello World

// hello.li
fn main() {
    println("Hello, Lira!")
}

Development

Commands

Command Description
just build Build compiler and VM (debug)
just release Build in release mode
just test Run all tests
just test-verbose Run tests with output
just run <file> Compile and run a .li file
just check Type check without building
just clippy Run Rust linter
just fmt Format Rust code
just clean Clean build artifacts

Manual Build (without just)

# Build
cargo build --package lirac --package liravm

# Compile a file
cargo run --package lirac -- compile examples/hello.li -o /tmp/hello.lic

# Run bytecode
cargo run --package liravm -- run /tmp/hello.lic

# Run tests
cargo test --workspace

CLI Tools

lirac — The Lira compiler

lirac compile <file.li> [-o output.lic]   # Compile to bytecode
lirac check <file.li>                      # Type check only
lirac --version                            # Show version

liravm — The Lira virtual machine

liravm run <file.lic>      # Execute bytecode
liravm run-debug <file>    # Run with debug output
liravm --version           # Show version

lira-lsp — The Lira language server

lira-lsp                   # Start LSP server (stdio)

LSP Features:

  • Diagnostics (syntax and type errors)
  • Completion (keywords, builtins, user symbols)
  • Hover (type info and documentation)
  • Go to definition
  • Find references
  • Document symbols (outline)
  • Semantic highlighting
  • Signature help (parameter hints)
  • Folding ranges
  • Document links (clickable imports)
  • Inlay hints (inline type annotations)
  • Rename symbol
  • Call hierarchy (callers/callees)
  • Code actions (quick fixes, refactoring)

lira-doc — The Lira documentation generator

lira-doc <file.li>         # Generate Markdown docs for a file
lira-doc stdlib/           # Generate docs for a directory

Editor Support

Editor Extension Syntax LSP Tree-sitter
VS Code vscode-lira
Zed zed-lira
Neovim vim-lira
Helix helix-lira
Vim vim-lira
IntelliJ intellij-lira

Install with just <editor>-install (e.g., just nvim-install).

Project Structure

lira/
├── crates/
│   ├── lirac/          # Compiler (lexer, parser, checker, codegen)
│   ├── liravm/         # Virtual machine (interpreter, fibers, runtime)
│   ├── lira-core/      # Shared types & opcodes
│   ├── lira-lsp/       # Language server (LSP)
│   └── lira-doc/       # Documentation generator
├── editors/            # Editor extensions
│   ├── tree-sitter-lira/   # Tree-sitter grammar
│   ├── vscode-lira/        # VS Code extension
│   ├── vim-lira/           # Vim/Neovim plugin
│   ├── zed-lira/           # Zed extension
│   ├── helix-lira/         # Helix config
│   └── intellij-lira/      # IntelliJ plugin
├── stdlib/             # Standard library (20 modules)
├── examples/           # 87 example programs
├── docs/               # Language specifications
└── justfile            # Build commands

Language Overview

// Variables and types
let name: string = "Lira"
var count = 0                    // type inferred

// Functions
fn greet(name: string) -> string {
    return "Hello, " + name
}

// Structs with methods
struct Point { x: int, y: int }

impl Point {
    fn distance(self) -> float {
        return sqrt(self.x * self.x + self.y * self.y)
    }
}

// Pattern matching
match value {
    0 => "zero",
    n if n < 0 => "negative",
    _ => "positive"
}

// Fiber concurrency
let ch = chan(1)
spawn { send(ch, compute()) }
let result = recv(ch)

// Imports
import std.fs.{read_file, write_file}

Documentation

Document Description
Language Overview Introduction to Lira
Type System Types, generics, inference
Concurrency Fibers, channels, select
Standard Library Stdlib reference
Bytecode Format .lic file specification
Roadmap Development progress

Status

Current Phase: Developer Tooling (Phase 8)

Component Status
Lexer & Parser Complete
Type System Complete
Bytecode Compiler Complete
VM Core Complete
Fiber Runtime Complete
Standard Library Complete (21 modules)
Language Server Complete (14 features)
Documentation Generator Complete
Editor Extensions Complete (6 editors)
Code Formatter Planned
REPL Planned
Debugger Planned

Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing)
  3. Run tests (just test)
  4. Run linter (just clippy)
  5. Commit changes (git commit -m 'Add amazing feature')
  6. Push to branch (git push origin feature/amazing)
  7. Open a Pull Request

License

MIT License — see LICENSE for details.

About

[Very WIP] A modern systems programming language (read: rust/go lovechild) with fiber concurrency, pattern matching, and a custom bytecode VM. Written in Rust. (ofc)

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors