User:Not applicable/Sandbox

From Esolang
Jump to navigation Jump to search
Return to my page
Notice:
The contents of this sandbox are likely to change wildly. These are more for me testing out language ideas and stuff like that.


Languages occupying this sandbox:

Languages that will soon be occupying this sandbox:
  • SET
  • Objectification
  • DO






**This is some filler to separate the top part from the body**





stupidExpr

Return to top

stupidExpr is a programming language that is part of the stupid programming language family. Unlike it's equally stupid counterpart, stupidc, it does not use a system of prefixes, instead insisting that everything is a function (even variables!), which results in a program just being a giant equation. This is, in a sense, similar to Lisp (Wikipedia).

There are four "forms" of equations:

  • Operators are used for comparison, assignment, math, etc. These are defined with parenthesis (( )). Example: (a >= 10);, (a ++ 1);
  • Equations are used for putting the result of an expression into a function, executing the equation first then the function. These are defined with square brackets ([ ]). Example: print: [ (a = 10); return: a; ];
  • Routines are used for inputting an expression as an argument into a function, executing the function first then the routine. These are defined with braces ({ }). Example: loop: { print: "Hi\n"; };
  • Functions are routines or variables. They are used when the parser cannot match the first character to one of the bracket types. Example: print: "Hello!";

[1]

Every program has a variable called RESULT that defines the code to run on start. Like any other variable, it is defined as so:

(RESULT = [
    Your code here...
]);

Now, let's make it do something. How about, a hello world? To do that, we use the print function:

(RESULT = [
    print: "Hello, World!\n";
]);

That's more like it! How about we throw in some input?

(RESULT = [
    print: "Hello, World!\n";
    print: "What is your name?\n";
    print: "You said, ", [ask;];
]);

stupidZM

(name still pending)Return to top

stupidZM is an esoteric programming language designed similarly to many BASIC dialects, but also similar to Z-Machine code.

Syntax

Argument types

There are four types of arguments in stupidZM. They are:

  • Statements, such as with, as, or for. These modify what the command does and what arguments it parses.
  • Constants, such as 3 or "Hello!".
  • Operators, such as [thisvar+thatvar], [thisarr@thispos], or [this$+"Hi"]. These substitute an argument for whatever result the operation has.
  • Anything else will be matched as a variable.

Statements

Statements modify what the command does. Each command has different statements and in each instance, they do different things. For example, in ask "Will you marry me?" as string, as will tell the parser that the next argument is a data type, in this case, string, and will be used as so. However, if we were to use ask "Will you marry me?" with "Yes" "No", the statement with tells us that the next arguments are possible inputs for the user.

Constants

Constants are denoted by whether the first character is a number, or double quotes ("). For example, in say "Hello!" will print "Hello" to the screen, and say 123 will print "123" to the screen. However, using say 123Hello! will simply print "123" to the screen, as that is the behavior of VAL in QB, because it is looking for a number and found letters. In the future, I might add a thing that deals with this properly, but that will be for later.

Operators

The = operator

In stupidZM, there's an accumulator. By default, commands store their output in it. For example, ask "How are you?" as string would put the output of that in the accumulator, so if the user responds with "Good", then the accumulator will have "Good" in it. However, it is possible to store the output of the command as a variable without even touching the accumulator by appending the command with =, like so: ask "How are you?" as string = myvar Now, if the user responds with "Good", myvar will contain "Good" in it and the accumulator will remain untouched.


main thing
	ask "" with 0 1
	if 1
		loop; say "1"; .
	.
	if 0
		exit
	.
.

main helloworld
	say "Hello, world!"
.

main cat
	loop
		lastkey -> print
	.
.

main deadfish
	ask "Program:" = program
	
	loop
		get program from i to [i+1]
		choose
			if "i"; [a+1] = a; .
			if "d"; [a-1] = a; .
			if "o"; print a; .
			if "s"; [a*a] = a; .
			otherwise; say ""; .
		.
		[i+1] = i
		if [[a=0]|[a=255]]; 0 = a; .
		length program -> if < i; stop; .
	.
.

main calc
	loop
		ask "Number 1 = " as float = num1
		ask "Number 2 = " as float = num2
		ask "Operation: " with "+" "-" "/" "*" "%"
		print "$num1$ $$ $num2$ = "
		choose
			if "+"; [num1+num2] = res; .
			if "-"; [num1-num2] = res; .
			if "/"; [num1/num2] = res; .
			if "*"; [num1*num2] = res; .
			if "%"; [num1%num2] = res; .
		.
		say "$res$"
	.
.

main brainfuck
	define data as list
	ask "Program: " = program
	loop
		(data@p) = a
		get program from i to [i+1]
		choose
			if "+"; [a+1] = a; .
			if "-"; [a-1] = a; .
			if ">"; [p+1] = p; .
			if "<"; [p-1] = p; .
			if "]"; loop
					get program from i to [i+1]
					if "["; break; .
					[i-1] = i
			.; .
			if "."; print a; .
			if ","; lastkey = a; .
		.
		[i+1] = i
		[a%255] = [data@p]
		length program -> if < i; stop; .
	.
.

main itemdemo
	// loose says that case doesn't matter, and automatically trims inputs"
	define items as loose list
	loop
		ask "What do you do?" = line
		word 0 of line = action
		word 1 until end of line = argument
		choose
			if "inventory"
				say "Items in your inventory:"
				list items with "$!ITEM!$\n"
			.
			if "help"; say help; .
			if "grab"
				add argument to items
				say "You grabbed the $argument$"
			.
			if "drop"
				echo argument -> if in items
					drop argument from items
					say "You dropped the $argument$"
				. otherwise
					say "You don't have the $argument$"
				.
			.
		.
	.
.

main intro
	say "Programs:"
	list !mains! with "$!ITEM!$\n"
	ask "Which program do you want to run?" with !mains! -> run main #
.

Template

Return to top

Body goes here