Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Concept

We want to try and produce a Macros based Tamil programming interface for Rust. This follows in the line of Elango Cheran work on Clojure and Tamil macros enabling Tamil programming interface https://youtube.com/watch?v=terdLf0ribg and https://github.com/echeran/clj-thamil

rust-thamil

A proof-of-concept Tamil vocabulary layer for Rust, inspired by clj-thamil. Version 0.2 adds a procedural macro that translates a whole module or source file instead of wrapping each statement in a separate Lisp-like macro call.

Inline whole-module syntax

use rust_thamil::தமிழ்_மூலம்;

தமிழ்_மூலம்! {
    பொது தொகுதி கணக்கு {
        பொது செயல்கூறு கூட்டு(: i32,: i32) -> i32 {
            அ + ஆ
        }

        பொது செயல்கூறு கூட்டுத்தொகை(எண்கள்: &[i32]) -> i32 {
            மாறி மாறக்கூடிய மொத்தம் = 0;
            ஒவ்வொன்றாக எண் உள் எண்கள் {
                மொத்தம் += எண்;
            }
            மொத்தம்
        }
    }
}

This expands approximately to:

pub mod கணக்கு {
    pub fn கூட்டு(: i32, : i32) -> i32 { அ + ஆ }

    pub fn கூட்டுத்தொகை(எண்கள்: &[i32]) -> i32 {
        let mut மொத்தம் = 0;
        for எண் in எண்கள் { மொத்தம் += எண்; }
        மொத்தம்
    }
}

Include-source style

Place Tamil-flavored Rust in src/கணக்கு.tamil.rs:

பொது தொகுதி கணக்கு {
    பொது செயல்கூறு இரட்டிப்பு(மதிப்பு: i32) -> i32 {
        மதிப்பு * 2
    }
}

Include it from normal Rust:

use rust_thamil::தமிழ்_கோப்பு;

தமிழ்_கோப்பு!("src/கணக்கு.tamil.rs");

Paths are relative to the consuming package's CARGO_MANIFEST_DIR.

Core vocabulary

Tamil Rust
பொது pub
தொகுதி mod
பயன்படுத்து use
செயல்கூறு fn
மாறி let
மாறக்கூடிய mut
எனில் if
இல்லையெனில் else
பொருத்து match
ஒவ்வொன்றாக for
உள் in
வரையில் while
சுழல் loop
திருப்பு return
முறி break
தொடர் continue
வாய்மை true
பொய்மை false
வரி_அச்சிடு! println!
சமம்_உறுதி! assert_eq!

How it works

Rust tokenizes the body of a procedural macro before parsing it as Rust items. Tamil words are valid Unicode identifiers at that stage. The macro walks the entire token tree recursively and replaces reserved Tamil vocabulary with Rust keywords or built-in macro names. The resulting stream is then parsed normally by Rust, so ownership, borrowing, types, patterns, expressions, blocks, and semicolons remain native Rust.

Important limitations

  • The outer தமிழ்_மூலம்! { ... } or தமிழ்_கோப்பு!(...) invocation is still required on stable Rust.
  • Vocabulary words are reserved inside translated source. A local variable named மாறி, for example, would be translated to let.
  • This is token translation, not a full Tamil Rust parser. Rust punctuation and grammar remain unchanged.
  • File inclusion reads the source during procedural-macro expansion. A production release should add compiler-supported path tracking when that API is stable.
  • Macro names retain Rust's required !, such as வரி_அச்சிடு!(...).

Testing

Run from the workspace root:

cargo test --workspace

About

Crate for programming in Rust using the tamil language

Resources

Stars

3 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages