baa

From Esolang
Jump to navigation Jump to search

baa is a register-based esolang created by User:Joaozin003 where each command has the form "b*insert two or more a's*"

Syntax

The syntax is very easy to understand.

Also, commands can only appear once per line.

Numbers

It's the only form of objects and can be passed as arguments to some commands (more on that later!) and is held by the registers (more on that later!).

Numbers are represented by any amount of consecutive letters (not at the start of the line, otherwise it's a command) and the amount of letters is the number.

Examples: 10 = tenletters, 11 = elevenchars

Registers

Registers can hold numbers and are the "replacements" of variables.

There are 3 registers in baa and we call them a, b and r.

Registers a and b serve as inputs for mathematical operations and r is the result of them.

Constants

The only constant is zero (represented by 0) (it's a constant because it can't be achieved without mathematical operations) and can be put in registers a and b just like if it was a normal number.

Commands

Command Description
baa Start program
baaa End program
baaaa Print specified number as Unicode
baaaaa Print the r register as Unicode
baaaaaa Set the a register to the specified number
baaaaaaa Set the a register to the r register
baaaaaaaa Set the b register to the specified number
baaaaaaaaa Set the b register to the r register
baaaaaaaaaa Set the r register to the sum of a and b
baaaaaaaaaaa Set the r register to the difference of a and b
baaaaaaaaaaaa Set the r register to the product of a and b
baaaaaaaaaaaaa Set the r register to the quotient of a and b
baaaaaaaaaaaaaa Set the r register to a modulo b
baaaaaaaaaaaaaaa Set the r register to a squared
baaaaaaaaaaaaaaaa Put a label here with a id of the line number
baaaaaaaaaaaaaaaaa Goto the label with a id of the specified number if a > 0
baaaaaaaaaaaaaaaaaa Goto the label with a id of the specified number if b > 0
baaaaaaaaaaaaaaaaaaa Goto the label with a id of the specified number if r > 0

Example programs

Print every Unicode character

baa
baaaaaa 0
baaaaaaaa a
baaaaaaaaaaaaaaaa
baaaaa
baaaaaaaaaa
baaaaaaa
baaaaaaaaaaaaaaaaa four
baaa

This program loops and prints all unicode characters (starting with NUL) until unicode ends and the interpreter likely throws an exception.

Contribute

If you have any ideas, make sure to put them in the talk page!

External resources