esolang

Scotty

A language made to be easy to tokenize. Split each line on spaces and the first word says what it is.

2016 · Turing complete: no · ●○○ easy · esolangs.org

Tested with 5 known programs · Test method

Run it

Expected: 2

The idea

Scotty was made in the spring of 2016 for a course on programming languages, so that students could build an interpreter without a lexer. Every line splits on spaces, and its first word tells the kinds of line apart. The last line is a prefix expression, and its value is the program's output.

Read the story

The lines before it define variables and functions. A function takes exactly one parameter, by value, and it cannot see any variable outside itself. There is no condition anywhere, so a function that calls itself never comes back.

The machine

LineMeans
name = eA variable
fun name x = eA function of one parameter
eThe last line, whose value is printed
ExpressionMeans
+ e e - e e * e e / e eArithmetic, in prefix
( name e )Call a function
x 3 -2 0.5A variable or a number

Each token needs a space on both sides, brackets too. The specification gives no outputs, so this implementation prints each value plainly, with no decimal point on whole numbers.

Example

Functions calling functions, from the specification.
Expected: 3

Functions calling functions, from the specification. cube uses square, and the variable is passed in from the last line, since the functions could not read it themselves.

Expected: 27

Division is exact, as the grammar allows decimal numbers.

Expected: 3.5

Further

Educational

Write your own in Run Convert a program from Scotty

Implementation

JavaScript interpreter, source and command line

A JavaScript interpreter, used in the browser and on the command line. Id: scotty.

Command line

shib run scotty -e '+ 1 1'
shib manual scotty

Source

Module
langs/wiki/ports.js
Interpreter
langs/wiki/scotty.js

Docs: Kernel instructions · The .shib format · Command line · Adding a language

Source esolangs.org (CC0) · Edit on esolangs.org