请不要转载本文;请不要以任何形式重新出版,发布本文;请在下载本文 24 小时内将其删除;禁止将本文用于商业目的。
2.4 Preprocessing tokens [lex.pptoken]
2.4 预处理标记 【词法.预处理标记】
preprocessing-token:
header-name
identifier
pp-number
character-literal
string-literal
preprocessing-op-or-punc
each non-white-space character that cannot be one of the above
预处理-标记:
头-名称
标识符
预处理-数字
字符-文字量
字符串-文字量
预处理-运算符-或-标点
不被以上包括的非空白字符
Each preprocessing token that is converted to a token (2.6) shall have the lexical form of a keyword, an identifier, a literal, an operator, or a punctuator.
每一个能被转换为标记(2.6)的预处理标记都应具有关键字,标识符,文字量,运算符,或标点的形式。
A preprocessing token is the minimal lexical element of the language in translation phases 3 through 6. The categories of preprocessing token are: header names, identifiers, preprocessing numbers, character literals, string literals, preprocessing-op-or-punc, and single non-white-space characters that do not lexically match the other preprocessing token categories. If a ' or a " character matches the last category, the behavior is undefined. Preprocessing tokens can be separated by white space; this consists of comments (2.7), or white-space characters (spaces, horizontal tab, new-line, vertical tab, and form-feed), or both. As described in clause 16, in certain circumstances during translation phase 4, white space (or the absence thereof) serves as more than preprocessing token separation. White space can appear within a preprocessing token only as a part of a header name or between the quotation characters in a character literal or string literal.
预处理标记是语言从第 3 到第 6 阶段中最小的词法元素。预处理标记有以下几类:头名称,标识符,预处理数字,字符文字量,字符串文字量,预处理运算符或标点,以及不符合以上词法类型的单个非空白字符。如果一个 ' 或 " 字符属于最后一类,其行为未定义。预处理标记被空白分隔,空白由注释(2.7),或空白字符(空格,水平表格,换行,垂直表格,和换页),或者由两者共同组成。如在第 16 章中所说,在第 4 阶段的某些情况下,空白(也可能没有)可能不仅分隔预处理标记。仅当作为头名称的一部分,或在字符文字量或字符串文字量的引号字符之间时,空白才可以出现在预处理标记内部。
If the input stream has been parsed into preprocessing tokens up to a given character, the next preprocessing token is the longest sequence of characters that could constitute a preprocessing token, even if that would cause further lexical analysis to fail.
如果一个流直到某个给定字符处已经被解析成预处理标记,则下一个预处理标记将由能够组成一个预处理标记的最长字符序列组成,不管进一步的词法分析是否会失败。
[Example: The program fragment 1Ex is parsed as a preprocessing number token (one that is not a valid floating or integer literal token), even though a parse as the pair of preprocessing tokens 1 and Ex might produce a valid expression (for example, if Ex were a macro defined as +1). Similarly, the program fragment 1E1 is parsed as a preprocessing number (one that is a valid floating literal token), whether or not E is a macro name. ]
【例:无论预处理标记 1 和 Ex 是否会产生一个有效的表达式(比如 Ex 是一个被定义为 +1 的宏),程序片段 1Ex 总被解析为一个预处理数字标记(一个无效的浮点或整数文字量标记)。同样地,无论 E 是否是一个宏名字,程序片段 1E1 总被解析为一个预处理数字(一个有效的浮点文字量标记)。】
[Example: The program fragment x+++++y is parsed as x ++ ++ + y, which if x and y are if built-in types, violates a constraint on increment operators, even though the parse x ++ + ++ y might yield a correct expression. ]
【例:即使按 x ++ + ++ y 解析时可能产生一个正确的表达式,程序片段 x+++++y 总是被解析成 x ++ ++ + y,并且当 x 和 y 是内建类型时将违反增量运算符的约束。】