Stck

== Stck ==
Stck is a single thread, Stack based* language, in which the code itself is in the stack.
Well… not really, but it’s what had to be done to make this Turing complete.
=== Structure ===
Stck features 2 Stacks: A Program stack and a Loop Stack.
The Program Stack is the main stack. This is the stack you can change.
The Loop/Temporary Stack is for loops (loop, while), which constandly refreshes.
Stacks are defined with newlines:
 A
 B
 C
Yes. That means that every program is structured weirdly.
Spaces are ignored unless it’s a String.
Indexes are kept for the sake of readability, which could technically make this a pointer based as well. However, the program will always run the closest index to 0
=== Commands ===
Every Command Pops itself and every affiliated entry.
If a command i.e. set or global don’t make sense, think of either the trick of pulling a rag out which out moving the dishes on it or the the compiler shuffling around everything very quickly into the temp stack and back, and if it’s in the temp stack: Too bad, don’t think about it too much.
To simplify things I will be referring the next entry as the 2nd entry, the next next entry as the 3rd entry, etc.. These are relative to each other, the indexing starts at 1(st), which is the command itself.
 Commands
print	Prints the 2nd entry 	print \n °Hello World
add 	Adds the 2nd and 3rd entries; if its a number, returns 2nd+3rd. if one of the entries is a string, concatinates them. Saves it into the 4th location like input 	add \n 1 \n 2 \n ?var
sub 	subtracts the 3rd entry from the 2nd and saves it into the 4th location like input 	sub \n 1 \n 2 \n ?var
mul 	Multiplies the 2nd and 3rd entries together and saves it into the 4th location like input 	mul \n 1 \n 2 \n ?var
div 	Divides the 2nd entry by the 3rd and saves it into the 4th location like input 	div \n 1 \n 2 \n ?var
mod 	Modulo. Saves it into the 4th location like input 	mod \n 1 \n 2 \n ?var
exp 	Takes the 2nd entry to the 3rd (2nd^3rd) and saves it into the 4th location like input 	exp \n 1 \n 2 \n ?var
sin 	Sine of the 2nd entry, saved in 3rd 	sin \n 4 \n ?var
cos 	Cosine of the 2nd entry, saved in 3rd 	cos \n 4 \n ?var
tan 	Tangent of the 2nd entry, saved in 3rd 	tan \n 4 \n ?var
# 	Is a comment 	#Everything after the Octothorp until the newline is ignored
input	Takes user input and puts it into the non relative index; accepts globals as well. Only accepts numbers. 	input \n 85
pop 	Pops the entry, who’s index is equal to the 2nd entry, not relative to the command 	pop \n 729
pto 	Like pop but pops everything until that non relative index NOTE: DOES NOT POP THAT INDEX! 	pto \n 74
pie 	pop-if-equal. essentialy pto with the 2nd entry if the 3rd entry is equal to zero 	pie \n 52 \n 0
pne 	pop-if-not-equal. pie but inverted! 	pne \n 52 \n 4
loop 	loops from itself to the desired index, forever. You can use pto to escape it 	loop \n 3 ...
while	functions like loop, but every loop checks if the 4th condition is still 0. If not, stops looping. 	while \n ?var \n 5
vram 	Sets up vram as an window you can edit. Width = 2nd entry; Height = 3rd entry. The indexing starts at the value of the 4th entry and ends at the value of the (4th + 2nd * 3rd) entries. Each entry in that space can contain a 24bit number (0x000000 to 0xffffff), which it will render.	vram \n 100 \n 100 \n 1024
=== Operators ===
* ° ; String marker
* $ ; turns the number into an ascii character string and vice versa. i.e. $?data, $°H
* \ ; Magic Characters: \° will put ° as a character.
* ? and *; explained below
==== Semivariables ====
To make this program actually useful, two types of semivariables exist:
* Pointers, defined with * i.e. *5, *306, point to that non relative index. If the entry containing the pointer is changed, the index itself will not or
* Globals, defined with ? i.e. ?john, ?johnathanthe6, act like a singular stack entry with a name.
Using quantum linking, of course.
Example with no variables:
 input 
 4
 print
 #This entry will get overwritten
Example with pointers:
 input 
 5
 print
 *5
 #This entry will get overwritten
Example with globals:
 input
 ?data
 print
 ?data
=== More Examples ===
Line count is only there for readability purposes, remove them if you want to compile them!
Hello,_world!:
 1 print 
 2 °Hello, World!
 3 end # do i have to explain
truth-machine:
 1 input # gets the user input
 2 ?val
 3 pne # -> if ?val is not equal to 0, pop
 4 9 # -> if equal, run and end
 5 ?val
 6 print # print string 0
 7 °0
 8 end # end
 9 sub # the next 4 entries have to be done otherwise you can type 2 and still indefinitely print 1
 10 ?val 
 11 1
 12 pne # pops to end if its not 0
 13 19 
 14 ?val
 15 loop
 16 18 # loops 15-18, but since its popping itself essentially loops 17-18, printing 1 indefinitely
 17 print
 18 °1
 19 end
If this is too complicated, heres one printing 1 indefinitely if the user input isnt 0. I call it the !false-machine:
 1 input # gets the user input
 2 5
 3 pie # if #placeholder is equal to 0: pop everything until 10.
 4 10 # if not run the code in the area between 3-9, and since it pops itself: 5-9.
 5 #placeholder and puts it here
 6 loop
 7 9 # loops 6-9, but since its popping itself essentially loops 8-9, printing 1 indefinitely 
 8 print
 9 °1
 10 print
 11 °0
 12 end
== Interpreter ==
An interpreter is on the way!
Category:Stack-based
Category:Graphical Output
Category:Low-level
Category:Self-modifying
Category:Languages