Pronounced tools-whack, TEWELSWAC is an idea for a programming language by User:Timtomtoaster. As you can see, I'm not great at naming things (look at eWagon). The name stands for The Esolang Where Every Line Starts With A Colon. I will likely implement it in the future, but you can make an interpreter/compiler too!
Not all of this is guaranteed to be implemented in the final version, or implemented at all. Please don't write any big programs until an interpreter is written! It will save you a lot of pain "converting" from this to the real language.
Every line of code is like this:
When no condition is specified, the line is executed no matter what. All whitespace is supported.
; is used to separate commands. Newlines after this are not necessary.
Labels are used mainly for
GOTO statements. The condition specifies whether or not that line of code will be executed.
Variables are defined by the
SET command, which will be explained further in the Commands section of this page. To use the value of a variable as an arguments or condition, put a dollar sign before it. The only time you use only the variable's name is when you use commands that modify its value.
The memory for TEWELSWAC is a list of values. This is only used for variables. To point to a "physical" location in memory, use
*location. At the beginning of each program, type
MEMSIZE size. If this appears anywhere else in the code, it will clear the memory and re-initialize it with the specified size. Numbers only take up one cell, but strings are stored as several numbers plus an end character, so take this into consideration when defining the memory size.
Expressions are used within lines of code as conditions or arguments. They are enclosed in
s. An example of an expression is
[4 > 5] or
[$A + 5]. The expression will return the value represented by what's in the square brackets. A
! will get numerical input, and
@ will get string input. YOU CAN'T NEST THESE (unless you can write an interpreter that supports that, since I can't).
Capitalization isn't necessary.
||Create a new variable. The type is auto-detected (int, float, or string). If |
||Assign a new value to a variable.|
||Skip to another line.|
||Print something with a newline after it.|
||Print something without a newline.|
||Set the memory to the given size.|
||Don't do anything.|
||End the program.|
1:MEMSIZE 0; LOOP:PRINT [@]; 3:GOTO LOOP;
1:MEMSIZE 3; 2:NEW A; 3:NEW B IS 1; 4:NEW C; LOOP: PRINT $A; 7:SET C [$A + $B]; 8:SET A $B 9:SET B $C; 10:GOTO LOOP;
1:MEMSIZE 1; 2:NEW A IS [!]; 3:([$A = 1]) GOTO TRUE; 4:([$A = 0]) GOTO FALSE; TRUE:PRINT 1; 6:GOTO TRUE; FALSE:PRINT 0; 7:END;
1:MEMSIZE 40; 2:NEW BOTTLES IS 99; 3:NEW A IS " bottles of"; 4:NEW B IS " beer"; 5:NEW C IS " on the wall"; 6:NEW D IS "No more"; LOOP1:NOP; LOOP2:SHOW $BOTTLES; 9:SHOW $A; 10:SHOW $B; 11:SHOW $C; 12:PRINT "."; 13:SHOW $BOTTLES; 14:SHOW $A; 15:SHOW $B; 16:PRINT "."; 17:PRINT "Take one down, pass it around."; 18:SET BOTTLES [BOTTLES - 1]; 19:SHOW $BOTTLES; 20:SHOW $A; 21:SHOW $B; 22:SHOW $C; 23:PRINT "."; 24:([$BOTTLES > 0]) GOTO LOOP2; 26:SHOW $D; 27:SHOW $A; 28:SHOW $B; 29:SHOW $C; 30:PRINT "."; 31:SHOW $D; 32:SHOW $A; 33:SHOW $B; 34:PRINT "."; 35:PRINT "Go to the store, buy some more."; 36:SET BOTTLES 99; 37:SHOW $BOTTLES; 38:SHOW $A; 39:SHOW $B; 40:SHOW $C; 41:PRINT "."; 42:GOTO LOOP1;