2 Lexical conventions [lex]2.4 Preprocessing tokens [lex.pptoken]
|
2 詞法約定 【詞法】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 是內建類型時將違反增量運算符的約束。】
|
PREV [lex.trigraph] | NEXT [lex.digraph] | 上一頁 【詞法.三連符】 | 下一頁 【詞法.雙連符】 |
2.4 - [lex.pptoken] - 【詞法.預處理標記】
請不要轉載本文;請不要以任何形式重新出版,發佈本文;請在下載本文 24 小時內將其刪除;禁止將本文用於商業目的。
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.