Skip to main content

A language for goated people with no purpose.

Project description

🐐 GLC (GoatLang Compiler)

GLC is a toy programming language that transpiles to C and then compiles into native executables. It’s designed for learning about compilers, transpilers, and language design while keeping things simple.


✨ Features

  • Variables: int, float, bool, string
  • Arithmetic: +, -, *, /
  • Comparisons: <, >, ==, !=
  • Print statements: print(expr)
  • Conditionals: if / else
  • Loops: while
  • Basic string concatenation (msg + "something")

📦 Installation

Clone the repo and install it locally in editable mode:

pip install goatlang==0.0.1

This installs the glc command into your environment.


▶️ Usage

Compile & Run a program

Create a file hello.g:

fn main() {
    string msg = "Hello, GoatLang!"
    print(msg)
}

Compile and run:

glc hello.g

Output:

Hello, GoatLang!

Another Example (loop, conditionals, math)

fn main() {
    int x = 42
    float y = 3.14
    bool flag = true

    print(x)
    print(y)
    print(flag)

    int sum = x + 10
    float product = y * 2.0
    print(sum)
    print(product)

    if sum > 50 {
        print("Sum is large!")
    } else {
        print("Sum is small!")
    }

    int counter = 0
    while counter < 5 {
        print(counter)
        counter = counter + 1
    }
}

📂 Project Structure

glc/
├── glc/             # Source code
│   ├── lexer.py     # Tokenizer
│   ├── parser.py    # Parser → AST
│   ├── t2c.py       # AST → C transpiler
│   └── main.py      # CLI entry point
├── examples/        # Example GoatLang programs
├── pyproject.toml   # Build config
└── README.md

⚡ How It Works

  1. Lexing – source code → tokens
  2. Parsing – tokens → AST (abstract syntax tree)
  3. Transpiling – AST → C code
  4. Compiling – C → native executable (via GCC/clang)
  5. Running – GLC runs the binary automatically

🛠 Requirements

  • Python ≥ 3.8
  • GCC or Clang (for compiling generated C code)

🚧 Limitations

  • No user-defined functions yet (only fn main)
  • String concatenation is still basic (uses buffers + strcpy/strcat)
  • Error messages are primitive
  • No standard library (beyond print)

Do you have some issues with the language put them here: https://github.com/Narendrakumar-Suresh/goat-lang/issues

📜 License

MIT License © 2025 Naren

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

goatlang-0.0.2.tar.gz (9.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

goatlang-0.0.2-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

File details

Details for the file goatlang-0.0.2.tar.gz.

File metadata

  • Download URL: goatlang-0.0.2.tar.gz
  • Upload date:
  • Size: 9.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for goatlang-0.0.2.tar.gz
Algorithm Hash digest
SHA256 077326f37a387111acce853dff1d97f7920d3f741e605e1344ffc7e4c6cb9e68
MD5 9106ef1747a165faf5027cd44b0f5b8d
BLAKE2b-256 ed005eec2be3c824135b9fb4f45936e76de6849b14b5ed9365cbccba8c51c0de

See more details on using hashes here.

File details

Details for the file goatlang-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: goatlang-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 8.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for goatlang-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 5941bb3dbb1426c83260e3d0ad2e6d69216d2bef8fba257d92bcad080f636126
MD5 0698df662343e09c8b1c7ad4f05b6d4c
BLAKE2b-256 0740f164b1c3a1c45f9f828bb7c2635f50dc34aa824237e7eb28da66fdf13ff8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page