Vessel

Vessel (Virtual machinE Simulating Stack and queuE Language) is a language designed by User:PixelatedStarfish in 2021. As the name suggests, the language is designed to simulate theoretical machines. Vessel is designed with an acceptable degree of practicality in mind. It features several high-level operations to preserve the sanity of programmers. 
==Syntax==
===Tokens===
The following tokens are utilized in this language:
*Command is a command, such as one that starts an instruction. 
*Value is an integer value between 0 and 255 or any address that points to such an integer.
*Address is a pointer to a memory location on the grid, deque, or input register.
*String is a literal string of characters, such as Hello World!
===Grammar in EBNF===
 Program ::= {Instruction}
 Instruction ::= Command, {Param, Space}, Newline
 Param ::= Value | Address | String | Label | Identifier 
 Address ::= ValAddress | InputString 
 String ::= {Char}
 Label ::= ('L' | 'LBL' | 'LABEL'), Space, Identifier
 Identifier ::= {Letter | Digit}
 ValAddress ::= Cell | DeqVal | InputInt
 Cell ::= 'C'
 DeqVal ::= 'T' | 'B'
 InputInt ::= 'I'
 InputString ::= 'S'
 Command::= {Letter}, Space
 Value ::= {Digit} | Address
 Space ::= ' '
 Newline ::= '\n'
 Digit ::= '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9'
 Letter ::= 
 'A' | 'B' | 'C' | 'D' | 'E' | 'F' | 'G' | 'H' | 'I' | 'J' | 'K' | 'L' | 
 'M' | 'N' | 'O' | 'P' | 'Q' | 'R' | 'S' | 'T' | 'U' | 'V' | 'W' | 'X' | 'Y' | 'Z'
 Char ::= a printable ASCII character.
==Commands==
 Table of commands
Command 	Arguments 	Description
BEGIN / START 	None 	An optional label to indicate the start of execution.
GRID 	Value; Value 	A header operation to initialize an x by y grid.
MOVX / MX 	Value 	Move the grid pointer to the right by the specified number of cells.
MOVY / MY 	Value 	Move the grid pointer up by the specified number of cells.
JUMP / J 	Value; Value 	Jump to cell specified at (x,y).
QUE / ENQ 	Value 	Enqueue Value at bottom of deque.
DEQ / POP 	None 	Dequeue or pop Value at top of deque.
PUSH 	Value 	Push Value onto top of deque.
DUP 	None 	Duplicate Value at top and push.
SHFL / SHUFFLE 	None 	Shuffles the deque.
RCW 	None 	Rotate Clockwise. Value on top of deque shifts to bottom and values shift up.
RCCW / RACW 	None 	Rotate opposite of clockwise. Values shift down; Value at bottom goes to top.
PCHR 	Value 	Print value as ASCII character.
PVAL 	Value 	Print value.
PSLT 	String 	Print String literal.
PGRID 	None 	Print grid.
PDEQ 	None 	Print deque.
STR / STORE 	Address; Value 	Store value at address.
ADD 	Address; Value; Value	Adds two values and stores at address.
SUB 	Address; Value; Value	Subtracts argument 2 from argument 1 and stores at address.
MUL / PROD 	Address; Value; Value	Multiplies two values and stores at address.
DIV / QUO 	Address; Value; Value	Divides argument 1 by argument 2, takes the floor of the quotient, and stores at address.
MOD 	Address; Value; Value	Performs the Modulo operation with two values and stores at address.
RFL 	Address; Value; Value	Takes the floor of the radical (root) operation and stores at address. Argument 1 is the radicand and argument 2 is the index (the latter being the root, or degree thereof).
POW / EXP 	Address; Value; Value	Raise argument 1 to the power of argument 2 and store at address.
LBL / LABEL / L 	Identifier 	A label.
G / GOTO 	Label 	Go to the specified label.
CBZ 	Label; Value 	Go to label if value is zero. (Compare and branch if zero.)
CBNZ 	Label; Value 	Go to label if value is not zero. (Compare and branch if not zero.)
CBV 	Label; Value; Value 	Go to label if argument 1 is equal to argument 2.
RET / RETURN / GOBL / GOBLINS	None 	Return to the last go to statement executed (not a branch) and start execution at the next line. This is a subroutine operation. See Goblins Operation.
WAIT / SLEEP 	Value 	Pause execution for the number of milliseconds indicated.
INPUT / INP 	String 	Print String (or "Input Requested" if not specified). Then take input and store at the input register.
NOTE / CMT / COMMENT 	None 	A comment.
HALT / H / HLT / END 	None 	End Program. A halt command.
THROW / EXCEPT / EXCEPTION 	String 	Throw exception and print an error message ("Error" if not specified). Terminate execution.
==Memory==
===Cells and the Grid===
The Grid is a two dimensional array of cells. Cells can store values from 0 - 15 in hex:
 0 1 2 3 4 5 6 7 8 9 A B C D E F
The value on each cell can be modified with arithmetic commands, but they cannot have a value lees than 0 or more than F. 
Cell values wrap around; so (0 - 1) = F and (F + 1) = 0.
Cells on the gird are accessible via a pointer that moves in orthogonal directions.
===Values on the Deque===
The deque is a data structure that allows for operations on a queue and stack. Deque is short for Double Ended Queue It is essentially a queue that has the ability to change the direction of data processing at any time. Enqueues (or pushes) and dequeues (or pops) can be performed on either end of the deque. The deque can also rotate, which moves a value on one end to the other.
A value on the deque is an integer in the range from 0 to 255. Various commands can manipulate deque values and their respective positions on the deque. A value on the deque cannot be less than 0 or more than 255.
Values also wrap, so (255 + 1) = 0 and (0 - 1) = 255.
===Accessing Memory Addresses===
The following operations can be used in a command argument to access memory addresses:
*C gets the value of the cell currently pointed to.
*T gets the value at the top of the deque.
*B gets the value at the top of the deque.
*I gets input at the input register and parses it as an integer.
*S gets input at the input register as a string
==Program Examples==
===Hello World===
 PSLT Hello World!
===Truth Machine===
 INP
 CBZ 0 I
 L 1
 PVAL 1
 G 1
 L 0
==Proof of Turing Completeness==
Bf is Turing complete.
By translating each bf command to Vessel, it can be shown that Vessel is also Turing complete.
In this proof bf cells are substituted with values on the deque.
(Note that ' :: ' is a stand-in for a newline.)
 Conversion Table 
Vessel 	bf	Desc
RCW 	> 	increment
RACW 	< 	decrement
ADD T 1 	+ 	add 1 to cell
SUB T 1 	- 	take 1 from cell
PCHR T 	. 	Output ASCII value at deque value
INP 	, 	Take input at cell
CBZ x 	[ 	Jump past ' ] ' (to label x)
CBZ x :: G y :: L x	] 	goto ' [ ' (label y) if cell is greater than 0
'''
==Possible Rework==
In general, a stack is easier to implement and program with than deque. So this could be an alteration to the language.
An unbounded grid is also possible, but difficult to implement.
Category:Languages Category:Unimplemented Category:Turing complete Category:Deque-based Category:Stack-based Category:Queue-based Category:Cell-based Category:High-level Category:2021