BracketsLang

From Esolang
Jump to navigation Jump to search

BracketsLang is esoteric programming language invented in 2021 by user PoetLuchnik to show that brackets are better than Python tabs. Code is a sequence of atoms and blocks of sub-code. The program is always curly brackets block. Each block contains sub-code and has its own accumulator, which is zero at the beginning. Atoms have no code in, and they works with parent block accumulator. Accumulator is byte value [0..255]. Brackets are code, everything else is notes.

What do the brackets

case description c-like
() print accumulator as ASCII character putchar(accumulator);
[] increase accumulator by the ASCII value of entered character accumulator += getchar();
<> set accumulator to null accumulator = 0;
{} increment accumulator accumulator++;
(sub-code) store parent accumulator by address in own accumulator RAM[accumulator] = parent_accumulator;
[sub-code] load value by address in accumulator and add it to parent accumulator parent_accumulator += RAM[accumulator];
<sub-code> when ends if the accumulator not equals 0 then ending parent block immediately subcode(); if (accumulator != 0) break;
{sub-code} repeats sub-code endlessly, subtract accumulator from parent accumulator if ends ui8_t T = 0; while(!isbreak) T = subcode(); parent_accumulator -= T;

Examples

Hello World (almost)

add 64
{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}
add 8
{}{}{}{}{}{}{}{}
print 72 'H'
()
sub 3
{{}{}{}<{}>}
print 69 'E'
()
add 7
{}{}{}{}{}{}{}
print 76 'L' x2
()()
add 3
{}{}{}
print 79 'O'
()
enter any key to continue
[]
escape from program
<{}>

Cat

[] input
() output
<> void accumulator
and no escape

Alphabet

r0 = 26
{}{}{}{}(<>)[<>][<>]{}(<>)[<>](<>)
65
{}{}{}{}{}{}({})[{}]{}
r1 = 65
({})
infinity loop
{
	load r1
	[{}]
	print r1
	()
	+1
	{}
	store r1
	({})
	if --r0 == 0 then break
	<{
		if --r0 != 0 then break
		<[<>]{{}<{}>}(<>)>
		+1
		{}
		<{}>
	}>
} 
end of program
<{}>

Compilers

Not exists now...

Interpreters

EasyBracketsLang

EBL is interpreter created by author of this esolang. EBL on itch.io