# Boat

Jump to navigation Jump to search

This page is formatted terribly. If anyone could help out I'd appreciate it a lot.
Boat is a work-in-progress, C- and Brainfuck-inspired, two-dimensional programming language designed by User:Wareya - feel free to suggest things on the talk page.
If there's an infinite memory strip, it should be Turing complete.

## Notes

First of all I need to rewrite this part. About some variable things -- All memory addressing is treated as big endian, except that arrays are stored with the "first" value "lower", so if bytearray[0] was at bytes 0x40 to 0x39 then bytearray[1] would be at 0x48 to 0x41. Yes, memory is addressed with bits. Another example to the array thing is that with a 3-bit array "tb", if tb[0] were at 0x16 to 0x14, then tb[1] would be at 0x19 to 0x17. You can consider values to be big endian and arrays to be little endian. The interpreter should exit upon finding an unmatched semicolon, such as the program:(this is outdated)

```%(0{1}<5){0{1}=0{1}+1};
```

If someone wants to make a self modifying version of this for whatever reason then go ahead, but I suggest you create multiple "universes" of area to make life less complicated for programmers.

## 2d program flow control

The program flow starts at the top left corner of whatever text there is pointing right. if you can't work like that, use a jump command. The starting coordinates are considered 0,0 - not 1,1.

Command Description
`>` points program flow east/right
`<` west/left
`v` south/down
`^` north/up
`#;` toggle the above flow controls - you'll need to use this to use v, V, ^, <, and > in characters ad strings
`@(x,y);` goto/jump to these coordinates, preserving current program direction (not equivalent to `x`=x;`y`=y; unless the second command is at the location the first one jumps to)
` ` Whitespace outside of values(characters, strings) does nothing.

## Traditional logic

Command Description
`?(e){c}` if an expression 'e' returns true(greater than zero) execute command/s c
`%(e){c}` while e returns true execute command/s c (can be implemented like an asshole with just if and directional statements)
Note: The above should only need brackets if there are multiple commands; however, if there are 2D flow issues with excluding them then allowing no brackets should be excluded from the interpreter.
`!(n)` binary "not" -- note: not boolean, use casting for that
`n==n` equality test -- returns the xnor of two values (if you need booblean, use casting)
`n!=n` inequality test -- returns the xnand of two values
`n|n` "or" -- note: `||` in C is its `|` with a boolean restriction
`n&n` "and" -- note: `&&` in C is its `&` with a boolean restriction
`n!|n` "nor"
`n!&n` "nand"
`n^|n` "xor"
`n^&n` "xand"

## Math

Command Description
`n^n` exponent
`n*n` multiplication
`n+n` addition
`n/n` division
`n-n` subtraction

## Miscellaneous

Command Description
`/` nullify whatever the characteristics of the next character in the program flow direction are or something - make it a byte value, I don't know yet.
`(e)` an expression can be closed in by parenthesis, or must be for some things like tests
`'c'` a character/byte value in ascii or utf-8
`q{n}` access memory at address q with n bits in size -- you could see 4{30} which would access the half byte at bit addresses 27, 28, 29, and 30. Yeah, it's big endian, but that might change as this goes. I guess I could get away call this as a special case for an array of bits.
`q{n}[m]` array with segments the size of n with the "origin" data value being at address q - with big endian, again.
`q{n}[m][b]` multidimensional array
`q{n}=j` set value at memory address q of size n to j
`q{n}[m]=j` set value at spot m in an array to j
`q{n}[y]` use value of size n at address q as an address for a value size y
`;` End a command. Not needed at end of direction commands or a pair of braces.

## Examples

infinite loop

```v<
>^
```

another infinite loop

```>>>>>>>>V
@
>(0,v
0
;)<
```

abusing 2d flow - basic (this is really outdated)

```V             v={2}0(?  <
?(0{2}<3){0{2}=0{2}+1;v}^
^             1      }<
>);the interpreter should not read anything else in this direction but instead exit
note how badly I did that while loop using an if.
```