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:
git clone https://github.com/<your-username>/glc.git
cd glc
pip install -e .
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
- Lexing – source code → tokens
- Parsing – tokens → AST (abstract syntax tree)
- Transpiling – AST → C code
- Compiling – C → native executable (via GCC/clang)
- 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)
📜 License
MIT License © 2025 Naren
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file goatlang-0.0.1.tar.gz.
File metadata
- Download URL: goatlang-0.0.1.tar.gz
- Upload date:
- Size: 8.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4447a09771c8f45031a7ed472a119c9cc162b968c4e97cb6d798dee49324b094
|
|
| MD5 |
47aae77cccc12cb027f434a893d7253d
|
|
| BLAKE2b-256 |
d605d15ecfd5902f75ffbb805681968cc39d68c682d4556e0561c64fa2923f39
|
File details
Details for the file goatlang-0.0.1-py3-none-any.whl.
File metadata
- Download URL: goatlang-0.0.1-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e3267eb8e57000c81945ef48142902cbb0f83187b9ea9c854439b8198685c1f9
|
|
| MD5 |
e9ec11f56b62ff685cd53553b37cc841
|
|
| BLAKE2b-256 |
e089be8e186146b7e8ea03ceadc0773f686d0a5cd482e0925f33a2fc13cadf92
|