Table of Contents

Brainlack: the language that makes you lack a brain!

Welcome to the Brainlack language documentation. Brainlack is a simple, yet powerful language that uses a unique set of commands to manipulate memory cells and pointers. Let's dive into the commands:

For a list of ASCII characters, please see the ASCII Table

Brainlack reads commands from a file and executes them one by one. If the file cannot be opened, the interpreter will print an error message and exit. Let's learn about it!

Understanding Memory Cells and Pointers

In Brainlack, memory is represented as an array of cells, and there's a pointer that can move left or right to different cells. Each cell can hold a numerical value, and the commands you write will manipulate these values and the position of the pointer.

Comments

To make comments, you would place a ; along with the comment you want to put and end it off with another ;.

; This is a comment.;

Writing Your First Brainlack Program

Let's write a simple Brainlack program that increments a memory cell, moves the pointer, and then decrements the new memory cell. Here's how:

  1. Open a new file in your text editor.
  2. Type the following commands: [.(.]
  3. Save the file with the name "main.bl".

This program will increment the value in the first memory cell, move the pointer to the right, and then decrement the value in the second memory cell.

Debugging Your Brainlack Programs

If your program isn't working as expected, here are some debugging tips:

Example

  1. First, write your commands in a file. Here's an example:
    [..*,,(.*).]
    This command sequence will increment the value in the current memory cell twice, double it, triple it twice, move the memory pointer to the right, double the value in the new memory cell, output the ASCII value, move the memory pointer to the left, and output the ASCII value again.
  2. Next, save the file with any name you like, but make sure it has the .bl extension. For example, "example.bl".
  3. Finally, open your terminal, navigate to the directory containing your .bl file, and run the command `bl example.bl`. The interpreter will execute the commands in the file and print the output to the console.