Download

blang

Bruce's language (a defunct programming language prototype)

  • language
Docs 2.8K wordsMarkdown 2.5KText 309
Binary data 20.4 KiBOther 20.4 KiB
NameModifiedLinesSize
lib/ 917 lines11% of this folder's lines 27 KiB9% of this folder's bytes
stdlib/ 486 lines6% of this folder's lines 11.9 KiB4% of this folder's bytes
test/ 1.3K lines15% of this folder's lines 26.8 KiB8% of this folder's bytes
.gitignore 4 lines<1% of this folder's lines 19 B<1% of this folder's bytes
LICENSE 40 lines<1% of this folder's lines 1.9 KiB<1% of this folder's bytes
Makefile 29 lines<1% of this folder's lines 718 B<1% of this folder's bytes
README.md 63 lines<1% of this folder's lines 2.1 KiB<1% of this folder's bytes
blang * 52 lines<1% of this folder's lines 1.5 KiB<1% of this folder's bytes
blangc * 109 lines1% of this folder's lines 3.2 KiB<1% of this folder's bytes
compile.moon 2.5K lines30% of this folder's lines 108.3 KiB34% of this folder's bytes
features.md 460 lines6% of this folder's lines 15.7 KiB5% of this folder's bytes
getsym * 0 lines0% of this folder's lines 20.4 KiB6% of this folder's bytes
getsym.c 22 lines<1% of this folder's lines 703 B<1% of this folder's bytes
list_methods.moon 336 lines4% of this folder's lines 13.6 KiB4% of this folder's bytes
measure_methods.moon 19 lines<1% of this folder's lines 458 B<1% of this folder's bytes
number_methods.moon 22 lines<1% of this folder's lines 841 B<1% of this folder's bytes
parse.moon 48 lines<1% of this folder's lines 1.1 KiB<1% of this folder's bytes
percent_methods.moon 24 lines<1% of this folder's lines 775 B<1% of this folder's bytes
string_methods.moon 106 lines1% of this folder's lines 4.2 KiB1% of this folder's bytes
syntax.bp 237 lines3% of this folder's lines 14.7 KiB5% of this folder's bytes
table_methods.moon 129 lines2% of this folder's lines 5.2 KiB2% of this folder's bytes
typecheck.moon 920 lines11% of this folder's lines 38.7 KiB12% of this folder's bytes
types.moon 346 lines4% of this folder's lines 11.9 KiB4% of this folder's bytes
units.moon 71 lines<1% of this folder's lines 2.4 KiB<1% of this folder's bytes
util.moon 99 lines1% of this folder's lines 3.4 KiB1% of this folder's bytes

README.md

Blang

Blang is a small, statically typed, garbage-collected, compiled imperative language with ergonomic syntax. It uses QBE as a backend IR, and compiles from there to assembly code and then to a binary.

Example

def sing_bottles_song(n:Int)
    for i in n..0
        when i is 0
            say "No more bottles of beer on the wall! :("
        is 1
            say "One last bottle of beer on the wall"
        else
            say "$i bottles of beer on the wall"
    between
        say "Take one down, pass it around... "


sing_bottles_song 99

See test/*.bl for more examples.

Language Features

See features.md for writeups of some of the features in blang. These include:

  • Type-safe DSL strings
  • Units of measure
  • Better loops
  • Ergonomic optional typing
  • Memory safety (GC and automatic array bounds checking)
  • Percentages

Dependencies

The Blang compiler is written in Moonscript, uses QBE as a backend, before being compiled from assembly with your assembler of choice. Blang uses the following libraries:

  • Garbage collection: Boehm garbage collector
    • Available from your package manager of choice: pacman -S gc
  • Parsing and string pattern matching: bp
    • Install via git clone https://github.com/bruce-hill/bp/ && cd bp && make && sudo make install-lib
  • Hash maps: bhash
    • Install via git clone https://github.com/bruce-hill/bhash/ && cd bhash && make && sudo make install
  • String interning: intern
    • Install via git clone https://github.com/bruce-hill/intern/ && cd intern && make && sudo make install

Usage

Once the necessary dependencies are installed, you can use ./blang your-file.bl to run a file directly or ./blangc your-file.bl to compile it into a binary called your-file.o. See blang --help and blangc --help for full usage info.

License

Blang is released under the MIT license with the Commons Clause, see LICENSE for full details.