Skip to content

Latest commit

 

History

History
314 lines (224 loc) · 10.2 KB

File metadata and controls

314 lines (224 loc) · 10.2 KB

vetri (வெற்றி) Programming Language

A general-purpose interpreted language with Tamil keywords, types, built-ins, and standard library — written in Rust

crates.io Rust MIT


🏷️ Name Origin & Dedication

vetri (வெற்றி) means victory in Tamil.

The name is inspired by Tamizhaga Vetri Kazhakam — a movement rooted in Tamil pride, identity, and the pursuit of excellence. This language is a tribute to that spirit: the belief that Tamil — one of the world's oldest living classical languages — deserves a place in every domain of modern life, including code.


Mission

vetri is not just a programming language. It is an experiment with a clear purpose:

Tamil is one of the world's oldest living classical languages, with a literary tradition spanning over 2,000 years. Its script is precise, phonetically complete, and scientifically structured. vetri asks: what does code look like when written in a script that has survived millennia of human expression?

Tamil Code for the AI Age — LLMs are trained on English-dominant data. The more Tamil code exists on the internet — in repositories, documentation, and examples — the better future models will represent the Tamil language and its speakers.

Minority Language as First-Class Syntax — Tamil is spoken by over 80 million people worldwide, yet essentially zero programming languages use it as syntax. vetri is an experiment: what happens when an ancient classical language becomes the grammar of a modern compiler?


About

vetri is an interpreted programming language where keywords, type names, built-in functions, and error messages are written in Tamil. Arithmetic, comparison, and assignment operators follow C/Rust conventions. The toolchain is written entirely in Rust and ships with a tree-walking interpreter, an interactive REPL, and a full LSP server for VS Code.


Quick Start

Install from crates.io:

cargo install vetri-lang

Create வணக்கம்.vetri:

அச்சிடு("வணக்கம் உலகம்!")

Run it:

vetri interpret வணக்கம்.vetri
# Output: வணக்கம் உலகம்!

Or jump into the REPL:

vetri repl
வெற்றி> அச்சிடு("வணக்கம்!")
வணக்கம்!

Key Examples

Factorial

செயல் தொகுப்பு(n) {
    என்றால் (n <= 1) { திரும்பு 1 }
    திரும்பு n * தொகுப்பு(n - 1)
}

அச்சிடு(தொகுப்பு(5))    // 120
அச்சிடு(தொகுப்பு(10))   // 3628800

Fibonacci

செயல் பிபோனாச்சி(n) {
    என்றால் (n <= 1) { திரும்பு n }
    திரும்பு பிபோனாச்சி(n - 1) + பிபோனாச்சி(n - 2)
}

மாறி i = 0
சுழற்று (i < 8) {
    அச்சிடு(பிபோனாச்சி(i))
    i = i + 1
}

Sum of Array

செயல் கூட்டுத்தொகை(எண்கள்) {
    மாறி தொகை = 0
    மாறி i = 0
    சுழற்று (i < நீளம்(எண்கள்)) {
        தொகை = தொகை + எண்கள்[i]
        i = i + 1
    }
    திரும்பு தொகை
}

அச்சிடு(கூட்டுத்தொகை([1, 2, 3, 4, 5]))   // 15

Conditionals & Loops

மாறி i = 0
சுழற்று (i < 10) {
    என்றால் (i == 5) { நிறுத்து }
    என்றால் (i % 2 == 0) {
        அச்சிடு(உரையாக்கு(i) + " இரட்டை")
    } இல்லையென்றால் {
        அச்சிடு(உரையாக்கு(i) + " ஒற்றை")
    }
    i = i + 1
}

More examples live in the examples/ directory.


Features at a Glance

  • Tamil keywordsமாறி, நிலை, செயல், என்றால், இல்லையென்றால், சுழற்று, திரும்பு, நிறுத்து, தொடர்
  • Tamil identifiers — name your variables and functions entirely in Tamil script
  • Tamil boolean literalsஉண்மை (true), பொய் (false)
  • Tamil type namesஎண், மிதவை, உரை, உண்மை_பொய், இல்லை
  • Interpretedvetri interpret for instant execution, no compiler needed
  • REPL + LSPvetri repl for interactive sessions, vetri lsp for editor hover/completion/diagnostics
  • Scoped environments — lexical scoping with closures over function environments
  • Mutable & immutable variablesமாறி (mutable), நிலை (immutable constant)
  • Type annotations — optional typed parameters and return types on functions
  • Arrays — dynamic arrays with index access and built-in தள்ளு / இணை
  • String operations — concatenation with +, conversion with உரையாக்கு
  • Built-in functionsஅச்சிடு, நீளம், எண்ணாக்கு, மிதவையாக்கு, உரையாக்கு, வர்க்கமூலம், தள்ளு, இணை
  • Span-tracked errors — every error reports the exact line and column
  • VS Code extension — syntax highlighting, real-time diagnostics, hover docs, auto-completion for .vetri files

CLI Usage

vetri interpret <file.vetri>    Run with interpreter
vetri check <file.vetri>        Check syntax only (no execution)
vetri repl                      Interactive REPL
vetri lsp                       Start LSP server (hover + completion + diagnostics)

Language Reference

Variables

மாறி மதிப்பு = 42          // mutable
நிலை PI = 3.14159           // immutable constant
மாறி பெயர் = "வெற்றி"

Types

Tamil Meaning Example
எண் Integer 42
மிதவை Float 3.14
உரை String "வணக்கம்"
உண்மை_பொய் Boolean உண்மை / பொய்
இல்லை Void/Null இல்லை

Functions

செயல் கூட்டு(அ, ஆ) {
    திரும்பு அ + ஆ
}

// With type annotations
செயல் வர்க்கம்(x: எண்) -> எண் {
    திரும்பு x * x
}

Built-in Functions

Function Description
அச்சிடு(...) Print to stdout
நீளம்(x) Length of string or array
எண்ணாக்கு(x) Convert to integer
மிதவையாக்கு(x) Convert to float
உரையாக்கு(x) Convert to string
வர்க்கமூலம்(x) Square root
தள்ளு(arr, val) Append to array
இணை(arr, sep) Join array to string

VS Code Extension

The vetri VS Code extension provides full IDE support for .vetri files.

Features

  • Syntax highlighting for all Tamil keywords, types, operators, and builtins
  • Real-time error diagnostics via LSP
  • Hover documentation for every keyword and builtin
  • Auto-completion for keywords and builtins
  • Bracket auto-closing and indentation rules

Installation

From VSIX:

code --install-extension vetri-lang-*.vsix

Extension Settings:

Setting Default Description
vetri.serverPath "" Path to a custom vetri binary. Leave empty to use the bundled binary.
vetri.trace.server "off" LSP trace level: off, messages, or verbose.

Installation

Prerequisites

From crates.io

cargo install vetri-lang

From source

git clone https://github.com/aaiss-uk/vivirim.git
cd vivirim/compiler
cargo build --release

The binary will be at compiler/target/release/vivirim.


Running Tests

cd compiler && cargo test

Covers the lexer, parser, interpreter, and integration scenarios including arithmetic, string operations, conditionals, while loops, functions, arrays, and error handling.


Project Structure

vivirim/
├── compiler/                    # Rust toolchain
│   └── src/
│       ├── main.rs              # CLI (interpret, check, repl, lsp)
│       ├── ast.rs               # Token, Span, Expr, Stmt, Type definitions
│       ├── lexer.rs             # Tamil Unicode tokeniser with span tracking
│       ├── parser.rs            # Recursive-descent parser with Pratt expressions
│       └── interpreter.rs       # Tree-walking evaluator, scoped environment
├── examples/                    # Example .vetri programs
├── src/
│   └── extension.ts             # VS Code Language Client
├── syntaxes/
│   └── vetri.tmLanguage.json  # TextMate grammar
├── language-configuration.json  # Bracket matching & indentation rules
├── scripts/
│   └── build-lsp.js             # Cross-platform binary build script
├── server-binaries/             # Compiled LSP binaries (gitignored)
└── package.json                 # VS Code extension manifest

Contributing

Contributions are welcome. Please open an issue before submitting a pull request for significant changes.


License

MIT © TVKVolunteers


vetri (வெற்றி) — where the beauty of Tamil script meets the precision of code.