ZaferLang is a Turkish‑syntax programming language implemented in Rust.
It is a test/experimental project, focusing on being readable for Turkish speakers while remaining a practical, script‑friendly language.
- Turkish keywords and operators
- Variable declaration:
sayı,metin,liste - Conditions:
eğer ... ise ... değilse - Loops:
iken - Functions:
fonksiyon,dön - Boolean literals:
doğru,yanlış - Logical operators:
ve,veya,!
- Variable declaration:
- Built‑in types
sayı(integer)metin(string)liste(dynamic list of values)
- Expressions and operators
- Arithmetic:
+ - * / - Comparisons:
== != < <= > >= - String concatenation with
+(numbers are converted to strings when needed)
- Arithmetic:
- Control flow
eğer ... ise { ... } değilse { ... }iken <condition> { ... }(while‑loop)
- Functions
- Definition with
fonksiyon name(params) { ... } - Return with
dön expr - First‑class support for user‑defined functions
- Definition with
- Standard built‑ins
uzunluk(x)– length of a string or listtip(x)– type name as a string ("sayı","metin","liste","bool")rastgele_sayı(min, max)– random integer in [min, max]cik(kod)– exit the program with an exit code
- Modules
kullan "dosya.zf";to import another ZaferLang file (very similar toimport/include)
Inside the zaferlang crate directory:
src/ast.rs– AST (abstract syntax tree) typessrc/lexer.rs– tokenizer / lexersrc/parser.rs– recursive‑descent parsersrc/interpreter.rs– tree‑walking interpreter and built‑in functionssrc/main.rs– command‑line entry point
Requirements:
- Rust toolchain (Rust 1.74+ recommended, 1.94+ is known to work)
Build the project:
cd zaferlang
cargo buildRun tests manually by executing example programs:
cargo run -- program.zfTo get a zaferlang command similar to python:
cd zaferlang
cargo install --path .This installs zaferlang into Cargo's bin directory, usually:
- Windows:
%USERPROFILE%\.cargo\bin - Linux/macOS:
$HOME/.cargo/bin
Make sure that directory is on your PATH. After that you can run:
zaferlang program.zffrom anywhere.
yaz("Merhaba ZaferLang!");
sayı a = 1;
metin ad = "ZaferLang";
liste sayilar = [1, 2, 3];
yaz("ad: " + ad);
yaz("ad uzunluğu: " + uzunluk(ad));
yaz("sayilar: " + sayilar);
yaz("sayilar uzunluğu: " + uzunluk(sayilar));
yaz("a tipi: " + tip(a));
yaz("ad tipi: " + tip(ad));
yaz("sayilar tipi: " + tip(sayilar));
eğer a == 1 ve uzunluk(sayilar) == 3 ise {
yaz("mantıksal ifade: doğru");
} değilse {
yaz("mantıksal ifade: yanlış");
}
sayı i = 0;
iken i < 3 {
yaz("i = " + i);
i = i + 1;
}
fonksiyon topla(x, y) {
dön x + y;
}
sayı t = topla(5, 7);
yaz("toplam: " + t);
sayı zar = rastgele_sayı(1, 6);
yaz("zar: " + zar);
program2.zf:
kullan "hesap.zf";
sayı x = 4;
sayı x_kare = kare(x);
yaz("x: " + x);
yaz("x kare: " + x_kare);
yaz_kisi("Zafer", 25);
hesap.zf:
fonksiyon kare(x) {
dön x * x;
}
fonksiyon yaz_kisi(ad, yas) {
yaz("ad: " + ad);
yaz("yas: " + yas);
}
Run:
zaferlang program2.zfThis is an experimental project; possible future ideas include:
- REPL (interactive shell) when no file is provided
- List indexing (
liste[0]) andfor‑like loops - Struct‑like records (
yapı) and enums - Error handling blocks (
deneme { } hata olursa { }) - A small standard library (
dosya,zaman,math)