Readable

From Esolang
Jump to navigation Jump to search

Readable is a language invented by User:None1 and inspired by Unreadable. Unlike its name, programs in this language are very unreadable because it uses the characters (U+2212) and - (U+002D), which looks exactly the same in some fonts.

Data storage

There's a tape that supports random access, but no pointer. The tape is infinitely long, and all elements in the tape are unsigned bignums.

Commands

Every command in Readable has four characters, and some arguments, these characters and arguments have only the − and - characters.

For convenience, we use = instead of in this section's examples, but remember that = is invalid can be used in actual programming.

Arguments

There are two kinds of arguments: integer and string.

Integer

An integer is represented in binary (big-endian) but with - and instead of 0 and 1 respectively.

But since integers in Readable are unbounded, each bit is represented by 2 bits: The first bit is the actual data, the second bit is 0 if there is another bit after this bit, and 1 if this bit is the last bit of the integer).

For example:

=---=-==

Represents the number 11.

String

A string is represented by many integers, the first integer is the length of string, other integers are the ASCII value of corresponding characters.

Command Table

<string> is a string, <a>, <b>, <c>, etc... are integer values (variable or literal), <integer> must be an integer literal.

----<string> Print <string>
---=<a> Return value at address <a>
--=-<a><b> Return <a>+<b>
--==<a><b> Return <a>-<b>
-=--<a><b> Return <a>*<b>
-=-=<a><b> Return <a>/<b> (floor division)
-==-<a><b> Return <a>%<b>
-===<a><b> Set value at address <a> to <b>
=---<a>CODE=--= If <a> is nonzero, execute CODE
=-=-<a>CODE=--= While <a> is nonzero, execute CODE
=---<a>CODE1=-==CODE2=--= If <a> is nonzero, execute CODE1, otherwise CODE2
==--<a> Print <a>
==-=<a> Print the ASCII character with value <a>
===- Read a character and return its ASCII value
==== Read an integer and return it

Division/modulo by 0 or subtracting a smaller number by a larger one is undefined behavior.

Comments

To increase readablilty, Readable supports comments with |, the vertical bar. a | comments out the rest of the line.

code|comment
code

Like comments in other languages, comments in Readable are not parsed nor executed and can be used to describe what the program does, however, it is also useful for separating the actual program and some psuedocode for readability.

Readable code line 1 | Psuedocode line 1
Readable code line 2 | Psuedocode line 2
Readable code line 3 | Psuedocode line 3

Except and - and comments (comments can have any character), only spaces and line feeds are allowed.

Examples programs

Hello, World!

----−-−---−−--−-----−------−--−-−-----−---−−--−-−---−-−----−--−-−---−-−----−--−-−---−-−-−-−−----−---−-−----−----−----------−--−---−---−-−-−−--−-−---−-−-−-−−--−-−-−-----−--−--−-−---−-−----−--−-−-----−----−----−---------−−

Cat Program (never terminates)

Shows code on the left and pseudocode on the right.

−-−-−−     | while 1
−−-−−−−-  | putc(getc())
−--−        | end