VIOLET
VIOLET (Verbose Interactive Operating Language for Educational Terminals) is an interpreted programming language alleged to have been the custom onboard language developed for a 1980s educational computer, the Buttech CAI-1.
An interpreter for VIOLET written in Python is included as part of the BlueBox library, itself a graphics library for producing a basic retro terminal interface.
History
According to the VIOLET and BlueBox documentation, VIOLET was created by a community college intern in a matter of days as a hasty replacement for rejected BASIC and PILOT proposals, and cobbled together from bits of other languages from FORTH to LISP.
Basic Operation
All VIOLET programs are composed of operator statements, which take arguments, and return their values to a built in value named &LAST. Each line can only contain one operator, save for the IFY/IFN operators, which may call a sub operator if they are successful. Variables are strictly typed, and their values can only be changed by the SET operator. Flow control is in the form of an IF/IFY/IFN operator set similar to PILOT C:/CY:/CN:, as well as a WHILE/WHEND loop, and the dreaded GOTO statement, here particularly problematic because line numbers aren't hard set but based on file position.
Because the VIOLET interactive editor can also handle arbitrary text files, the interpreter first checks any file sent to it for a PROGRAM START clause at the beginning, and a PROGRAM STOP clause at the end.
Sample Code
Taken from the included samples in the repository:
PROGRAM START IGNORE HELLO WORLD IGNORE PROMPT $ "WHAT IS YOUR NAME: " SET $NAME &LAST ADD "HELLO " $NAME "." PRINT &LAST PROGRAM STOP
PROGRAM START IGNORE EXPONENT CALCULATOR IGNORE PRINT EXPONENT CALCULATOR PRINT PLEASE USE WHOLE NUMBERS ONLY PROMPT # "BASE: " SET #BASE &LAST PROMPT # "EXPONENT: " SET #EXP &LAST SET #TOTAL 1 SET #X 0 WHILE LESSER #X #EXP MULT #TOTAL #BASE SET #TOTAL &LAST ADD #X 1 SET #X &LAST WHEND PRINT "YOUR TOTAL IS: " #TOTAL PROGRAM STOP
PROGRAM START IGNORE FACTORIAL SOLVER IGNORE PRINT "FACTORIAL SOLVER" PRINT "PLEASE USE WHOLE NUMBERS" SET #RUN 1 WHILE EQUALS #RUN 1 PROMPT # "ENTER NUMBER: " SET #X &LAST SET #Y #X SET #TOTAL 1 WHILE GREATER #Y 0 MULT #TOTAL #Y SET #TOTAL &LAST SUB #Y 1 SET #Y &LAST WHEND PRINT #X "! = " #TOTAL PROMPT $ "RUN AGAIN? " IF EQUALS &LAST "YES" IFY SET #RUN 1 IFN SET #RUN 0 WHEND PROGRAM STOP
External resources
- BlueBox - A graphics library for simulating the appearance of CAI-1 applications. Includes violet.py, a VIOLET interpreter in Python 2.7.
- The VIOLET Programming Language - The only known documentation for the VIOLET language. (Possibly still incomplete.)