12
12
\begin {document }
13
13
14
14
% \chapter{The Structure of the \TeX\ Processor}
15
- \chapter {\TeX \ 处理器的结构 }
15
+ \chapter {\TeX 处理器的结构 }
16
16
17
17
% This book treats the various aspects of \TeX\ in chapters
18
18
% that are concerned with relatively small, well-delineated,
@@ -23,13 +23,13 @@ \chapter{\TeX\ 处理器的结构}
23
23
% the few examples given in this chapter will be repeated
24
24
% in the appropriate places later on; they are included here
25
25
% to make this chapter self-contained.
26
- 本书涵盖了 \TeX \ 诸多方面的内容;其中每一章都讲述一个相对较小且易于描述的主题。
27
- 本章将简介 \TeX \ 处理文档的基本流程。
26
+ 本书涵盖了 \TeX 诸多方面的内容;其中每一章都讲述一个相对较小且易于描述的主题。
27
+ 本章将简介 \TeX 处理文档的基本流程。
28
28
当然,本章会忽略很多细节,留待后续章节继续讨论。
29
29
相应的,为了说明问题,本章会给出一些例子;这些例子在后续的这些章节中会继续讨论。
30
30
31
31
% \section{Four \TeX\protect\ processors}
32
- \section {\TeX \ 的 4 个处理器 }
32
+ \section {\TeX 的 4 个处理器 }
33
33
34
34
% The way \TeX\ processes its input can be viewed as
35
35
% happening on four levels. One might say that
@@ -38,50 +38,50 @@ \section{\TeX\ 的 4 个处理器}
38
38
% delivering the input for the next stage. The input of
39
39
% the first stage is then the \n{.tex} input file; the output
40
40
% of the last stage is a \n{.dvi} file.
41
- \TeX \ 处理输入的过程可分为 4 个层次 。
42
- 你可以认为 \TeX \ 处理器(也成 \TeX \ 引擎)有 4 个独立的单元,
41
+ \TeX 处理输入的过程可分为 4 个阶段 。
42
+ 你可以认为 \TeX 处理器(也称 \TeX 引擎)有 4 个独立的单元,
43
43
每个单元接收前序步骤的输出,并将输出作为后续单元的输入。
44
- 第一阶段的输入是 \n {.tex} 文件,最后一个阶段的输出是 \n {.dvi} 文件\footnote {译注(Liam0205):此处讨论的 \TeX \ 是 Knuth \TeX 。后续扩展的 pdf\TeX 等不一定输出 \n {.dvi} 文件。}。%
44
+ 第一阶段的输入是 \n {.tex} 文件,最后一个阶段的输出是 \n {.dvi} 文件\footnote {译注(Liam0205):此处讨论的 \TeX 是 Knuth \TeX 。后续扩展的 pdf\TeX 等不一定输出 \n {.dvi} 文件。}。%
45
45
46
46
% For many purposes it is most convenient, and most insightful,
47
47
% to consider these four levels of processing as happening
48
48
% after one another, each one accepting the {\em completed\/}
49
49
% output of the previous level. In reality this is not true:
50
50
% all levels are simultaneously
51
51
% active, and there is interaction between them.
52
- 通常而言,这样理解上述 4 个层次方便且直观 :
53
- 每个层次 \emph {完整地 }接收上一个层次的输出 。
52
+ 通常而言,这样理解上述 4 个阶段方便且直观 :
53
+ 每个阶段 \emph {完整地 }接收上一个阶段的输出 。
54
54
然而,这样并不完全正确:
55
- 4 个层次的处理是同时进行的,层次之间也有交互 \footnote {译注(Liam0205):流式处理,上一层次处理完多少,下一个层次就接着继续处理这部分 。}。
55
+ 4 个阶段的处理是同时进行的,阶段之间也有交互 \footnote {译注(Liam0205):流式处理,上一阶段处理完多少,下一个阶段就接着继续处理这部分 。}。
56
56
57
57
% The four levels are (corresponding roughly
58
58
% to the `eyes', `mouth', `stomach', and `bowels' respectively
59
59
% in Knuth's original terminology) as follows.
60
- % \begin{enumerate}\item
60
+ 4 个阶段列举如下(按 Knuth 最初的叫法,分别是「眼睛」、「嘴巴」、「胃」和「肠道」):
61
+ \begin {enumerate }
62
+ % \item
61
63
% The input processor. This is the piece of \TeX\ that
62
64
% accepts input lines from the file system of whatever computer
63
65
% \TeX\ runs on, and turns them into tokens.
64
66
% Tokens are the internal objects of \TeX:
65
67
% there are character tokens that constitute the typeset
66
68
% text, and control sequence tokens that are commands
67
69
% to be processed by the next two levels.
70
+ \item 输入处理器(input processor):负责从运行 \TeX 的计算机的文件系统中读入输入,并处理为记号。
71
+ 记号是两种 \TeX 内部对象的统称:构成排版文本的字符记号、待后续两个阶段作为命令处理的控制序列记号。
68
72
% \item The expansion processor.
69
73
% Some but not all of the tokens generated in the first level
70
74
% \ldash macros, conditionals, and a number
71
75
% of primitive \TeX\ commands \rdash are subject to expansion.
72
76
% Expansion is the process that replaces some (sequences of)
73
77
% tokens by other (or no) tokens.
78
+ \item 展开处理器(expansion processor):
79
+ 负责展开输入处理器输出的部分记号:宏、条件式、以及部分 \TeX 原语。
80
+ 记号展开的过程会将一些(连续的)记号删除或替换为其它记号。
74
81
% \item The execution processor.
75
82
% Control sequences that are not expandable are executable,
76
83
% and this execution takes place on the third level of the
77
84
% \TeX\ processor.
78
- 4 个层次列举如下(按 Knuth 最初的叫法,分别是「眼睛」、「嘴巴」、「胃」和「肠道」):
79
- \begin {enumerate }
80
- \item 输入处理器(input processor):负责为 \TeX \ 从文件系统中读入输入,并处理为记号。
81
- 记号是两种 \TeX \ 内部对象的统称:构成排版文本的字符记号、待后续两个层次作为命令处理的控制序列记号。
82
- \item 展开处理器(expansion processor):
83
- 负责展开输入处理器输出的部分记号:宏、条件式、以及部分 \TeX \ 原语。
84
- 记号展开的过程会将一些(连续的)记号删除或替换为其它记号。
85
85
\item 执行处理器(execution processor):
86
86
不可展开的控制序列即是可执行的;执行处理器负责执行这些可执行的控制序列。
87
87
@@ -91,6 +91,9 @@ \section{\TeX\ 的 4 个处理器}
91
91
% category. The other major thing happening on this level
92
92
% is the construction of horizontal, vertical, and
93
93
% mathematical lists.
94
+ 执行处理器的部分活动涉及到 \TeX 的内部状态之变化:
95
+ 赋值(包括宏定义)是其中典型。
96
+ 除此之外,执行处理器负责构造水平列表、垂直列表和数学列表。
94
97
% \item The visual processor.
95
98
% In the final level of processing
96
99
% the visual part of \TeX\ processing is performed. Here
@@ -100,15 +103,11 @@ \section{\TeX\ 的 4 个处理器}
100
103
% Also the output to the \n{dvi} file takes place on this level.
101
104
% The algorithms working here are not accessible to the user,
102
105
% but they can be influenced by a number of parameters.
103
- % \end{enumerate}
104
- 执行处理器的部分活动涉及到 \TeX \ 的内部状态之变化:
105
- 赋值(包括宏定义)是其中典型。
106
- 除此之外,执行处理器负责构造水平列表、垂直列表和数学列表。
107
106
\item 可视化处理器(visual processor):
108
- \TeX \ 的最后一个层次负责排版内容的可视化 。
107
+ \TeX 的最后一个阶段负责排版内容的可视化 。
109
108
可视化处理器将水平列表分行成段,将垂直列表分割成页,将数学列表构建成数学公式;
110
109
最终输出 \n {.dvi} 文件%
111
- \footnote {译注(zoho):对于现代 \TeX \ 处理器而言,还可以是 \n {pdf} 和 \n {xml} 等文件。}。
110
+ \footnote {译注(zoho):对于现代 \TeX 处理器而言,还可以是 \n {pdf} 和 \n {xml} 等文件。}。
112
111
可视化处理器的内部算法对于用户是不可见的;不过用户可以通过一系列参数来控制。
113
112
\end {enumerate }
114
113
@@ -122,7 +121,7 @@ \section{输入处理器}
122
121
% character tokens and control sequence tokens.
123
122
% The remaining category is that of the parameter tokens;
124
123
% these will not be treated in this chapter.
125
- 输入处理器是 \TeX \ 的一部分,负责将 \TeX \ 从输入文件中读入的内容翻译成记号。
124
+ 输入处理器是 \TeX 的一部分,负责将 \TeX 从输入文件中读入的内容翻译成记号。
126
125
它的输出是记号流(stream of tokens):记号组成的列表。
127
126
大部分记号属于以下两类:
128
127
字符记号和控制序列记号。
@@ -138,8 +137,8 @@ \subsection{字符的输入}
138
137
% to any character in the input, for instance the space token
139
138
% at the end of the line, or the \cs{par} token after an empty line.
140
139
对于简单的输入文本,其中的字符被输入处理器翻译为字符记号。
141
- 在某些情况下,\TeX \ 会忽略一些输入字符;例如,连续空格通常等价于单个空格。
142
- 此外,\TeX \ 也会向记号流中插入一些与输入字符无关的记号。
140
+ 在某些情况下,\TeX 会忽略一些输入字符;例如,连续空格通常等价于单个空格。
141
+ 此外,\TeX 也会向记号流中插入一些与输入字符无关的记号。
143
142
例如在每一行的末尾插入一个空格,以及在每一个空行末尾插入一个 \cs {par} 记号。
144
143
145
144
% Not all character tokens signify characters to be typeset.
@@ -157,13 +156,12 @@ \subsection{字符的输入}
157
156
% character code.
158
157
并非所有的字符记号都会被最终排版出来。
159
158
事实上,在 \TeX 中,字符被分类为 16 类
160
- \ldash 每一类都有特定的功能\rdash
159
+ \ldash 每一类都有特定的功能\rdash %
161
160
而只有两类最终会被排版出来。
162
161
其它字符类,像 \n {\char `\{ }、\n {\char `\} }、\n \&
163
162
和 \n \# ,都不会被排版出来。
164
- 因此,\TeX 的字符记号的含义由一对数字决定:
165
- 字符编码\ldash 通常是 \ascii 编码\rdash 和分类码。
166
- 具体某一编码的字符对应的分类码是可修改的\footnote {译注(Liam0205):也就是说,字符在 \TeX 看来是何种含义不光取决于这个字符是什么(字符编码),还取决于它是什么类型(分类码)。对于某个具体的字符来说(字符编码确定),它的类型是可以改变的(分类码可以改变)。}。
163
+ 也就是说,在 \TeX 中,字符记号的含义由字符编码(通常是 \ascii 编码)和分类码这一对数字共同决定。
164
+ 而具体某一编码的字符对应的分类码是可以修改的。
167
165
168
166
% When the escape character (by default~\cs{}$\,$) appears in the input,
169
167
% \TeX's behaviour in forming tokens is more complicated.
@@ -178,9 +176,8 @@ \subsection{字符的输入}
178
176
% $N$,~new line; $M$,~middle of line; $S$,~skipping spaces.
179
177
% These states and the transitions between them are treated
180
178
% in Chapter~\ref{mouth}.
181
- % FIXME (Liam0205): 这一段的翻译感觉有问题,但是等到后续再说吧。
182
- 对于分类码的处理,\TeX \ 输入处理器的行为可想像为在三种内部状态($ N$ ,新行;$ M$ ,
183
- 行内;$ S$ ,忽略空格)中切换的机器。在第~\ref {mouth }~章中我们会讨论这些状态及其切换。
179
+ 在分类码的影响下,\TeX 输入处理器的行为可视作是一个在三种内部状态($ N$ ,新行;$ M$ ,
180
+ 行内;$ S$ ,忽略空格)中切换的机器。第~\ref {mouth }~章将讨论这些状态及其切换。
184
181
185
182
% \subsection{Two-level input processing}
186
183
\subsection {输入处理器的两个阶段 }
@@ -621,7 +618,7 @@ \subsection{被忽略的空格}
621
618
% the sequence \begin{verbatim}
622
619
% \a0
623
620
% \end{verbatim}
624
- 被忽略的空格可以反映数据在 \TeX \ 各层处理器之间的流动情况 。例如:
621
+ 被忽略的空格可以反映数据在 \TeX 各处理器之间的流动情况 。例如:
625
622
\begin {verbatim }
626
623
\def\a{\penalty200}
627
624
\a 0
@@ -647,7 +644,7 @@ \subsection{内部量值及其表示}
647
644
% quantities have an external representation,
648
645
% which is a string of characters, such as
649
646
% \n{4711} or~\n{91.44cm}.
650
- \TeX 使用了多重内部量 ,比如说整数和尺寸。
647
+ \TeX 使用了多种内部量 ,比如说整数和尺寸。
651
648
这些内部量的外部表示是同一的:字符组成的字符串。
652
649
例如 \n {4711} 和 \n {91.44cm}。
653
650
0 commit comments