Skip to main content

A compiler for burb lang.

Project description

License: MIT

BLang - A Minimal Programming Language

This is a toy programming language with its own compiler backend that emits x86_64 assembly. It supports basic types, arrays, pointers, functions, conditionals, loops, etc. The compiler is written in Python.

Why?

Just for fun. I wanted to learn how compilers work at a deeper level, and this was a great way to explore parsing, code generation, memory layout, calling conventions, etc.

Is it useful?

Probably not. It's not fast, it's not safe, it's not feature-complete, and it doesn't have a standard library. But the code is (mostly) readable, and it covers a lot of core ideas behind compiling a high-level language down to raw machine code.

Running

Install NASM.

To compile a .bl source file to a native executable:

blangc your_program.bl -o your_program

To run tests:

pytest tests/

Current Features

  • Integers (signed/unsigned), doubles
  • Arrays and pointers
  • Functions (multiple arguments, stack handling)
  • Conditionals (if, else)
  • Loops (while, for)
  • Bitwise operations (&, |, ^)
  • String literals and basic string handling
  • Assembly output using NASM
  • Simple CLI compiler
  • CI build and test pipeline

Missing / Incomplete / Won't Do

  • No type inference or advanced type checking
  • No heap allocation or garbage collection
  • No standard library
  • Limited error reporting
  • No optimization passes
  • No inline assembly or macros (yet)
  • No structs

License

MIT

Example programs

See examples/

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

blang-0.1.3.tar.gz (46.4 kB view details)

Uploaded Source

Built Distribution

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

blang-0.1.3-py3-none-any.whl (27.5 kB view details)

Uploaded Python 3

File details

Details for the file blang-0.1.3.tar.gz.

File metadata

  • Download URL: blang-0.1.3.tar.gz
  • Upload date:
  • Size: 46.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.7.3

File hashes

Hashes for blang-0.1.3.tar.gz
Algorithm Hash digest
SHA256 5b22611edec7497ce9e2f995b296904d0a1d1d16b9ad707279774583254c50c4
MD5 72d14f574cf9ed6f31b8de637726401f
BLAKE2b-256 016f9984c3561ae0d5d2391c7463d5f5bc6a900b535431f4236c9b08b13bf0b1

See more details on using hashes here.

File details

Details for the file blang-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: blang-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 27.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.7.3

File hashes

Hashes for blang-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 236f168be3d7ee35240de286e3edded5754e664e095dd6c6f235d552faf8b2ed
MD5 d645ad17b175d7c5d7a4a9ea2e5317d2
BLAKE2b-256 506b074137dc3bba46eb2c479367e3fd7bb66b6f2448a6f029eeb0cd3ac97070

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