Updates to 2001/herrmann1

Update plus1.turing file I added a while back (based on author's
remarks).

One of the missing files was not actually missing; it was a misreading
of the author's remarks. It was suggesting that if one wanted to make
their own file by that name, not that the file was there. There still is
a missing file, however.

Format/typo check README.md.
This commit is contained in:
Cody Boone Ferguson committed 2023-11-17 12:46:14 -08:00
1 parent c0c2bd8fb6
commit db6bb7cee7
4 files changed
+21 -20

No files matched your search

+17 -14
View File
@@ -20,16 +20,13 @@ For more detailed information see [2001 herrmann1 in bugs.md](/bugs.md#2001-herr
## To use:
```sh
./herrmann1.sh 'prg=file'
./herrmann1.sh 'prg=file'
```
NOTE: this entry seems to rely on older versions of gcc for the compilation
stage and as such if you wish to see that part like it was designed you will
need an older compiler perhaps gcc 2.95.
NOTE: some files are missing and are not found in the archive either. See
[bugs.md](/bugs.md) for more details.
### Try:
@@ -56,7 +53,7 @@ on.
## Author's remarks:
Many cool things have been done with the preprocessor,
e.g. calculation of prime numbers or the tower of Hanoi. However,
e.g. calculation of prime numbers or the Tower of Hanoi. However,
up to now, no one proved that the preprocessor is Turing complete,
and I wondered why. Well, the answer is simply that the
preprocessor is _not_ Turing complete, at least not if the program
@@ -86,8 +83,10 @@ example that you can solve NP hard problems in polynomial time!
Turing machine running over the tape and doing its work in your
terminal!
### How to use it
#### For the impatient
The info files `herrmann1.turing` and [herrmann1.gcd](herrmann1.gcd) are sample
@@ -176,12 +175,12 @@ Some explanations:
- The tape alphabet is always O and I.
- The states can be anything starting with "st". "start" and
"stop" are the start and stop states, respectively.
- to define a state, use two lines: one for each letter on the
- To define a state, use two lines: one for each letter on the
tape. You may omit one of the lines if the Turing machine will
never enter the state reading that letter. (In the example, the
line defining st2_I has been left out.)
line defining `st2_I` has been left out.)
- The order of the lines is irrelevant.
- You may use c-style comments. (Would you have guessed it?)
- You may use C-style comments. (Would you have guessed it?)
Now, the program can be used with
@@ -191,8 +190,8 @@ Now, the program can be used with
But what happens if no tape is provided? Up to now, the Turing
machine would start on an empty tape (that is, a tape filled with
O's). For many programs, this doesn't make much sense (as is
the case for "plus1.turing"). So you might want to provide a
`O`s). For many programs, this doesn't make much sense (as is
the case for `plus1.turing`). So you might want to provide a
default tape by adding a line like
```c
@@ -201,6 +200,7 @@ default tape by adding a line like
to your program.
### Debugging
When writing long programs, the most common errors are to forget
@@ -230,13 +230,14 @@ Tape:
```
and the return code will be 1. As you can see, the Turing machine
moved over the O's, but when it arrived at the `I` (still in state
moved over the `O`s, but when it arrived at the `I` (still in state
start), the error occurred.
Note that other kinds of errors can cause compilation to fail.
If this happens, the build script will write the error message of
gcc into a file called `error` and then exit.
### What the build script does
In principle, the build script simply runs the preprocessor over
@@ -264,7 +265,7 @@ with a `-D` before. I had a slight technical problem doing this
(especially with the spaces that can appear within the tape
argument). That made the build script a bit longer.
- It would be enough to pass the defines in the first
- It would be enough to pass the `#define`s in the first
preprocessing. The program then "remembers" them. However, it
doesn't matter if they are passed in all pre-processes. (This
doesn't sound very impressive, but it has required some extra
@@ -280,6 +281,7 @@ directly, because the warnings would clobber the animation. I
could have made the compile script output the error file in case
of an error, but I didn't want to make it yet longer.)
### Some technical details / obfuscations
- The program is compressed. In the first three preprocessing
@@ -334,6 +336,7 @@ to use many variables more than once.
"modern art of programming" - a mixture of program-like
indenting and modern art. There are even some comments...
### Compatibility
- It works with many versions of gcc. I tested it with versions
@@ -349,12 +352,12 @@ inside comments (Well, _I_ like some well-placed `/*/*/`.) as
well as some suggestions where to place some more parentheses
(as if I didn't know the operator precedence).
- Different versions of cc all produced only rubbish. Apparently,
- Different versions of `cc` all produced only rubbish. Apparently,
the preprocessors didn't really work. (I don't feel guilty
there, either. Even with very simple programs, they produced
mysterious output.)
- For Mac-Users: It works with the C compiler of Codewarrior (an
- For Mac-Users: It works with the C compiler of CodeWarrior (an
old version). This compiler even leaves out all that unnecessary
white space, so that no clean-up is needed. (It would be useful
to write a kind of script which does the equivalent to the build
+1 -1
View File
@@ -1,7 +1,7 @@
#define tape O O O O O I I I I
/* Search beginning of number. */
#define start_O O, right, start
/* Number found. Move one step to the left. */
#define start_I I, left, st2
/* Write a I and stop */
#define st2_O I, left, stop
-5
View File
@@ -1887,11 +1887,6 @@ This program deliberately crashes if it loses (which is what it aims to do).
The author referred to the file `herrmann1.turing` but it does not exist not even
in the archive. Do you have a copy? Please provide it!
### STATUS: missing files - please provide them
The author also referred to the file `times2.turing` but this is also missing in
the archive. Do you have a copy? Please provide it!
### STATUS: known bug - please help us fix
+3
View File
@@ -2556,6 +2556,9 @@ itself by itself which just showed the usage string and exited. The [script
herrmann1.sh](2001/herrmann1/herrmann1.sh) is used to compile the program but
it's also how you invoke the program.
Cody provided the file [plus1.turing](2001/herrmann1/plus1.turing) based on the
author's remarks.
He also fixed the [script herrmann1.sh](2001/herrmann1/herrmann1.sh) for
shellcheck. In particular there were quite a few: