GridScript

GridScript is an esoteric programming language designed by user SuperJedi224. It is not yet implemented.

The program is expressed as a list of points in a two-dimensional grid, with a command assigned to each point, such as "(3,1):PRINT 42".

The main program and each subroutine (if there are any) must each contain exactly one node marked START. The program tracer starts at the center of this node, pointing east.

Data storage takes the form of a dataspace, also two-dimensional; a stack-like structure called a "Buffer", and an arbitrary number of variables.

The dataspace may only store INTs (and is initially filled with 0s), the Buffer may store any number of INTs, FLOATs, STRINGs, and/or BOOLs (and is initially empty), variables may store a single INT, FLOAT, STRING, or BOOL each.

Variables and buffer values may also store the special value NULL, and this is assumed to be the value of any variable that has not yet been assigned a value.

Basic Program Format

 * 1) TITLE.

(metadata)

(list of nodes)

With subroutines

 * 1) TITLE.

(metadata)

(list of nodes)


 * 1) SUBROUTINE 1 TITLE.

(metadata)

(list of nodes)


 * 1) SUBROUTINE 2 TITLE.

(metadata)

(list of nodes)

Command Summary
These are the commands used, with a brief description of each.

Comments
A pair of exclamation marks (!!) denotes that the rest of that line of code is a comment

Hello World

 * 1) HELLO WORLD.

@width 3 @height 1

(1,1):START (3,1):PRINT 'Hello World'

Cat Program
This program halts when either 0 or the empty string is given.
 * 1) CAT PROGRAM.

@width 11 @height 1

(1,1):START (3,1):CHECKPOINT 0 (5,1):INPUT STRING s (7,1):SWITCH !s (9,1):PRINT s (11,1):GOTO 0

Truth Machine

 * 1) TRUTH MACHINE.

@width 9 @height 5

(1,1):START (3,1):INPUT INT (5,1):GO EAST (7,1):SWITCH =1 (7,3):PRINT 1 (7,5):GO WEST (5,5):GO NORTH (9,1):PRINT 0

Alternate Version

 * 1) TRUTH MACHINE 2.

@width 7 @height 7

(1,1):START (3,1):INPUT INT (5,1):SWITCH =1 (5,3):CHECKPOINT 0 (5,5):PRINT 1 (5,7):GOTO 0 (7,1):PRINT 0

99 Bottles of Beer on the Wall

 * 1) 99 BOTTLES OF BEER.

@width 7 @height 39

(1,1):START (3,1):STORE 99 (5,1):GO EAST (7,1):GO SOUTH (7,3):PRINT (7,5):PRINT " bottles of beer on the wall," (7,7):PRINT NEWLINE (7,9):PRINT (7,11):PRINT " bottles of beer." (7,13):PRINT NEWLINE (7,15):PRINT "Take one down and pass it around," (7,17):PRINT NEWLINE (7,19):SWITCH =1 (7,21):PRINT (7,23):PRINT " bottles of beer on the wall!" (7,25):DECREMENT (7,27):GO WEST (5,27):GO NORTH (5,25):PRINT NEWLINE (5,23):PRINT NEWLINE (3,19):GO SOUTH (3,21):PRINT "1 bottle of beer on the wall!" (3,23):PRINT NEWLINE (3,25):PRINT NEWLINE (3,27):PRINT "1 bottle of beer on the wall," (3,29):PRINT NEWLINE (3,31):PRINT "1 bottle of beer" (3,33):PRINT NEWLINE (3,35):PRINT "Take one down and pass it around," (3,37):PRINT NEWLINE (3,39):PRINT "No more bottles of beer on the wall."

Factorial

 * 1) FACTORIAL.

@width 14 @height 8

(1,3):START (7,1):CHECKPOINT 0 (3,3):INPUT INT TO n (5,3):STORE n (7,3):GO EAST (9,3):DECREMENT n (11,3):SWITCH n (11,5):MULTIPLY BY n (11,7):GOTO 0 (13,3):PRINT

Fibonacci Sequence
(Only stores 10,000 terms at a time)
 * 1) FIBONACCI SEQUENCE.

@width 37 @height 1 @datawidth 10000 @dataheight 1

(1,1):START (3,1):STORE 1 (5,1):NEXT VALUE (7,1):STORE 1 (9,1):NEXT VALUE (11,1):PRINT "1 1" (13,1):CHECKPOINT 0 (15,1):PREVIOUS VALUE (17,1):PREVIOUS VALUE (19,1):STORE TO a (21,1):NEXT VALUE (23,1):STORE TO b (25,1):INCREMENT a BY b GIVING c (27,1):PRINT " " (29,1):NEXT VALUE (31,1):STORE c (33,1):PRINT (35,1):NEXT VALUE (37,1):GOTO 0

Ackermann Function

 * 1) ACKERMANN FUNCTION.

@width 9 @height 1

(1,1):START (3,1):INPUT INT TO x (5,1):INPUT INT TO y (7,1):CALL ACK WITH ARGUMENTS x y (9,1):PRINT


 * 1) ACK.

@width 19 @height 7

(1,1):START (3,1):INPUT INT TO x (5,1):INPUT INT TO y (7,1):SWITCH !x (7,3):INCREMENT y (7,5):RETURN y (9,1):SWITCH !y (9,3):DECREMENT x (9,5):CALL ACK WITH ARGUMENTS x 1 (9,7):RETURN (11,1):DECREMENT y (13,1):CALL ACK WITH ARGUMENTS x y GIVING z (15,1):DECREMENT x (17,1):CALL ACK WITH ARGUMENTS x z (19,1):RETURN

External resources

 * Source specification (Google Docs)