Thube

Thube (pronounced "TOO-bee") is a badly-named esoteric programming language and derivative of Thue designed by the Zodiac Working Group as an attempt to pull Thue out of the Turing Tarpit. It aims to implement high-level features into Thue like File Handling, libraries, and maybe a bit of OO.

This document is a Work In Progress.

Syntax
Thube uses a different syntax from traditional Thue. For starters, the entire format is different. Thube programs consist of a series of subprograms which consist of a name followed by an opening curly bracket, the subprogram, then a closing curly bracket.

 { stuff; stuff; ...    stuff; }

The subprograms are:


 * use: A list of libraries to use. Names separated by semicolons.
 * objects: A series of objects created for usage later (such as sockets)
 * rules: A series of rules dictating replacement strings.
 * strings: Quoted strings separated by semicolons. The Thube interpreter executes the rules on these in sequence.

Rules in Thube go in the "rules" block and have a slightly different design. For starters, strings must be enclosed in single or double quotes (matching). These strings are operated on by either A) Putting them alone (for nonary) B) prefixing them with the operator (for unary) or C) putting them on either side of the operator (for binary). Operators are either single characters outside of strings OR multiple character contained in curly brackets (though single characters in curly brackets work just the same). Any characters can be an operator, which may be hard to implement in some languages.

A rule is defined by the following syntax ::= ; Basically, the same as in normal Thue, but with a semicolon at the end.

Objects in Thube's objects block are defined as such: ::= (*);

stdio
Operators: "::": Replace with input. Save as replacement. Do not replace again. Return input. ":::": Get user input each time. Return input. "~ ": Print the following string. Return "".

fileio
Operators: "^": Open and read the following file. Return content. " _": Write this string to this file. Return empty string.

socket
Objects: socket(, ): Create a socket Operators: "^ ": Read this socket and return its contents " _ ": Write this string into this socket.

Examples
Hello World: use { # List of libraries to use stdio; # Get the library for input and output } # End libraries rules { # Rules for replacement strings "a" ::= ~"Hello, world!"; # On the character "a", print "Hello, world!" to the console } # End rules strings { # List of strings to use "a"; # The string "a", the first (and only) base string } # End strings

Output the contents of a file (name hard-coded): use { stdio; fileio; } rules { "a" ::= ~^"file.ext"; # Output (~) the contents (o) of file.ext } strings { "a" }

Output the contents of a file by user input: use { stdio; fileio; } rules { "a" ::= ~^{:::}; # Output (~) the contents (o) of a file from user input } strings { "a"; }

Cat server on port 666 (print output): use { stdio; fileio; # Sockets behave like files socket; } objects { sock ::= socket("", 666); } rules { "a" ::= ~^sock+sock_^sock;+"a" # _ is the write operator from fileio. Neither ~ nor _ returns anything, but "a" returns "a", so it replaces it with itself, thus triggering an infinite loop } strings { "a"; }