3LEB

From Esolang
Jump to navigation Jump to search

3LEB is a language supposed to be somewhat similar to languages such as BASIC. Data is stored in variables or on a stack/cells. Keywords are not English, but of an unknown language.

An interpreter exists but can only be accessed by giving the creator User:Hanzlu of the language the 3LEB code for a Hello World! program. The program was given to me, now here is a link to the interpreter [1], the 3leb.py file.

Variables are marked with []. The variable X would always be written as [X] in code. Keywords work as functions, taking arguments and often doing something to/with a variable. Each program must end with the 'DAK' keyword.

The capabilities of writing code on one single line has not been tested, and is not recommended for easy-reading purposes. A optional but by the creator preferred way of writing if clauses is by similar to Python using tabs as in the example program below.

/ PRIME NUMBERS /
JAO 2
PEB [X] 3
:LY [X] VEA 100
    PEB [A] [X]
    PLE [X] 2
    PEB [H] [X]
    PEB [X] [A]
    PEB [Y] 2
    :LY [Y] VEA [H]
        PEB [A] [X]
        ROV [X] [Y]
        PEB [B] [X]
        PEB [X] [A]
        .IK [B] AOS 0
            PEB [Y] [H]
        ,
        GUN [Y] 1
    ;
    .IK [Y] AOS [H]
        JAO [X]
    ,
    GUN [X] 2
;
DAK

To define a variable you write:

PEB [<name of variable>] <number or [variable]>

Such as:

PEB [X] 2

The stack is inherently empty.

To push something on the stack you write:

RAY <number or [variable]>

To pop something off the stack you write (into a variable):

MIG [variable]

It is also possible to set a variable equal to something on the stack like this:

HAF [variable] <number or [variable]>

This does not pop the value of the stack it only copies it into the variable. The second argument is the index of the stack cell. Unlike most programming language whose arrays start with the index 0, the first element of the stack would be accessed with 1 in 3LEB. If you want to set the variable X equal to the 3rd element of the stack you write:

HAF [X] 3


Mathematical operations all work the same way:

<keyword> [variable] <number or [variable]>
ADD = GUN
SUBTRACT = HYL
MULTIPLICATE = AMY
DIVIDE = PLE
MODULUS = ROV

There are two types of output keywords. One for integer output and one for character output.

Integer output works as follows:

JAO <number or [variable]>

Character output works as follows (ASCII):

GAU <number or [variable]>

Input allows the user to input a number, then put into a variable:

UNA [variable]

IF statements are of the form:

.IK [variable] <condition> <number or [variable]>

The dot before 'IK' is necessary. An IF-clause ends with a ','.

The conditions are the following:

EQUAL = AOS
NOT EQUAL = SEB
LARGER THAN = IDI
LESS THAN = VEA

Loops are similar to WHILE loops. They work the same way as IF-clauses but take this form:

:LY [variable] <condition> <number or [variable]>

The colon is necessary. A WHILE-loop ends with a ';'.

3LEB includes special keywords:

CONTINUE = ILO
BREAK = GAN 

To set a variable equal to a random number you write:

VAN [variable] <number or [variable]>

This sets the variable equal to a number between 0 and the second argument.

In order to clear the screen you use the RAK command.

In order to halt the program for a certain amount of milliseconds you write:

URI <number or [variable]>

In order to define a function you start by writing:

VER (<name of function>)

Where the function name is written between parentheses.

Any code written after this command until a '!' character is read, is then saved as the code of the function. In order to run a function you write:

STE (<name of function>)

This runs the function. Functions in 3LEB can be seen as copy paste where you copy the code of a defined function into a specified location.

Comments can be written between '/' character such as:

/ THIS is A comment /

To end a program in 3LEB you must write the keyword DAK.