ArachnidAbby / BCL

BCL Compiled Language (BCL)

Home Page:https://discord.gg/sShr7fMNFn

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

BCL logo

Project Status GitHub last commit Discord

What is BCL?

BCL (BCL Compiled Language) is a compiled programming language that is inspired by python, rust, and other languages.

Installing via source

To do this you will need:

  • LLVM 14 (or LLVM11 if using alternative fork)
  • Conda
  • Python 3.11+
  • SetupTools (pip install setuptools)
  • Git (required for pip)
  • Visual Studio (When on windows)

Step 1

Clone the git repo

Step 2

run these commands

Step 2.1 (ALL)

This is for all platforms. There is only one linux exclusive command.

# libs required to compile llvmlite from source/custom fork
## linux gcc stuff, I couldn't get it to compile without this
conda install -c conda-forge libstdcxx-ng=12
## llvm14 install (change 14 to 11 if needed)
conda install -y -q -c numba/label/dev llvmdev="14.*" libxml2
## llvm uses cmake
conda install cmake

Step 2.2 (WINDOWS)

Installing llvm 11

# when using a different version of visual studio, do:
set CMAKE_GENERATOR=Visual Studio 17 2022 # an example version of visual studio.
# Install LLVM11. I haven't found a way to use 14 on windows.
pip install git+https://github.com/spidertyler2005/llvmlite.git

Step 2.2 (LINUX)

Installing llvmlite 14 or 11

# Installing custom llvmlite fork that has lld for linking (LLVM14)
pip install git+https://github.com/Hassium-Software/llvmlite-lld.git
# Alternatively, if this doesn't work install (LLVM11)
pip install git+https://github.com/spidertyler2005/llvmlite.git

Step 2.3 (ALL)

installing BCL

# Installing BCL
pip install .

Step 3

run bcl <subcommand> <args> to use BCL!

How to uninstall

run pip uninstall Bens_Compiled_Language

Example code

//  fizzbuzz program
// ===================

import stdlib::*; // will later be an auto-import

define main() {
    for i in 0..100 {
        // printf is in the language, could be used here too!
        print(i);
        print(' ');
        if is_multiple(i, 3) {
            print("fizz");
        }
        if is_multiple(i, 5) {
            print("buzz");
        }
        println();
    }
}

define is_multiple(value: i32, divider: i32) -> bool {
    return (value % divider) == 0;
}

State of the language

The language is not fit for production use. It is missing a very large number of features. Although, it is turing-complete.

Features

  • codeblocks
  • functions
  • function returns
  • function arguments
  • variable declaration and assignment
  • most Operators (now with 100% more bitwise ops)
  • boolean operators
  • if and else statements
  • while loops
  • floats
  • variable type declaration
  • variable assignment-operators (+=, -=, etc)
  • Arrays
  • for-loops (only with range literals rignt now)
  • references
  • constants
  • structs
  • struct functions
  • struct methods
  • struct operator overloading
  • struct generic typing
  • protocol types
  • generator functions/iterators
  • import statement with the ability to import modules/packages (WIP, needs namespaces)
  • compile a folder or file instead of hardcoded test string.
  • heap allocation with garbage collection (Box::<T>)
  • malloc and free functions (If you manage your own memory instead of using Box::<T>)
  • in-line assembly functionality.
  • make sys-calls
  • some access to llvm function directly. (notice: more can, and will, be added) disabled temporarily
  • access to cpu registers.
  • standard math library (VERY VERY WIP)
  • string (literal)
  • strings (mutable)
  • vectors (WIP)
  • stdio library (VERY WIP)
  • run-time errors (Error type for errors as values., Result::<T, E>)
  • Option type (Optional::<T>)
  • namespaces
  • enums

VSCode highlighting

There is a folder called syntax_highlighting, inside there is a vsix file which you can right click to install. Just note that it's a bit of a work in progress.

Documentation

Sphinx documentation can be found in the docs folder. Note that these docs are not up-to-date yet.

Stargazers over time

Stargazers over time

About

BCL Compiled Language (BCL)

https://discord.gg/sShr7fMNFn


Languages

Language:Python 99.7%Language:Makefile 0.3%Language:Shell 0.1%