- #1
Eclair_de_XII
- 1,083
- 91
- TL;DR Summary
- I copied a piece of TeX code from TeX by Topic, and I don't quite know how the following code is interpreted. I am informed that the eyes, mouth, gullet, and intestines of TeX do not run one after another, but rather, in tandem. But this is rather confusing to me, and it is too vague an explanation for me to understand the following code.
Code:
{\catcode`\^^M=12 \endlinechar=`\^^J \catcode`\^^J=5 This is an M:
This is a middle line.
This is a "J":
}
As I see it, the TeX processor would first need to feed this to the input processor to be transformed into a token list.
The input processor would see the code I posted above with their default cat-codes and transform it into a list of (char-code,cat-code) pairs.
\begin{speculation}
There's nothing in the token list that is going to be expanded, I think, so the expansion processor does nothing.
Then the token list is fed into the execution processor, and the assignments on line 1 are made.
I assume then, that the input processor is run again after the execution processor, but that just makes things even more confusing, if it were true. For example:
- If the assignments on the first line have been made, then why is the eol-character on this line still ^^M?
- Why is the eol-character on the second and third lines ^^J with cat-code 5 while the terminator character on the first is ^^M?
- Why does it seem that the eol-character is ^^J outside the group, and moreover, why does it not have cat-code 5? Isn't grouping supposed to isolate the assignment from the rest of the document outside the group?
- Consider the following:
Code:
{\catcode`\^^M=12 %
\endlinechar=`\^^J %
\catcode`\^^J=5 This is an M:
This is a middle line.
This is a "J":
}
If separated each assignment statement by a comment-character followed by a line break, the terminator character does not seem to be a catcode-12 ^^M after the phrase, ``This is an M:''. This is does not seem to be in-line with the fact that the three resulting lines are read as though they are all on one line.
- Overall, this piece of code is a total anomaly to me and makes me question all that I think I know about TeX.
\end{speculation}
I know this is far from the earlier remark that the input, expansion, execution, and visual processors work simultaneously, and actually affect one another when TeX is run. Yet, I cannot seem to grasp how they would work at the same exact time. Mind you, TeX by Topic claims to be an advanced book on TeX, to be read after an introductory text, and would thus expect its reader to know this sort of thing. It might be my incompetence as an inattentive reader, but all the same, the books I've skimmed do not seem to go too in-depth on the interdependence of these processors.