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. 1 year ago
src Reformat. 1 year ago
tests Reformat. 1 year ago
.gitignore Rewrite and reformat the specification. 1 year ago
Cargo.toml Add LICENSE. 1 year ago
LICENSE Add LICENSE. 1 year ago Update specification. 1 year ago
presidents.tsv Update specification. 1 year ago


set -eu

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

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

<title>The Washington Programming Language</title>
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;

<h1>The Washington Programming Language</h1>

<p>Draft Specification; version 0.0.2</p>
<p>Author: Jeb Rosen &lt;;</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.

<h2>General Syntax</h2>

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>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>

<li>Every Nation must be founded by Washington.</li>
Each inaugurated President must be from a different Party than the previously inaugurated President.
Democratic-Republicans count as both Democrats and Republicans, and
must be preceded and/or followed only by a Federalist or a Whig.
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.
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.

<h2>Special Cases and Exceptions</h2>
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>Van Buren's name is combined into one token, VanBuren.</li>
Donald Trump is still in office, and his name is reserved for future
expansion to the language.

<h2>Inauguration Model</h2>

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.

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.

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.

<h2>List of Presidents</h2>

$(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)

<h3>Hello World</h3>


$(include_code tests/hello_world_reg.usa)


$(include_code tests/hello_world_stack.usa)


Counts down from 9 to 0.

$(include_code tests/loop.usa)


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


make_html > README.html