summaryrefslogtreecommitdiff
path: root/project/templates/thue2a.html
diff options
context:
space:
mode:
authorJed Barber <jjbarber@y7mail.com>2017-08-07 12:20:36 +1000
committerJed Barber <jjbarber@y7mail.com>2017-08-07 12:20:36 +1000
commit92ff13627021a5fdd4eea59bd5db493cbea5406b (patch)
treeeb95a180a88c4cd8f82aa2169a4ce1fb0ddcbe07 /project/templates/thue2a.html
parent60c63100f66ea5dce4ad10941b4c40725f01f3c8 (diff)
I think I've finally struck the right width balance
Diffstat (limited to 'project/templates/thue2a.html')
-rw-r--r--project/templates/thue2a.html13
1 files changed, 12 insertions, 1 deletions
diff --git a/project/templates/thue2a.html b/project/templates/thue2a.html
index 6cb4680..4f82ed8 100644
--- a/project/templates/thue2a.html
+++ b/project/templates/thue2a.html
@@ -19,6 +19,7 @@ state of the program. Applicable rules are then applied to the inital state in a
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:</p>
+<div class="precontain">
<code>
1_::=1++
0_::=1
@@ -29,6 +30,7 @@ _1++::=10
::=
_1111111_
</code>
+</div>
<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>
@@ -37,11 +39,13 @@ ended by a blank rule. Note that whitespace in rules and the inital state is NOT
go to stdout and the replacement in the program to be the empty string.</p>
<p>The traditional Hello World program:</p>
+<div class="precontain">
<code>
a::=~Hello World!
::=
a
</code>
+</div>
<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
@@ -49,11 +53,13 @@ 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.</p>
+<div class="precontain">
<code>
a::=:::
::=
a
</code>
+</div>
<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
@@ -65,16 +71,21 @@ ordinary symbols. Rules can refer to and manipulate symbols obtained through std
surrounding them in double quotes.</p>
<p>A rule that replaces an ordinary symbol 'a' with 'abc':</p>
+<div class="precontain">
<code>
a::=abc
</code>
+</div>
<p>A rule that replaces the letter 'a' that was obtained from stdin with 'abc':</p>
+<div class="precontain">
<code>
"a"::=abc
</code>
+</div>
<p>For convenience, a number of escaped characters are also available:</p>
+<div class="precontain">
<pre>
\\ -> backslash
\r -> return
@@ -83,7 +94,7 @@ a::=abc
\" -> double quote
\EOT -> end of file
</pre>
-
+</div>
<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