# IBSA

This is still a work in progress. It may be changed in the future.

IBSA (short for Interacting Binary Substitution Automata) is an esolang made by User:Simple9371. Its main idea is the method call syntax <object>.<method>(<inputs>) in Object-oriented languages.

## Documentation

IBSA has no stdin and stdout. An IBSA code has three parts written in order: 1) Objects and methods initialization, 2) Flow definition, and 3) First execution. Whitespaces (line breaks, space, tabs, etc.) and comments are like in C-style languages.

### Objects and methods initialization

Both objects and "methods" (will be explained in the next part) are always finite binary strings (i.e. ${\displaystyle \in \{0,1\}^{*}}$); empty string is written as !. Objects are mutable, whereas methods are not. Objects and methods are both assigned via either:

• <objectOrMethodName>/<binaryString> (explicit assignment of binary string),
• <objectOrMethodName>/<anotherObjectName> (which copies the value of the previously defined object), or
• <objectOrMethodName>/<anotherObjectName>.<anotherObjectName> (which copies the value of the previously defined method assigned under an object).

Methods are assigned under the object via the syntax <objectAssignment> {<methodAssignment1>, <methodAssignment2>, ...}; no brackets should be written for objects without methods. Overall, here is what objects and methods initialization would look like:

x/100;   // one can see below that this is effectively immutable
obj0/11111 {
x/x,   // becomes 100
y/obj0.x,   // also becomes 100
e/!
};
obj1/00010101 {
x/obj0,   // becomes 11111
e/obj0.e   // becomes !
};
...


Allowed names (for both objects and methods) are similar to many conventional languages: name must satisfy the regex ^[a-zA-Z_][a-zA-Z_0-9]*.

### Flow definition

Let's define conventions for brevity: <mainInput> would be the shorthand for <string>|<objName>|<objName>.<methodName>. Natural numbers will be written in syntax as <nat>.

From the introduction above, the main idea for this language is the call. Here is its syntax:

<call> ::= <objName>.<methodName>(<mainInput>, <nat>)|#

The first expresssion means that the object <objName> with the method <methodName> is called with the inputs, in which the roles will be explained in a short while. On the other hand, the other expression # means simply halting the program.

Now the flow of the whole program is defined through a list of statements for some methods of any object. Here is the syntax for a statement:

<statement> ::= <objName>.<methodName>? <call0>: <call1>;

A statement will "activate" if <objName> with <methodName> is called, which is from <call> in another statement or itself. Upon activation, <objName> is checked if it contains <mainInput> (in <call>) as substring, starting from bit <nat> (the first bit would be "bit 0"). If true, then the substring of <mainInput> in <objName> is completely replaced by <methodName>, and then call <call0>. Else, then no bit string replacement will occur, and <call1> is called. Here are some examples for substring checking:

• It is true that <objName>='001011' contains '10' at <nat>=2.
• It is false that <objName>='001011' contains '10' at <nat>=10 (because <objName> doesn't have bit 10).
• It is false that <objName>='001011' contains '10' at <nat>=5 (because <objName> doesn't have bit 6, which '10' as a substring requires).

For the case of <mainInput>=!, the <nat> corresponds to the empty string before the bit <nat>, and string replacement becomes insertion. Here are some examples for substring checking:

• It is true that <objName>='001011' contains ! at <nat>=0.
• It is true that <objName>='001011' contains ! at <nat>=6 (because the last bit of <objName> is bit 5).
• It is false that <objName>='001011' contains ! at <nat>=7 (because <objName> doesn't have bit 6 and 7).

Overall, here is what flow definition would look like:

obj0.x? obj1.x(010, 2): obj0.e(x, 0);
obj1.e? #: obj0.y(obj1, 1);
...


### First execution

This last part is simply a <call> to start the flow of the program. Here is what first execution would look like.

obj1.e(0, 0);


The overall "output" of an IBSA program is the final values of objects after the halt.

WIP

## Computational class

I conjecture that this is Turing-complete, but I have no proof as of writing this.

WIP