Notes From James
Home | About | Find Stuff | Download
The Rev Programming Language   James - Wednesday, September 13, 2017, 9:02 pm

This is a description of a programming language I am working on, Rev, based on the Mouse Programming Language by Peter Grogono, originally written in 1979. This language is not compatible with Mouse, but is based on it and shares many common concepts with it. See Wikipedia for details on Mouse.

Some of the operation (#, for example) differ in the order of operations, and others (^) have differences to be more "C" like.

Symbol Description
(space) No action.
$ End the program. Not necessary, unless the program needs to exit immediately.
(number) Number. Push a number onto the stack.
+ Add. Pop two operands from the stack and push their sum.
- Subtract. Pop two operands from the stack and push their difference. 3 2 - results in 1.
* Multiply. Pop two operands from the stack and push their product.
/ Divide. Pop two operands from the stack and push their quotient. 9 3 / results in 3.
% Remainder (modulus). Pop two operands from the stack and push the remainder of the first divided by the second.
? Input number. Read a number from the keyboard and push it onto the stack.
?' Input character. Read a character from the keyboard and push its ASCII code onto the stack.
! Output number. Pop a number from the stack and display it on the terminal.
!' Output character. Pop an ASCII code from the stack and display the corresponding character on the terminal.
'(char) Character literal. Push the ASCII code corresponding the the character onto the stack.
" Output string. Display each character between the " and the next " on the terminal. Translate the character ! to a new line.
(letter) Declare a variable and push the name onto the stack. The value pushed on the stack will vary depending on nesting level.
: Assignment. Pop two operands from the stack and store the value of the second at the address specified by the second. To assign 3 to x, use "3 x:" (no quotes)
. Dereference. Pop an address from the stack and push the value stored at that address onto the stack.
< Comparison. Pop two operands from the stack. If the first is less than the second, push 1, else push 0 onto the stack.
= Comparison. Pop two operands from the stack. If they are equal, push 1, else push 0 onto the stack.
> Comparison. Pop two operands from the stack. If the first is greater than the second, push 1, else push 0 onto the stack.
[ Conditional. Pop a value from the stack. If it is zero, skip over the character until a matching ] is found.
] Matches opening bracket
( Start loop. No action.
) Go back to top of loop.
^ Pops a value; if it is nonzero, exit loop.
(letter)# Call a function. To call function 'a', type 'a#'.
@ Return early from a function
(letter){ Start of function named letter.
} End of function
~ Start of comment. Comment goes until end of line.
_ Allocate memory

Other references:

Peter Grogono's Mouse webpage

David Simpson's Mouse software

Lee Bradley's Mouse page