Skip to content

DeForestt/aflat

Repository files navigation

AFlat

AFlat is a simple, low-level, programming language. It is designed to give as much freedom as possible to the programmer, and yet at the same time be easy to read and understand. Please see the documentation for the full documentation. Please see examples in the examples Repository.

Trust the programmer philosophy

AFlat aims to trust that developers know what they are doing. It allows and encurages things that many other modern languages do not such as pointer arythmatic, memory managment, and so on.


Getting started

One Command to rule them all

Install with one command:

curl -s https://raw.githubusercontent.com/DeForestt/aflat/main/install.sh | bash

Cloning the repository

git clone https://github.com/DeForestt/aflat

Building the project

All that is required to build the project is to create the bin directory and run the make command. please make sure that you have the make command installed. sudo apt install make

cd aflat
mkdir bin
make

I suggest creating an alias for main in your bashrc file.

alias aflat="<aflat bin dir>/main"

Or adding the aflat bin to your path.

This readme assumes that the aflat bin directory is in your path or an alias is set.

Creating a new project

Creating a new aflat progect is as simple as running the binary with the command 'make'

aflat make <project_name>

Hello World

The hello world program in aflat is auto-generated by the make command.

.needs <std>

import * from "io" under io;

int main(){
    io.print("Hello World!");
    return 0;
};

Building a project

The aflat make command will have generated an aflat.cfg configuration file that tells the built in pacage manager what to build and link the file.

aflat build

Running the project

Build and run the project with the aflat run command.

Array Loop Example

.needs <std>

import {printInt, printChar} from "io" under io;
import ICollection, Array from "Collections";

int main(){
    Array a = new Array(int, 10);
    for int i = 0; i < 10; i = i + 1 {
        adr pointer = a.at(i);              // adr - is the pointer 'address' key word
        pointer =: i;                       // the =: operator is used to load a value to a pointer
    };

    a.forEach([adr value]=> io.printInt(value as int)); // the as operator is used to assume the type of a pointer
	io.printChar('\n');
    return 0;
};

Have fun!