summaryrefslogtreecommitdiff
path: root/project
diff options
context:
space:
mode:
Diffstat (limited to 'project')
-rw-r--r--project/assets/css/default.css24
-rwxr-xr-xproject/assets/img/grasp_helloworld.pngbin0 -> 3477 bytes
-rw-r--r--project/complexity.yml2
-rw-r--r--project/templates/base.html7
-rw-r--r--project/templates/grasp.html70
-rw-r--r--project/templates/index.html7
-rw-r--r--project/templates/thue2a.html97
7 files changed, 203 insertions, 4 deletions
diff --git a/project/assets/css/default.css b/project/assets/css/default.css
index a3805ee..7ae93a6 100644
--- a/project/assets/css/default.css
+++ b/project/assets/css/default.css
@@ -9,6 +9,18 @@ body {
}
+figure {
+ text-align: center;
+}
+
+
+code {
+ display: block;
+ font-family: monospace;
+ white-space: pre;
+}
+
+
/* A bunch of nonsense to make the navbar
@@ -35,3 +47,15 @@ nav ul li {
line-height: 100%;
}
+
+
+
+/* Formatting the index list differently
+ from regular lists. */
+
+ul.index {
+ text-align: center;
+ list-style-type: none;
+ margin-top: 1.5cm;
+}
+
diff --git a/project/assets/img/grasp_helloworld.png b/project/assets/img/grasp_helloworld.png
new file mode 100755
index 0000000..df5bfff
--- /dev/null
+++ b/project/assets/img/grasp_helloworld.png
Binary files differ
diff --git a/project/complexity.yml b/project/complexity.yml
index a9a19d0..c67a7b2 100644
--- a/project/complexity.yml
+++ b/project/complexity.yml
@@ -11,4 +11,6 @@ output_dir: "../www"
unexpanded_templates:
- "about.html"
- "git.html"
+ - "grasp.html"
+ - "thue2a.html"
diff --git a/project/templates/base.html b/project/templates/base.html
index 2e5a549..7a215a4 100644
--- a/project/templates/base.html
+++ b/project/templates/base.html
@@ -2,14 +2,16 @@
<html lang="en">
<head>
<meta charset="utf-8">
- <title>Jed Barber - {% block title %}{% endblock %}</title>
+ <title>{% block title %}{% endblock %}</title>
<link href="/css/default.css" rel="stylesheet">
</head>
<body>
+ <h2>Jedidiah Barber's Personal Site</h2>
+ <hr>
<nav>
<ul>
<li><a href="/">Index</a></li>
- <!--<li><a href="/about.html">About</a></li>-->
+ <li><a href="/about.html">About</a></li>
<li><a href="/git.html">Git</a></li>
</ul>
</nav>
@@ -20,3 +22,4 @@
</article>
</body>
</html>
+
diff --git a/project/templates/grasp.html b/project/templates/grasp.html
new file mode 100644
index 0000000..e591d92
--- /dev/null
+++ b/project/templates/grasp.html
@@ -0,0 +1,70 @@
+
+{% extends "base.html" %}
+
+
+
+{% block title %}Grasp Interpreter{% endblock %}
+
+
+
+{% block content %}
+
+<h4>Grasp Interpreter</h4>
+
+<p>Like Lisp, the esoteric programming language <a href="http://esolangs.org/wiki/Grasp">Grasp</a>
+is a homoiconic language that exclusively uses a single datatype. Except instead of lists, it uses
+directed graphs.</p>
+
+<p>A Grasp program is initialised with instruction pointers to those nodes in the graph that have
+a "name" edge to a node with the value "grasp:main". The nodes at each instruction pointer are
+evaluated and the pointer then updated by following an available "next" edge. This continues until
+all instruction pointers have no more "next" edges to follow.</p>
+
+<figure>
+ <img src="/img/grasp_helloworld.png"
+ alt="Hello World in Grasp"
+ height="176"
+ width="268">
+ <figcaption>Hello World in Grasp</figcaption>
+</figure>
+
+<p>In the <a href="https://github.com/fis/grajsp/wiki/Grasp-specification">current specification</a>,
+the actions that can be performed are:</p>
+
+<ul>
+ <li>add or delete an edge</li>
+ <li>change the value of a node</li>
+ <li>add, subtract, multiply, divide, or modulo node values</li>
+ <li>call and return from functions, which take the form of subgraphs with named entry points</li>
+ <li>read and write from arbitrary file handles</li>
+ <li>push, pop and pick a section of nodes arranged to act as a stack</li>
+</ul>
+
+<p>The execution of a node may be skipped by having "cond" edges pointing to either zero values or
+non-numeric values. Also, due to the way instruction pointers update and the way several instructions
+are defined, there is a measure of non-determinism that can be introduced depending on what
+edges are available.</p>
+
+<p>The language seemed like an interesting enough idea, but unfortunately nobody had done anything
+with it, and there was only a specification. This has now been fixed. The interpreter currently
+uses a subset of the DOT graph description language for the file format, to enable a text format
+as well as relatively easy conversion to a graph image. If a format that more readily converts to a
+comprehensible graph image is found, a parser for it may be added.</p>
+
+<p>The above example is recorded as follows:
+<code>
+ digraph {
+ 1 [label="puts"]
+ 2 [label="grasp:main"]
+ 3 [label="Hello world!"]
+
+ 1 -> 2 [label="name"]
+ 1 -> 3 [label="in"]
+ }
+</code>
+</p>
+
+<p>Source code is available <a href="https://github.com/jedb/esoteric">here</a>.</p>
+
+{% endblock %}
+
diff --git a/project/templates/index.html b/project/templates/index.html
index 14b9c97..70aafcb 100644
--- a/project/templates/index.html
+++ b/project/templates/index.html
@@ -1,8 +1,11 @@
{% extends "base.html" %}
-{% block title %}Index{% endblock %}
+{% block title %}Jedidiah Barber's Personal Site{% endblock %}
{% block content %}
- <p>Content for index goes here</p>
+ <ul class="index">
+ <li><a href="/grasp.html">Grasp Interpreter</a></li>
+ <li><a href="/thue2a.html">Thue Version 2a</a></li>
+ </ul>
{% endblock %}
diff --git a/project/templates/thue2a.html b/project/templates/thue2a.html
new file mode 100644
index 0000000..c0430db
--- /dev/null
+++ b/project/templates/thue2a.html
@@ -0,0 +1,97 @@
+
+{% extends "base.html" %}
+
+
+
+{% block title %}Thue Version 2a{% endblock %}
+
+
+
+{% block content %}
+
+<h4>Thue Version 2a</h4>
+
+<p><a href="http://esolangs.org/wiki/Thue">Thue</a> is an esoteric programming language
+based on unrestricted grammars. A Thue program consists of a number of rules detailing a
+sequence of symbols to replace and a sequence of symbols to replace with, and an initial
+state of the program. Applicable rules are then applied to the inital state in a random
+order until no more are applicable, at which point the program terminates.</p>
+
+<p>An example Thue program that increments a binary number surrounded by '_' characters:
+<code>
+ 1_::=1++
+ 0_::=1
+ 01++::=10
+ 11++::=1++0
+ _0::=_
+ _1++::=10
+ ::=
+ _1111111_
+</code>
+</p>
+
+<p>The before and after symbols in each rule are separated by '::=' and the list of rules is
+ended by a blank rule. Note that whitespace in rules and the inital state is NOT ignored.</p>
+
+<p>Output is handled by prefixing the right hand side with '~', which causes those symbols to
+go to stdout and the replacement in the program to be the empty string.</p>
+
+<p>The traditional Hello World program:
+<code>
+ a::=~Hello World!
+ ::=
+ a
+</code>
+</p>
+
+<p>Input is handled by having the right hand side of a rule be ':::', which causes the left
+hand side symbols to be replaced with a line from the standard output. Unfortunately, this
+immediately causes problems.</p>
+
+<p>The following is an innocent piece of code that accepts a single line of input and does nothing
+more. Maybe.
+<code>
+ a::=:::
+ ::=
+ a
+</code>
+</p>
+
+<p>If a string involving the letter 'a' is entered into the above program, the single input rule
+will again become applicable and another line of input will be obtained. In other words, the
+input in Thue is unescaped and allows direct code injection into a program.</p>
+
+<p>To solve this problem, I've constructed a slightly modified version of Thue that I'm calling
+version 2a. In this version, all symbols obtained through stdin are treated as different from
+ordinary symbols. Rules can refer to and manipulate symbols obtained through stdin by
+surrounding them in double quotes.</p>
+
+<p>A rule that replaces an ordinary symbol 'a' with 'abc':
+<code>
+ a::=abc
+</code>
+</p>
+
+<p>A rule that replaces the letter 'a' that was obtained from stdin with 'abc':
+<code>
+ "a"::=abc
+</code>
+</p>
+
+<p>For convenience, a number of escaped characters are also available:
+<pre>
+ \\ -> backslash
+ \r -> return
+ \n -> newline
+ \: -> colon
+ \" -> double quote
+ \EOT -> end of file
+</pre>
+</p>
+
+<p>While this doesn't solve all the problems Thue has (try writing a Thue program that asks
+for and greets the user by name!) it should solve this one particular issue. Source code is
+available <a href="https://github.com/jedb/esoteric">here</a>.</p>
+
+{% endblock %}
+