Scotty

History
Scotty is an educational esoteric language created in the Spring of 2016 for a course on programming languages. It is an imperative language with a syntax that is incredibly easy to tokenize, making it relatively easy to implement language features without needing to perform any lexical analysis of the input.

Description
Programs in this language can be split into lines. The final line of the program is a prefix expression, where the result of the evaluation of that expression is the output of the program. The language definition includes variables and functions, which are defined on the first n - 1 lines of the program. Each function can take exactly one parameter, and that parameter is passed by value. Functions cannot access variables outside of the local scope of the function.

Each line of the program can be split on spaces, and each command is uniquely identified by the first token of the expression.

Grammar
 ::=  |   |      ::= =         ::= fun  =     ::= +     | -    | *  <prefix_exp>  | / <prefix_exp> <prefix_exp>  | ( <prefix_exp> ) | |   ::= <id_tail> | <id_tail>      ::= <id_tail> | <id_tail> | | ::= - |        ::=  | . |          ::= (0 .. 9)        ::= ('A'..'Z') ++ ('a'..'z')

Simple Numeric Evaluation
+ 1 1

With Variable Assignment
x = + 1 1 + x 1

With Function Definition
fun square x = * x x ( square 3 )

Functions within Functions
fun square x = * x x fun cube x = * ( square x ) x ( cube 3 )

Functions and Variables
fun square x = * x x fun cube x = * ( square x ) x something = 3 ( cube something )

Interpreter
Scotty interpreter written in Haskell

The above interpreter does absolutely NO checking of the input program. It assumes that the code provided is a valid Scotty program. Obvious future work is to add syntax checking to the program.