Стандарт C++ 98, страница 6
Описание файла
PDF-файл из архива "Стандарт C++ 98", который расположен в категории "". Всё это находится в предмете "практикум (прикладное программное обеспечение и системы программирования)" из 4 семестр, которые можно найти в файловом архиве МГУ им. Ломоносова. Не смотря на прямую связь этого архива с МГУ им. Ломоносова, его также можно найти и в других разделах. .
Просмотр PDF-файла онлайн
Текст 6 страницы из PDF
The set of alternative tokens is defined in Table 2.Table 2—alternative tokens_______________________________________________________________________________________________________________________________alternative primary alternative primary alternative primary ______________________________________________________________<%{and&&&=_______________________________________________________________ and_eq%>} bitor| or_eq|=_______________________________________________________________ xor_eq<:[or||^=_______________________________________________________________:>]xor^not!______________________________________________________________________________________________________________________________ compl not_eq%:#~!=%:%:##&_______________________________________________________________ bitand2.6 Tokens[lex.token]token:identifierkeywordliteraloperatorpunctuator1There are five kinds of tokens: identifiers, keywords, literals,18) operators, and other separators.
Blanks,horizontal and vertical tabs, newlines, formfeeds, and comments (collectively, “white space”), as describedbelow, are ignored except as they serve to separate tokens. [Note: Some white space is required to separateotherwise adjacent identifiers, keywords, numeric literals, and alternative tokens containing alphabeticcharacters. ]2.7 Comments1[lex.comment]The characters /* start a comment, which terminates with the characters */. These comments do not nest.The characters // start a comment, which terminates with the next new-line character. If there is a formfeed or a vertical-tab character in such a comment, only white-space characters shall appear between it andthe new-line that terminates the comment; no diagnostic is required.
[Note: The comment characters //,/*, and */ have no special meaning within a // comment and are treated just like other characters. Similarly, the comment characters // and /* have no special meaning within a /* comment. ]__________________16) These include “digraphs” and additional reserved words. The term “digraph” (token consisting of two characters) is not perfectlydescriptive, since one of the alternative preprocessing-tokens is %:%: and of course several primary tokens contain two characters.Nonetheless, those alternative tokens that aren’t lexical keywords are colloquially known as “digraphs”.17) Thus the “stringized” values (16.3.2) of [ and <: will be different, maintaining the source spelling, but the tokens can otherwise befreely interchanged.18) Literals include strings and character and numeric literals.12© ISO/IECISO/IEC 14882:1998(E)2 Lexical conventions2.8 Header names2.8 Header names[lex.header]header-name:<h-char-sequence>"q-char-sequence"h-char-sequence:h-charh-char-sequence h-charh-char:any member of the source character set exceptnew-line and >q-char-sequence:q-charq-char-sequence q-charq-char:any member of the source character set exceptnew-line and "1Header name preprocessing tokens shall only appear within a #include preprocessing directive (16.2).The sequences in both forms of header-names are mapped in an implementation-defined manner to headersor to external source file names as specified in 16.2.2If either of the characters ’ or \, or either of the character sequences /* or // appears in a q-charsequence or a h-char-sequence, or the character " appears in a h-char-sequence, the behavior is undefined.19)2.9 Preprocessing numbers[lex.ppnumber]pp-number:digit.
digitpp-number digitpp-number nondigitpp-number e signpp-number E signpp-number .1Preprocessing number tokens lexically include all integral literal tokens (2.13.1) and all floating literaltokens (2.13.3).2A preprocessing number does not have a type or a value; it acquires both after a successful conversion (aspart of translation phase 7, 2.1) to an integral literal token or a floating literal token.2.10 Identifiers[lex.name]identifier:nondigitidentifier nondigitidentifier digit__________________19) Thus, sequences of characters that resemble escape sequences cause undefined behavior.13ISO/IEC 14882:1998(E)© ISO/IEC2.10 Identifiers2 Lexical conventionsnondigit: one ofuniversal-character-name_ a b c d e f g hn o p q r s t uA B C D E F G HN O P Q R S T UivIVjwJWkxKXlyLYmzMZdigit: one of0 1 2 3 4 5 6 7 8 91An identifier is an arbitrarily long sequence of letters and digits.
Each universal-character-name in an identifier shall designate a character whose encoding in ISO 10646 falls into one of the ranges specified inAnnex E. Upper- and lower-case letters are different. All characters are significant.20)2In addition, some identifiers are reserved for use by C++ implementations and standard libraries (17.4.3.1.2)and shall not be used otherwise; no diagnostic is required.2.11 Keywords1[lex.key]The identifiers shown in Table 3 are reserved for use as keywords (that is, they are unconditionally treatedas keywords in phase 7):Table 3—keywords___________________________________________________________________________________ asmdoifreturntypedef autodoubleinlineshorttypeiddynamic_castintsignedtypename boolelselongsizeofunion break caseenummutablestaticunsigned catchexplicitnamespacestatic_castusing charexportnewstructvirtual externoperatorswitchvoid classfalseprivatetemplatevolatile const const_castfloatprotectedthiswchar_t continueforpublicthrowwhile defaultfriendregistertruedeletegotoreinterpret_casttry___________________________________________________________________________________2Furthermore, the alternative representations shown in Table 4 for certain operators and punctuators (2.5) arereserved and shall not be used otherwise:Table 4—alternative representations________________________________________________________ andand_eqbitandbitorcomplnot not_eqoror_eqxorxor_eq__________________________________________________________________________20) On systems in which linkers cannot accept extended characters, an encoding of the universal-character-name may be used in forming valid external identifiers.
For example, some otherwise unused character or sequence of characters may be used to encode the \uin a universal-character-name. Extended characters may produce a long external identifier, but C++ does not place a translation limiton significant characters for external identifiers. In C++, upper- and lower-case letters are considered different for all identifiers,including external identifiers.14© ISO/IECISO/IEC 14882:1998(E)2 Lexical conventions2.12 Operators and punctuators2.12 Operators and punctuators1[lex.operators]The lexical representation of C++ programs includes a number of preprocessing tokens which are used inthe syntax of the preprocessor or are converted into tokens for operators and punctuators:preprocessing-op-or-punc: one of{}[<::><%newdelete ?+*!=<^=&=|=<=>=&&andand_eq bitandoror_eqxor]%>::/><<||bitorxor_eq#%:.%+=>>++compl##%:%:.*^-=>>=-not(;):...&*=<<=,not_eq|/===->*~%=!=->Each preprocessing-op-or-punc is converted to a single token in translation phase 7 (2.1).2.13 Literals1[lex.literal]There are several kinds of literals.21)literal:integer-literalcharacter-literalfloating-literalstring-literalboolean-literal2.13.1 Integer literals[lex.icon]integer-literal:decimal-literal integer-suffixoptoctal-literal integer-suffixopthexadecimal-literal integer-suffixoptdecimal-literal:nonzero-digitdecimal-literal digitoctal-literal:0octal-literal octal-digithexadecimal-literal:0x hexadecimal-digit0X hexadecimal-digithexadecimal-literal hexadecimal-digitnonzero-digit: one of1 2 345678octal-digit: one of0 1 2345679__________________21) The term “literal” generally designates, in this International Standard, those tokens that are called “constants” in ISO C.15ISO/IEC 14882:1998(E)© ISO/IEC2.13.1 Integer literalshexadecimal-digit:0 1a bA B2 Lexical conventionsone of2 3c dC D4eE5fF6789integer-suffix:unsigned-suffix long-suffixoptlong-suffix unsigned-suffixoptunsigned-suffix: one ofu Ulong-suffix: one ofl L1An integer literal is a sequence of digits that has no period or exponent part.
An integer literal may have aprefix that specifies its base and a suffix that specifies its type. The lexically first digit of the sequence ofdigits is the most significant. A decimal integer literal (base ten) begins with a digit other than 0 and consists of a sequence of decimal digits. An octal integer literal (base eight) begins with the digit 0 and consists of a sequence of octal digits.22) A hexadecimal integer literal (base sixteen) begins with 0x or 0X andconsists of a sequence of hexadecimal digits, which include the decimal digits and the letters a through fand A through F with decimal values ten through fifteen.