-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2b2481c
commit 250c500
Showing
1 changed file
with
47 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,48 @@ | ||
# BlueSpace | ||
A Whitespace interpreter in Python | ||
BlueSpace is the name of an interpreter for the Whitespace programming language. | ||
|
||
## Whitespace | ||
[Whitespace](https://en.wikipedia.org/wiki/Whitespace_%28programming_language%29) is an esoteric programming language that was created by Edwin Brady and Chris Morris and is based at http://compsoc.dur.ac.uk/whitespace/. Its syntax consists entirely of characters that are usually invisible when displayed by a computer: space, horizontal tab and line feed. | ||
|
||
## BlueSpace | ||
This interpreter is written in Python 3 and boasts the following features: | ||
* Interpret Whitespace code | ||
* Compile Whitespace code to Python and optionally execute it | ||
* Option to use a printable syntax, which substitutes space, tab and linefeed with `s`, `t` and `n`, respectively | ||
* Assemble and disassemble an assembly-style syntax (described below) | ||
|
||
To run a Whitespace program, simply execute `./bspace.py source.ws`; to see other options, use `./bspace.py --help`. | ||
|
||
## Assembly Syntax | ||
Each line of the source must match one of the following forms, where *number* is any decimal integer and *label* is any string of `s` and `t` characters with an optional trailing `n`. Each line maps to a single Whitespace instruction. A `#` begins a comment; it and any subsequent characters on the same line are ignored. | ||
|
||
<pre> | ||
Push <i>number</i> | ||
Duplicate | ||
Copy <i>number</i> | ||
Swap | ||
Discard | ||
Slide <i>number</i> | ||
|
||
Add | ||
Subtract | ||
Multiply | ||
Divide | ||
Modulo | ||
|
||
Store | ||
Retrieve | ||
|
||
Label <i>label</i> | ||
Call <i>label</i> | ||
Jump <i>label</i> | ||
JumpZero <i>label</i> | ||
JumpNegative <i>label</i> | ||
Return | ||
End | ||
|
||
OutputChar | ||
OutputNum | ||
ReadChar | ||
ReadNum | ||
</pre> |