From 92ff13627021a5fdd4eea59bd5db493cbea5406b Mon Sep 17 00:00:00 2001
From: Jed Barber
An example Thue program that increments a binary number surrounded by '_' characters:
+
1_::=1++
0_::=1
@@ -29,6 +30,7 @@ _1++::=10
::=
_1111111_
+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.
@@ -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.The traditional Hello World program:
+
a::=~Hello World!
::=
a
+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.
The following is an innocent piece of code that accepts a single line of input and does nothing more. Maybe.
+
a::=:::
::=
a
+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.
A rule that replaces an ordinary symbol 'a' with 'abc':
+
a::=abc
+A rule that replaces the letter 'a' that was obtained from stdin with 'abc':
+
"a"::=abc
+For convenience, a number of escaped characters are also available:
+\\ -> backslash \r -> return @@ -83,7 +94,7 @@ a::=abc \" -> 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 -- cgit