Bolaga++

From Esolang
Jump to navigation Jump to search

Bolaga++ is an extension of Bolaga that introduces labels. It was created by User:Fly, the same creator of Bolaga, in year 2026.

Instructions

It keeps the same instruction set as Bolaga with the addition of these new instructions:

Instructions
Instruction Description
)<label name> Push a copy of the top of the specified label's stack onto the currect label's stack
(<label name> Pop from the specified label's stack
]<label name> Push a copy of the current label's stack onto the specified label's stack
[<label name> Pop from both the specified label's stack and the current label's stack
(there's supposed to be a pipe character here)<label name> Copy the current state of the specified stack in the current label's stack
,<label name> Return to the last call made from the specified label to the current label, then continue code execution from there
\ Compares top two values: if not equal, continue normally; if equal, skips next instruction (or skips whole next loop block if next token is `:`).

For the instructions that operate on labels, if no label is specified, it is automatically assumed to be the main label. For the return instruction, if no label is specified, it will return to the last caller.

Labels

Each Bolaga++ program requires a 'main' label as an entry point for the program.
A label is defined with a '.' followed by a name for the label (a label name can contain '_' and numbers).
You can call a label by prefixing the name of the label you want to call with a '*'. Each label has it's own stack, the stack of the main label is referred as the "main stack".

Examples

Factorial program

.main
    >5
    >1]result<
    *factorial
    $<$%>10@!

.result
.factorial
    ):
        =>1?*end
        <)result
        $>0$:
            >1>0-+$>1+$;<>1>0-+>0$
            :>1>0-+$>1+$;<$=$>0$:>
            1>0-+$>1+$;<$>0$:>1>0-
            +$>1+$;<:>1>0-+>0$:>1>
            0-+$>1+$;<$>0$:>1>0-+$
            >1+$;<$=$>0$:>1>0-+$>1
            +$;<+$>0$:>1>0-+$>1+$;
            <;<>0$:>1>0-+$>1+$
        ;<<$
        ]result<>1>0-+
    ;
    r

.end
    )result]
    r

Recursive count program with pointer to data (using the label 'n' as a variable)

.n
.main
    >5]n<
    )n]count_recursive
    *count_recursive
    (n]n<&!

.count_recursive
    >0\*perform_count
    ],main

.perform_count
    (count_recursive)count_recursive
    =%>10@>1>0-+
    =[count_recursive]count_recursive
    *count_recursive

Computational class

Bolaga++ is turing complete because it doesn't change the main core of Bolaga, but only enriching it with more functionality.
Therefore each proof of turing completeness that apply to Bolaga, also apply to Bolaga++

Implementations

https://github.com/mmmmosca/Bolaga-plus-plus