summaryrefslogtreecommitdiff
path: root/project/templates/grasp.xhtml
blob: 5d8d23772bf3939d0e1a1a2e7b0bc8706895b832 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80

{%- extends "base_plain.xhtml" -%}



{%- block title -%}Grasp Interpreter{%- endblock -%}



{%- block footer -%}{{ plain_footer ("grasp.xhtml") }}{%- endblock -%}



{%- block content %}
<h4>Grasp Interpreter</h4>

<p>Git repository: <a href="/cgi-bin/cgit.cgi/esoteric">Link</a></p>

<h5>1/1/2017</h5>

<p>Like Lisp, the esoteric programming language <a href="http://esolangs.org/wiki/Grasp"
class="external">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>

<div class="figure">
    <img src="/img/grasp_helloworld.png"
         alt="Hello World in Grasp"
         height="176"
         width="268" />
    <div class="figcaption">Hello World in Grasp</div>
</div>

<p>In the <a href="https://github.com/fis/grajsp/wiki/Grasp-specification" class="external">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 <a href="http://www.graphviz.org/doc/info/lang.html" class="external">DOT graph
description language</a> for the file format, to enable a text format as well as relatively easy
conversion to a graph image.</p>

<p>The above example is recorded as follows:</p>
<div class="precontain">
<code>
digraph {
    1 [label="puts"]
    2 [label="grasp:main"]
    3 [label="Hello world!"]

    1 -> 2 [label="name"]
    1 -> 3 [label="in"]
}
</code>
</div>

<p>If a format that more readily converts to a comprehensible graph image is found, a parser for it
may be added.</p>
{% endblock -%}