/tau-lang

A strictly typed, compiled, general purpose programming language.

Primary LanguageCApache License 2.0Apache-2.0

Tau Logo

A unified language for efficient and expressive code.


Welcome to Tau, a programming language designed to be simple yet powerful. This repository contains the compiler for Tau, written in C and utilizing LLVM for backend processing.

Important

The project is in its early stages, and the language is still evolving.

🚀 Features

Syntax

  • Clean, concise, consistent.
  • Keywords are short and recognizable (fun, pub, unit etc.).
  • Similar to other popular languages like C/C++ and Rust.

Types

  • Strong and strict type system.
  • Bounds checked arrays.
  • No null pointers, explicit optionals (?i32).
  • References (&i32).
  • unit instead of void.
  • Structs, unions, enums.

Control Flow

  • Conditional branches (if-then, else).
  • Loops (while-do, do-while).
  • Deferred statements (defer).

Functions

  • Simple function definitions (fun factorial(x: i32): i32).
  • External function declarations (extern "C" fun sqrtf(x: f32): f32).

Expressions

  • Arithmetic, logical, bitwise and comparison operators.
  • Safe and unsafe optional operators (x?, x!).
  • Memory related operators (*x, &x).
  • Special operators (sizeof, alignof).

⚙️ Installation

Prerequisites

  • CMake: Build tool to configure and manage the build process.
  • LLVM: Used as the backend for code generation and optimization.

Building the Compiler

  1. Clone the Repository:

    git clone https://github.com/Baleg00/tau-lang.git
    cd tau-lang
  2. Create a Build Directory:

    mkdir build
    cd build
  3. Configure the Project:

    cmake ..
  4. Build the Project:

    cmake --build .
  5. Install:

     cmake --install .

    After installation add the folder (where Tau was installed to) to your environment variables.

  6. Verify Installation:

    Verify that Tau was installed correctly by running the following command:

    tauc --version

    This should display the installed Tau version.

👏 That's it! You're now ready to start using Tau for your programming projects. If you encounter any problems during installation or have questions, feel free to open an issue.

❤️ Happy coding with Tau!

📦 Usage

Here's how you can create and compile your first Tau program.

  1. Create Source File:

    Create a file called hello.tau and add the following code:

    extern "C" fun printf(fmt: *u8, ...): i32
    
    fun main(): i32 {
      printf("Hello World!")
      
      return 0
    }
    
  2. Compile:

    Compile the Tau source code into an object file.

    tauc --emit-obj hello.tau
  3. Link:

    Use a linker to compile the generated object file into an executable.

    gcc -o hello.exe ./hello.tau.obj
  4. Run:

    Run the executable! If everything went according to plan, you should see Hello World printed to your screen.

    ./hello.exe

🤝 Contributing

If you'd like to contribute to the Tau project, please check out the Contribution Guidelines.

📄 License

This project is licensed under the Apache 2.0 License.

💖 Support

"Buy Me A Coffee"