The Washington programming language.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Jeb Rosen f6d479df59 Add LICENSE. 5 months ago
src Reformat. 6 months ago
tests Reformat. 6 months ago
.gitignore Rewrite and reformat the specification. 6 months ago
Cargo.toml Add LICENSE. 5 months ago
LICENSE Add LICENSE. 5 months ago
README.html.sh Update specification. 6 months ago
presidents.tsv Update specification. 6 months ago

README.html.sh

#!/bin/sh

set -eu

include_code() {
cat <<EOF
<pre class="code">
$(cat $1)
</pre>
EOF
}

make_html() {
cat <<EOF
<!doctype html>
<html lang="en">

<head>
<title>The Washington Programming Language</title>
<style>
h1, h2, h3, h4, h5, h6 {
font-family: sans-serif;
}

table {
border-collapse: collapse;
}

th, td {
border: 1px solid black;
padding: 4px 2px;
}

.code {
background-color: #333333;
color: #cccccc;
padding: 0.5em;
border-radius: 4px;
margin-right: auto;
}
</style>
</head>

<body>
<h1>The Washington Programming Language</h1>

<p>Draft Specification; version 0.0.2</p>
<p>Author: Jeb Rosen &lt;jeb@jebrosen.com&gt;</p>

<h2>Overview</h2>
<p>
Washington exists because Pikachu is too difficult to use practically. To avoid
being too practical, however, Washington has several pointless and confusing
restrictions of its own.
</p>

<h2>General Syntax</h2>

<ul>
<li>
A Nation is defined by a sequence of names of Presidents, some to be
Inaugurated and some to be read as arguments for other Presidents.
</li>
<li>The names of Presidents are case-insensitive.</li>
<li>President names must be separated by any number of whitespace characters.</li>
<li>The comma, period, semicolon, colon, exclamation, and question mark characters are ignored.</li>
<li>All contents of any line beginning with a double quotation mark are ignored.</li>
</ul>

<h2>Rules</h2>
<ul>
<li>Every Nation must be founded by Washington.</li>
<li>
Each inaugurated President must be from a different Party than the previously inaugurated President.
<ul>
<li>
Democratic-Republicans count as both Democrats and Republicans, and
must be preceded and/or followed only by a Federalist or a Whig.
</li>
</ul>
</li>
<li>
The last president eligible for inauguration (i.e. not named as an
argument) determines the "era" of the Nation. Future Presidents (those from a
later era) cannot be named. Presidents become more complex in later eras. If
an ambiguous president is named in this manner, the earliest possible era is
chosen. This last President will still be Inaugurated if reached during the
life of the Nation.
</li>
<li>
In the case of an ambiguous name, it as if both Presidents were
inaugurated simultaneously. If they are from different parties, both of their
restrictions apply.
</li>
</ul>

<h2>Special Cases and Exceptions</h2>
<ul>
<li>
John Adams is the only Federalist, but his last name conflicts with John
Quincy Adams. To resolve this, the name "Adams" always refers to the
Federalist John Adams, and "Quincy" always to the Democratic-Republican
John Quincy Adams.
</li>
<li>Van Buren's name is combined into one token, VanBuren.</li>
<li>
Donald Trump is still in office, and his name is reserved for future
expansion to the language.
</li>
</ul>

<h2>Inauguration Model</h2>

<p>
Some Presidents operate on registers, which are named after presidents.
Presidents that share names create ambiguity; generally, inaugurations that
read data read from the earliest possible register and inaugurations that
write data will write to both registers.
</p>

<p>
Before a nation is formed, the Washington register is initialized to zero. It
is an error to read from an uninitialized register. Writing to an uninitialized
register is allowed.
</p>

<p>
Some Presidents operate on a stack, the top of which overlaps with the
registers. After pushing 3, 4, then 5 on the stack these values would
be visible in the Jefferson, Adams, and Washington registers
respectively. After popping two values off the stack, Washington would
hold the value 3. The stack should be assumed to be of infinite length,
though implementations will probably limit it.
</p>

<h2>List of Presidents</h2>

<table>
$(awk -F'\t' '/\t/{ print "<tr><td>"$1"</td><td>"$2"</td><td>"$3"</td><td>"$4"</td><td>"$5"</td><td>"$6"</td></tr>" }' presidents.tsv)
</table>

<h2>Examples</h2>
<h3>Hello World</h3>

Register-based

$(include_code tests/hello_world_reg.usa)

Stack-based

$(include_code tests/hello_world_stack.usa)

<h3>Loop</h3>

Counts down from 9 to 0.

$(include_code tests/loop.usa)

<h2>Glossary</h2>
<dl>
<dt>nation</dt><dd>program</dd>
<dt>president</dt><dd>instruction</dd>
<dt>inaugurate</dt><dd>execute</dd>
</dl>

<p>Copyright © Jeb Rosen 2019.</p>

</body>
</html>
EOF
}

make_html > README.html