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.
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
cargo build --workspace --releaseBinaries land in target/release/:
noorandنور— driver (parse + emit Go + invokego).
بسته اصلی
کتابخانه («فرمت»)
کار نخست() {
فرمت.چاپ(«سلام، جهان»)
}
./target/debug/noor run hello.noor
# → سلام، جهان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
| 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 |
- No ASCII semicolons. Newlines end statements. Internal separator
inside
for/ifinit 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 prependsXto exported names so the resulting Go symbol satisfies Go's exported-first-letter rule.
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.
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.
The implementation grew in 14 phases (visible in git log):
- Scaffold + Go-shaped lexer/parser
- Hello-world Go emitter
- Variables (
متغیر+:=) + binary arithmetic - Control flow (if/else, for, switch, break/continue, comparisons)
- Composite types (struct, slice, map)
- Multi-return, variadic, closures, multi-name short decl
- Errors as values (
خطا,هیچ, if-with-init) - Methods + interfaces + pointer types
- Concurrency (
همرو,جریان,<-,بساز) - Defer + panic + recover
- Adapter-driven package registry (built-in +
~/.noor/adapters/) - Type-checker MVP (unused imports/vars, call/return arity)
- Examples harness + docs
- Repo extraction (this commit history)
cargo build --workspace
cargo test --workspace
cargo fmt --all --check
cargo clippy --workspace --all-targets -- -D warningsMIT. See LICENSE.