Skip to content

MorphyKutay/ZaferLang

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ZaferLang

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.

Features

  • 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, !
  • 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)
  • 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
  • Standard built‑ins
    • uzunluk(x) – length of a string or list
    • tip(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 to import / include)

Project layout

Inside the zaferlang crate directory:

  • src/ast.rs – AST (abstract syntax tree) types
  • src/lexer.rs – tokenizer / lexer
  • src/parser.rs – recursive‑descent parser
  • src/interpreter.rs – tree‑walking interpreter and built‑in functions
  • src/main.rs – command‑line entry point

Building

Requirements:

  • Rust toolchain (Rust 1.74+ recommended, 1.94+ is known to work)

Build the project:

cd zaferlang
cargo build

Run tests manually by executing example programs:

cargo run -- program.zf

Installing the zaferlang binary

To 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.zf

from anywhere.

Language overview

Hello world

yaz("Merhaba ZaferLang!");

Variables and types

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));

Conditions

eğer a == 1 ve uzunluk(sayilar) == 3 ise {
    yaz("mantıksal ifade: doğru");
} değilse {
    yaz("mantıksal ifade: yanlış");
}

Loops and assignment

sayı i = 0;
iken i < 3 {
    yaz("i = " + i);
    i = i + 1;
}

Functions

fonksiyon topla(x, y) {
    dön x + y;
}

sayı t = topla(5, 7);
yaz("toplam: " + t);

Random numbers

sayı zar = rastgele_sayı(1, 6);
yaz("zar: " + zar);

Modules (kullan)

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.zf

Roadmap ideas

This is an experimental project; possible future ideas include:

  • REPL (interactive shell) when no file is provided
  • List indexing (liste[0]) and for‑like loops
  • Struct‑like records (yapı) and enums
  • Error handling blocks (deneme { } hata olursa { })
  • A small standard library (dosya, zaman, math)

About

ZaferLang is a Turkish‑syntax programming language implemented in Rust.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages