Skip to content

Borderliner/Noor

Repository files navigation

Noor (نور)

A Persian-syntax programming language that compiles to Go. Source files (.noor or .نور) are lexed, parsed, type-checked, lowered to a Go translation unit, and handed to the host go toolchain for the actual build.

Noor was extracted from the Hormoz project once its design settled around a Go backend. The two share patterns (grapheme-aware lexer, diagnostic-collecting parser, adapter-driven stdlib) but Noor is the long-running effort.

Layout

noor-core/   # lexer, parser, AST, typeck, go_gen, adapters registry
noor-bin/    # `noor` / `نور` CLI driver
examples/    # 14 demo programs + run_all.sh harness
adapters/    # sample TOML manifests for Go stdlib packages

Build

cargo build --workspace --release

Binaries land in target/release/:

  • noor and نور — driver (parse + emit Go + invoke go).

Quick start

بسته اصلی

کتابخانه («فرمت»)

کار نخست() {
    فرمت.چاپ(«سلام، جهان»)
}
./target/debug/noor run hello.noor
# → سلام، جهان

CLI

noor parse  <file.noor>      print parsed AST
noor emit   <file.noor>      print emitted Go source
noor build  <file.noor>      emit `<file>.go` next to source
noor run    <file.noor>      emit Go then `go run` it
noor adapter list            list installed package adapters
noor adapter add  <file>.toml install an adapter
noor adapter remove <alias>  delete an adapter by alias

Syntax overview

Source-level feature Noor keyword Go equivalent
package decl بسته package
import block کتابخانه («pkg») import "pkg"
public marker عمومی before decl uppercase first letter
function decl کار نام(...) func name(...)
method decl کار (recv T) Name(...) func (recv T) Name(...)
return بازگشت e1, e2 return e1, e2
value binding متغیر, := var, :=
primitives صحیح۳۲ etc. int32, …
string «...» interpreted "..."
nil / unit هیچ nil (Go has no void)
bools درست / غلط true / false
if/else اگر cond { } وگرنه cond { } وگرنه { } if/else if/else
if with init اگر init؛ cond { ... } if init; cond { ... }
for loops برای { }, برای cond { } for {}, for cond {}
switch انتخاب, مورد, پیشفرض switch, case, default
struct decl ساختار نام { ... } type Name struct {...}
slice / map []T, نقشه[K]V []T, map[K]V
interface رابط نام { ... } type Name interface {...}
pointer *T *T
address-of نشانی x &x
chan جریان T chan T
goroutine همرو f() go f()
send/recv ch <- v, <-ch identical
make بساز(T, ...) make(T, ...)
defer موکول f() defer f()
panic / recover وحشت(...), بازیابی() identical
variadic args ...T identical
closure کار(p T) R { ... } func(p T) R { ... }
iota equivalent شمارنده iota
error type خطا error

Notable rules

  • No ASCII semicolons. Newlines end statements. Internal separator inside for/if init clauses is the Arabic semicolon ؛ (U+061B).
  • Digits. ASCII (0-9), Persian (۰-۹), and Arabic-Indic (٠-٩) all lex as integer digits and normalise to ASCII before parse. Mix-and-match allowed within one token.
  • Identifiers accept ZWNJ (U+200C) and hyphens (e.g. می‌خواهم, چاپ-با-فرمت).
  • Visibility is keyword-driven, not case-driven, because Persian has no uppercase. عمومی before کار/ساختار/رابط exports the decl. Identifier mangling prepends X to exported names so the resulting Go symbol satisfies Go's exported-first-letter rule.

Adapter-driven packages

Noor maps Persian package aliases to Go imports via a registry. Built-in entries (فرمتfmt, سیستمos) ship in the binary. Users add more via TOML files under ~/.noor/adapters/:

[package]
alias   = "ریاضی"
go_path = "math"

[[functions]]
alias   = "حداکثر"
go_name = "Max"

[[functions]]
alias   = "ریشه"
go_name = "Sqrt"

Install with noor adapter add path/to/file.toml. Sample adapters live under adapters/ in this repo.

Examples

bash examples/run_all.sh compiles each .noor to Go, builds the binary via go build, runs it, and asserts the expected output. See examples/README.md for the full table.

Phase status

The implementation grew in 14 phases (visible in git log):

  1. Scaffold + Go-shaped lexer/parser
  2. Hello-world Go emitter
  3. Variables (متغیر + :=) + binary arithmetic
  4. Control flow (if/else, for, switch, break/continue, comparisons)
  5. Composite types (struct, slice, map)
  6. Multi-return, variadic, closures, multi-name short decl
  7. Errors as values (خطا, هیچ, if-with-init)
  8. Methods + interfaces + pointer types
  9. Concurrency (همرو, جریان, <-, بساز)
  10. Defer + panic + recover
  11. Adapter-driven package registry (built-in + ~/.noor/adapters/)
  12. Type-checker MVP (unused imports/vars, call/return arity)
  13. Examples harness + docs
  14. Repo extraction (this commit history)

Development

cargo build --workspace
cargo test  --workspace
cargo fmt   --all --check
cargo clippy --workspace --all-targets -- -D warnings

License

MIT. See LICENSE.

About

Noor Programming Language, inspired by Go, written in Rust

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors