Tiny

Tiny is a small floating point RPN based language created by User:Ron.hudson. It is a console/character type interpretive programming language, in which all statements are either assignments or those that print quoted strings.

Syntax
Each line consists of a floating point line number, followed by any number of commands. Line numbers must be floating point numnbers and may have up to 3 digits to the right of the decimal point. The number can have leading zeros. The commands are: "print this string" [calculates an expression] stores the result into one or more variables : The third command is an assignment, and the fourth command ends the program. Multiple commands can be written on the same line. Escape sequences are allowed inside quoted strings (\n (newline), \e (ASCII 0x1B), \t (tab), \", \\).
 * 1) comment to end of line

Expressions are written in Reverse Polish notation, and can use the following operators: + - * / % ^ Arithmetic (add, subtract, multiply, divide, remainder, raise to a power) < > = Comparison (less than, greater than, equal to;                  returns 1 for true, 0 for false) & | ! Logical (and, or, not; uses 1 for true and 0 for false) The stack is dynamic.

Variables
There are three types of variables:
 * a to z. These are floating point numbers.
 * Array members. There is one array, which is sized at compile time. An array element is specified by enclosing an expression in parens. The value of the expression is taken as an index into the array.
 * Special variables. These are used for I/O, storage, and program control, and have names which are punctuation marks.

Special variables
The following special variables are available:
 * @ The current execution step. Assigning a value to this, other than 0, causes a jump to the line with the number that has been assigned at the end of the line currently running. All elements in the line complete before the jump is taken. Assigning 0 has no effect. Reading from this (before it is assigned) gives the line number of the next line (Useful as a subroutine return address)
 * $ Storage stack. Assigning to $ pushes a number onto the stack; reading from it pops a number from the stack and returns it. The main use for the stack is to store subroutine return addresses. [@]$ [subroutine line number] @  to call a subroutine and [$]@  to return from one.
 * ? Numeric I/O. Reading from ? inputs a number, and writing to it outputs a number. If a null string is entered by the user, 0 is returned.
 * ~ Random number. Reading returns a random number, and writing seeds the random-number generator (with the number given, or with the system time if 0 is given).

Example
0100.00 #squares to 42 0110.00 [?] x 0120.00 [x] ? " Squared is : " [x 2 ^] ? "\n"  [x 42 = ! 110.00 *] @ 0130.00 "Thanks for trying Tiny! \n\n" 0140.00 :

Line 100.00 is a comment.

Line 110.00 waits for user numeric input, reads it, and then stores it in the variable x.

Line 120.00 prints x, prints a string, prints x squared, prints a newline, then tests x; if x is not equal to 42, it goes to line 110. (It stores 0 in @ if x is 42; or 110 in @ if x is not 42; storing 0 in @ has no effect.)

Line 130.00 prints a string.

Line 140.00 ends the program and stops execution.

Computational class
Due to the limits on the range of a variable, Tiny cannot be Turing-complete; the array is effectively finite, as only a finite number of elements can be indexed (due to the range of the variables a-z). The $ stack is infinite; however, there is only one $ stack, which is not enough for Turing-completeness (there is no temporary storage for a bignum anywhere else). Every Tiny program is a (random, if you use ~) push-down automaton. Because jump target line numbers are also limited in size, Tiny can probably not simulate PDAs with arbitrarily many states. The amount of memory available is likely to prove adequate for most programs.

External resources
Geocities is being closed by Yahoo, I am looking for a new place to host fltiny. In the mean time check my user page for info on how to get your copy.


 * Now at the 99-bottles-of-beer site!

Plans and possible extensions
Line Number Sorting.. Line number sorting has been handled by Bruce Hudson (My brother). Line numbers are now used to sort the program in both executive and interactive mode.

right now you have to say "0 5 -" if you mean -5.

This has changed use the "_" underbar to finish a number and change its sign

Some form of file i/o might be nice.

Since every element of tiny is one character long, The only ones free at the moment are ; {} and, I have not used any of the extended characters because I want to be able to run tiny from a terminal connected to my Linux server.

What can I use  ;  and, for? got any ideas?

I suppose a drop command would be good, it would even work outside the [,] of an expression (actually all the operators do [ and ] mainly control reading vs. storing. )

In floating point tiny the list of unused is ; ,

Recently a friend who goes by the handle "Comet" brought up an idea - self modifying programs. Using perhaps ";" I would take array elements as ASCII characters and have tiny act as though the line were typed in at the console parsing line number and code.

Or perhaps it's time to use the curly brackets: {c} where c is some code flag-character

{o filename.ext} change output stream to file {o} to restore

{i filename.ext} change input stream to file {i} to restore

{p "5 [x]?"} Parse string into program, adding or replacing line 5

{s filename.ext} Write the current program out to filename.

{?} Reads a string from input and places each char in the array starting at 1

Has possibilities.

Announcing Floating Point Tiny
Integer Tiny is not currently available... for now.

Floating point tiny is now available at my geocities website. New note: Geocitites is closing... see below.

The Stack, Variables and array are all now floating point. '%' is an integer function. Line numbers are floating point and are displayed to 4 decimal places. The Random Number is floating point and is in the range {0 <= ~ < 1}.

Since the period is needed as a decimal point, the stop program command is now the ":"

Latest Updates to Tiny
Added {# comments }

Tiny reads and writes to files now!

Open filename to receive output instead of stdout


 * {o+ filename} open a filename for append
 * {o- filename} open a filename for replace
 * {o*} Closes filename and selects stdout

Open a filename to replace stdin for inputs


 * {i+ filename} open filename
 * {i* }         return to stdin

String I/O: Tiny can read and print strings:
 * [{?}]         Read a string into the array
 * [ ] {?}       Print the array as a string

Strings are placed converting character by character into array elements starting at element 1, up to element 80. element 0 is left alone and no element beyond 80 is changed.

Tiny can do math.h mathematical functions: {f functionname} where function name is:

SIN, TAN, ACOS, ASIN, ATAN, ATAN2, COSH, SINH, TANH, EXP, FREXP, LDEXP, LOG, LOG10, MODF, POW, SQRT, CEIL, FABS, FLOOR, FMODCOS, SIN, TAN, ACOS, ASIN, ATAN, ATAN2, COSH, SINH, TANH, EXP, FREXP, LDEXP, LOG, LOG10, MODF, POW, SQRT, CEIL, FABS, FLOOR, FMOD

A plea
I seem to have misplaced the source for fltiny.c If any of you have downloaded it please contact me so I can get a copy from you my email address is obfuscated in my user page Ron.hudson