DateTri
DateTri is an esolang by User:BoundedBeans which is designed to look like an old programming language, as well as showing off three different definitions of the word "Date".
Data types
There are three data types: date, date, and date.
Date
This represents a calendar date. Definitions of these are started with DAY and ended with MIDNIGHT. Here is what a date definition looks like (the date used has no particular significance):
10 DEFINE /A AS A DATE: DAY 20 ..YEAR='2019' 30 ..MONTH='FEB' 40 ..DAY='12' 50 MIDNIGHT
YEAR
should be a 32-bit unsigned number.
MONTH
should be one of:
JAN
FEB
MAR
APR
MAY
JUN
JUL
AUG
SEP
OCT
NOV
DEC
DAY
should be a number between 1 and 31. Note that there is absolutely no issue with using dates that don't exist; February 30th exists in this language.
Date
This represents a romantic night out. Definitions of these are started with OUTING and ended with BREAKUP. Here is what a date definition looks like:
60 DEFINE /B AS A DATE: OUTING 70 ..DAY='/B' 80 ..LOCATION='COFFEE SHOP' 90 ..BLIND='NO' 100 BREAKUP
DAY
should be the name of a date variable. It makes a copy of the variable, if the original variable changes, DAY
doesn't. (Although it's not really accessible other than with EXTRACT
). If DAY
uses the transfer format, the DAY
will be transferred, although it does not need to be copied, since neither DAY
variable is directly modifiable.
LOCATION
should be one of:
COFFEE SHOP
FANCY RESTAURANT
MOVIE THEATER
BLIND
should be either YES
or NO
.
Date
This represents the fruit. Definitions of these are started with FRUIT
and ended with WINTER
. Here is what a date definition looks like:
110 DEFINE /C AS A DATE: FRUIT 120 ..ROTTEN='NO' 130 WINTER
ROTTEN
should be either YES
or NO
. Dates function as booleans, sort of.
Syntax
All lines should start with a line number, followed by a required space. The line numbers run in increasing order. Note that everything has a line number, including field initialization lines and even function definitions. There is nothing stopping you from jumping inside of a function from outside.
Definitions
Each line inside of the definition still starts with the line number and space, but after that comes two periods. After that, the line should contain something of the form NAME='VALUE'. The name and value must be valid for the type. The right part can also be [(field name) OF (variable name)]
to transfer data. Note that the DAY
field of an OUTING
must be literally a string containing the variables name, meaning it cannot be transferred (nowhere else allows a slash). It will, however, be copied automatically from the variable, if it happens to be of type DAY
.
Commands
GOTO (line number)
|
Similar to basic. |
IF (field name) OF (var name) (IS|ISNT) (value in single quotes) : (line number)
|
Conditional goto. |
DEFINE (var name) AS A DATE: (type)
|
Follow with a definition for variable initialization. The name can be up to four characters, which may be either uppercase letters or a hyphen. The name must always be preceded by / in every situation.
|
OUTPUT (var name)
|
Prints something to the console depending on the value of the variable. The format is implementation dependent. |
PROCEDURE (name in single quotes) (square bracket enclosed space-separated list of parameter names)
|
Starts a function. The parameters will be defined as local variables. There are no global variables. The variables outside of a function are not accessible from within; they must all be passed as parameters. This command is just a jump point for CALL and is a no-op when encountered normally. Typically, you should use a GOTO to skip it.
|
EXIT
|
Ends a function. Whatever value was in the local variable /RE will be returned, including its stack.
|
CALL (function name in single quotes) (square bracketed space-separated list of variable names for the parameters) [ON (variable name)]
|
Calls a function with parameters, including their stacks. If an ON clause is specified, the return value will be stored in the variable, including its stack. |
ADD (field name) OF (variable name) TO (field name 2) OF (variable name 2)
|
Adds the first to the second, stores result in the second. Both must be either a YEAR of a DAY or a DAY of a DAY .
|
SUBTRACT (field name) OF (variable name) TO (field name 2) OF (variable name 2)
|
Subtracts the first from the second, stores result in the second. Both must be either a YEAR of a DAY or a DAY of a DAY .
|
MULTIPLY (field name) OF (variable name) TO (field name 2) OF (variable name 2)
|
Multiplies the first by the second, stores result in the second. Both must be either a YEAR of a DAY or a DAY of a DAY .
|
DIVIDE (field name) OF (variable name) TO (field name 2) OF (variable name 2)
|
Integer divides the second by the first, stores result in the second. Both must be either a YEAR of a DAY or a DAY of a DAY .
|
EXTRACT (variable name) TO (variable name 2)
|
The first must be an OUTING variable. The DAY field will be copied and moved to the second.
|
BURY (variable name)
|
Acts identically to STASH in INTERCAL. (Pushes the variable's value to its own private stack.)
|
DIG UP (variable name)
|
Acts identically to RETRIEVE in INTERCAL. (Pops and sets the variable's value from its own private stack.)
|
PRINT ASCII (variable name)
|
The variable must be a DAY . The year will be taken modulo 256 and printed to the console as an ascii character.
|
PRINT NUMERIC (variable name)
|
The variable must be a DAY . The year will be printed to the console as a decimal number.
|
READ ASCII (variable name)
|
The variable will be changed to a DAY containing: YEAR=(the input as an ascii character to its code),MONTH='JAN',DAY='1'. (Note that this is not valid code.)
|
READ NUMERIC (variable name)
|
The variable will be changed to a DAY containing: YEAR=(the input as a number),MONTH='JAN',DAY='1'.
|
NOTE (any text) |
Comment |
Examples
Truth-machine
10 READ NUMERIC /VAL 20 DEFINE /ONE AS A DATE : DAY 30 ..YEAR='1' 40 ..MONTH='JAN' 50 ..DAY='1' 60 MIDNIGHT 70 DEFINE /ZERO AS A DATE : DAY 71 ..YEAR='0' 72 ..MONTH='JAN' 73 ..DAY='1' 74 MIDNIGHT 80 IF YEAR OF /VAL IS '1' : 100 90 IF YEAR OF /VAL IS '0' : 200 100 PRINT NUMERIC /ONE 110 GOTO 100 200 PRINT NUMERIC /ZERO
Hello world!
10 DEFINE /H AS A DATE : DAY 20 ..YEAR='72' 30 ..MONTH='JAN' 40 ..DAY='1' 50 MIDNIGHT 60 DEFINE /E AS A DATE : DAY 70 ..YEAR='101' 80 ..MONTH='JAN' 90 ..DAY='1' 100 MIDNIGHT 110 DEFINE /L AS A DATE : DAY 120 ..YEAR='108' 130 ..MONTH='JAN' 140 ..DAY='1' 150 MIDNIGHT 160 DEFINE /O AS A DATE : DAY 170 ..YEAR='111' 180 ..MONTH='JAN' 190 ..DAY='1' 200 MIDNIGHT 210 DEFINE /SPAC AS A DATE : DAY 220 ..YEAR='32' 230 ..MONTH='JAN' 240 ..DAY='1' 250 MIDNIGHT 260 DEFINE /W AS A DATE : DAY 270 ..YEAR='119' 280 ..MONTH='JAN' 290 ..DAY='1' 300 MIDNIGHT 310 DEFINE /R AS A DATE : DAY 320 ..YEAR='114' 330 ..MONTH='JAN' 340 ..DAY='1' 350 MIDNIGHT 360 DEFINE /D AS A DATE : DAY 370 ..YEAR='100' 380 ..MONTH='JAN' 390 ..DAY='1' 400 MIDNIGHT 410 DEFINE /EXCL AS A DATE : DAY 420 ..YEAR='33' 430 ..MONTH='JAN' 440 ..DAY='1' 450 MIDNIGHT 460 PRINT ASCII /H 470 PRINT ASCII /E 480 PRINT ASCII /L 490 PRINT ASCII /L 500 PRINT ASCII /O 510 PRINT ASCII /SPAC 520 PRINT ASCII /W 530 PRINT ASCII /O 540 PRINT ASCII /R 550 PRINT ASCII /L 560 PRINT ASCII /D 570 PRINT ASCII /EXCL
Deadfish
10 DEFINE /ANGL AS A DATE : DAY 20 ..YEAR='62' 30 ..MONTH='JAN' 40 ..DAY='1' 50 MIDNIGHT 60 DEFINE /LF AS A DATE : DAY 70 ..YEAR='10' 80 ..MONTH='JAN' 90 ..DAY='1' 100 MIDNIGHT 110 DEFINE /ACC AS A DATE : DAY 120 ..YEAR='0' 130 ..MONTH='JAN' 140 ..DAY='1' 141 MIDNIGHT 150 PRINT ASCII /ANGL 160 PRINT ASCII /ANGL 170 READ ASCII /OP 180 PRINT ASCII /LF 200 IF YEAR OF /OP IS '105' : 300 210 IF YEAR OF /OP IS '100' : 400 220 IF YEAR OF /OP IS '115' : 500 230 IF YEAR OF /OP IS '111' : 600 240 IF YEAR OF /OP IS '104' : 700 300 ADD DAY OF /ACC TO YEAR OF /ACC 310 GOTO 800 400 SUBTRACT DAY OF /ACC TO YEAR OF /ACC 410 GOTO 800 500 MULTIPLY YEAR OF /ACC TO YEAR OF /ACC 510 GOTO 800 600 PRINT NUMERIC /ACC 610 GOTO 800 700 GOTO 1000 800 IF YEAR OF /ACC IS '-1' GOTO 900 810 IF YEAR OF /ACC IS '256' GOTO 900 820 GOTO 150 900 DEFINE /ACC AS A DATE : DAY 910 ..YEAR='0' 920 ..MONTH='JAN' 930 ..DAY='1' 940 MIDNIGHT 950 GOTO 150 1000 NOTE Halting point.