Skip to content
This repository was archived by the owner on Feb 12, 2026. It is now read-only.

thagore-foundation/RThagore

Thagore Programming Language

Ask DeepWiki

Thagore is a statically-typed, compiled language that borrows Python-like indentation and brevity while targeting systems-level performance and safety. It uses strong type inference, offers flexible memory management (manual ownership or garbage collection), and ships with a single CLI tool named thagore. Thagore is a distinct language; Rust is only used to implement its compiler/runtime toolchain.

Current plan 💀🙏:

image

Language snapshot

  • Indentation-only blocks; no braces or end. Scripts run top-to-bottom without a main wrapper.
  • Bindings: = plus += -= *= /= %=, and ?= (assign only when the current value is falsy).
  • Expressions: numbers/booleans/null, list [a, b], map {k: v}, arithmetic (+ mod on integers), comparisons (== != <> < > <= >=), logical and/or/not, null-coalescing ??, ternary cond ? a : b, optional chaining (expr?.field/expr?.method()), expr? assertions, and copy/move unary forms.
  • Functions: block or func name(params) = expr; default parameters are allowed; method-call style obj.method(args) passes the receiver first.
  • Control flow: if/elif/else, match/case/default (first match wins; no fallthrough), while, for item in collection (or start..end ranges), break/continue (loops only), return, stop to halt the script.
  • Errors: throw plus try/catch err (optional finally).
  • Imports: use module.path or use module.path as alias, plus from module use name as alias for symbol imports.
  • Symbols from other modules are available via from ... use ... or alias.method(...) only.
  • Strings: double-quoted basics; v-strings v"..." interpolate {expr} with {{/}}; comments use // or /* ... */.
  • Truthiness: falsy values are null, false, empty strings, and unit (no-return); all others are truthy. Type inference stays on by default.
// examples/hello.tg
func greet(name) = print(v"Hello {name}!")

name = input(v"Enter your name: ")
greet(name)

CLI usage

  • thagore run <file.tg> - read, parse, and execute a program.
  • thagore init [<dir>] - scaffold a new Thagore project (configs, src/main.tg, test skeleton).
  • thagore check <file.tg> - syntax/type/borrow validation without execution.
  • thagore version - print the tool version.
  • thagore update - update the thagore binary from a manifest URL.
  • thagore fli-verify <metadata.tgc> [--lock-output out.ltgc] - validate Foreign Library Interface metadata (TGC) and emit an ABI hash (optionally writing a lock snippet in .ltgc).
  • thagore lang [<en|vi>] - switch CLI messages for this invocation; if no value is provided, an interactive arrow-key picker is shown (fallback to English if no TTY).
  • Global --lang <en|vi> flag works with any command to localize CLI/log messages (case-insensitive).
  • Global compatibility flags: --language-version, --runtime-version, --stdlib-version let you target older language/runtime/stdlib versions; pipeline caches will invalidate if these change.
  • Module resolution flags: --lib-path <path> (repeatable), --stdlib-path <path>, --trace-imports (shows origin + path), --print-resolve <spec> (prints resolve/chosen/origin).
  • Backends: --backend vm (default), --backend wasm, or --backend cranelift (with the feature enabled). With Cranelift you can keep artifacts using --emit-obj (object file) and/or --emit-exe (linked native binary).

Package manager (drago)

Drago also ships a minimal package manager binary named drago.

  • drago init - create .drago/, package.tgc, and drago.lock.
  • drago add axios - add a verified registry alias (or @user/pkg / github:user/repo for unverified).
  • drago install - resolve dependencies, update drago.lock, and install into .drago/packages/.
  • drago list - show installed packages (with --tree if desired).
  • drago clean - clear cache and temp artifacts.
  • drago pub - generate drago.pub for distribution.
  • drago update - update the drago binary from a manifest URL.

Docs: docs/DRAGO.md, docs/registry.sample.json.

Update manifests:

  • THAGORE_UPDATE_MANIFEST enables thagore update (and auto-update with THAGORE_AUTO_UPDATE=1).
  • DRAGO_UPDATE_MANIFEST enables drago update (and auto-update with DRAGO_AUTO_UPDATE=1).

Example usage:

drago init
drago add axios
drago add axios@^1.2.0
drago add user/repo
drago add github:user/repo
drago install
drago remove axios
drago list
drago clean
drago pub --name mylib --version 0.1.0

Project layout

Canonical core spec: docs/SYNTAX.md + docs/contracts.md.

  • src/main.rs - binary entrypoint; wires CLI to the pipeline.
  • src/cli/ - argument parsing and command dispatch (run, check, version).
  • src/core/ - shared types like SourceCode and ZenResult.
  • src/diagnostics/ - unified ZenError and error reporting helpers.
  • src/fs/ - filesystem helpers for loading .tg sources.
  • src/lexer/ - token definitions and an indentation-aware lexer (comments, strings, interpolation, numbers).
  • src/parser/ - AST + parser for core statements/expressions, imports, and OOP constructs.
  • src/backend/ - MIR lowering + runtime backends (VM/MIR, WASM, Cranelift).
  • docs/OVERVIEW.md - detailed design and architecture notes.
  • docs/contracts.md - canonical AST/MIR/span/module_key contracts and diagnostics rules (keep in sync with code).
  • docs/SYNTAX.md - the up-to-date syntax reference for the core language (v-strings, range step, time counter).
  • docs/OOP.md - Python-like OOP behavior (inheritance, __init__, bound methods).
  • examples/ - sample Thagore programs.
  • tests/ - integration tests for CLI flows.

OOP contract (enforced at parse/MIR/codegen/runtime)

  • final classes cannot be extended; sealed classes only extendable inside the same module.
  • All bases must exist; unknown base classes are rejected.
  • override must match an existing base method or trait requirement (arity-checked); otherwise it is an error.
  • Non-abstract classes must implement all trait requirements with non-abstract methods.
  • Abstract methods cannot be called; abstract/mixin types cannot be instantiated.
  • The validator runs before codegen (VM/WASM/Cranelift) so CLI errors include spans for the offending method/class.

Building and running

  1. Prebuilt (Windows): dist/thagore-windows-x86_64.exe run examples/hello.tg
  2. Install Rust (Cargo and rustc) neu can build tu source.
  3. Build: cargo build
  4. Run example: cargo run -- run examples/hello.tg
  5. Check example: cargo run -- check examples/hello.tg
  6. Tests: cargo test
  7. Bootstrap (optional): cargo run --bin thagore -- run bootstrap/bootstrap.tg
  8. Bootstrap (PATH): thagore run bootstrap/bootstrap.tg (xem docs/BOOTSTRAP.md; set THAGORE_STAGE0 neu binary stage0 khong trong PATH)

Cross-platform setup (local)

  • Windows: install "Desktop development with C++" (or Build Tools) to get MSVC link.exe, then install Rust via rustup (default stable MSVC toolchain). Verify with cargo --version and rustc --version.
  • Linux: install build essentials (e.g., build-essential/gcc/clang plus pkg-config if needed) and Rust via rustup.
  • macOS: install Xcode command line tools (xcode-select --install) and Rust via rustup.
  • After prerequisites, run cargo build and cargo test on each platform; the codebase avoids platform-specific APIs to stay portable like Python.

Current status

  • Interpreter covers the full core snapshot above (bindings, control flow, collections, interpolation, try/catch/finally, stop/throw, optional chaining, match).
  • Lexer is indentation-aware with comments/escapes/interpolation; parser/runtime keep expanding toward richer typing and the dual memory model. Standard modules will be written directly in Thagore and loaded with normal use/import <module> (no embedded DSLs).
  • Planned keywords (struct, borrow, borrowmut, gcnew, pyimport) are reserved but not implemented yet; copy/move are reserved keywords with implemented semantics.
  • Runtime note: today the compiler/runtime and host stdlib are implemented in Rust; this is a conscious dependency for now and may be replaced or supplemented with other backends/runtimes in the future.

Stdlib plan

  • Stdlib is split into a minimal auto-imported prelude and optional modules.
  • Roadmap and module layout live in docs/STDLIB_PLAN.md.

Cross-platform CI

  • GitHub Actions workflow at .github/workflows/ci.yml builds across Linux, macOS (Intel + Apple Silicon), and Windows for both AMD64 and ARM64 targets; Linux ARM64 uses cross, native targets also run tests.

Upcoming features (99,99% won't scroll down lol):

  • Add GUIs
  • Add classickeywords which add more remember keywords like print(), input() for beginners (this will become external library)

About

Viết ngắn. Chạy nhanh. Đọc như suy nghĩ.

Resources

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages