From 4e7fdd57cbf8f60f674ba48fd04c80ad59a20579 Mon Sep 17 00:00:00 2001
From: Jed Barber Like Lisp, the esoteric programming language Grasp
+is a homoiconic language that exclusively uses a single datatype. Except instead of lists, it uses
+directed graphs. 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. In the current specification,
+the actions that can be performed are: 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. 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. The above example is recorded as follows:
+ Source code is available here. Content for index goes here Thue 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. An example Thue program that increments a binary number surrounded by '_' characters:
+ 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. 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. The traditional Hello World program:
+ 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. The following is an innocent piece of code that accepts a single line of input and does nothing
+more. Maybe.
+ 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. 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. A rule that replaces an ordinary symbol 'a' with 'abc':
+ A rule that replaces the letter 'a' that was obtained from stdin with 'abc':
+ For convenience, a number of escaped characters are also available:
+Jedidiah Barber's Personal Site
+
@@ -20,3 +22,4 @@
+
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 %}
+
+Grasp Interpreter
+
+
+
+
+
+ digraph {
+ 1 [label="puts"]
+ 2 [label="grasp:main"]
+ 3 [label="Hello world!"]
+
+ 1 -> 2 [label="name"]
+ 1 -> 3 [label="in"]
+ }
+
+Thue Version 2a
+
+
+ 1_::=1++
+ 0_::=1
+ 01++::=10
+ 11++::=1++0
+ _0::=_
+ _1++::=10
+ ::=
+ _1111111_
+
+
+ a::=~Hello World!
+ ::=
+ a
+
+
+ a::=:::
+ ::=
+ a
+
+
+ a::=abc
+
+
+ "a"::=abc
+
+
+ \\ -> backslash
+ \r -> return
+ \n -> newline
+ \: -> colon
+ \" -> double quote
+ \EOT -> end of file
+
+
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 here.
+ +{% endblock %} + -- cgit