Gramática léxica de CC lexical grammar

TokensTokens

token :token :
keyword
identifier
constant
string-literal
punctuator

preprocessing-token :preprocessing-token :
header-name
identifier
pp-number
character-constant
string-literal
punctuator
 cada carácter que no sea un espacio en blanco que no pueda ser uno de los anteriores each non-whitespace character that can't be one of the above

Palabras claveKeywords

keyword : uno dekeyword : one of
auto break case char const continueauto break case char const continue
default do double else enum externdefault do double else enum extern
float for goto if inline int longfloat for goto if inline int long
register restrict return short signedregister restrict return short signed
sizeof static struct switch typedef unionsizeof static struct switch typedef union
unsigned void volatile while _Alignasunsigned void volatile while _Alignas
_Alignof _Atomic _Bool _Complex _Generic_Alignof _Atomic _Bool _Complex _Generic
_Imaginary _Noreturn _Static_assert_Imaginary _Noreturn _Static_assert
_Thread_local

Para una lista de otras palabras clave específicas de Microsoft, consulte Palabras clave de C.For a list of additional Microsoft-specific keywords, see C keywords.

IdentificadoresIdentifiers

identifier :identifier :
identifier-nondigit
identifier identifier-nondigitidentifier identifier-nondigit
identifier digitidentifier digit

identifier-nondigit :identifier-nondigit :
nondigit
universal-character-name
 otros caracteres definidos por la implementación other implementation-defined characters

nondigit : uno denondigit : one of
_ a b c d e f g h i j k l m_ a b c d e f g h i j k l m
n o p q r s t u v w x y zn o p q r s t u v w x y z
A B C D E F G H I J K L MA B C D E F G H I J K L M
N O P Q R S T U V W X Y ZN O P Q R S T U V W X Y Z

digit : uno dedigit : one of
0 1 2 3 4 5 6 7 8 90 1 2 3 4 5 6 7 8 9

universal-character-name :universal-character-name :
\u hex-quad\u hex-quad
\U hex-quad hex-quad\U hex-quad hex-quad

hex-quad :hex-quad :
hexadecimal-digit hexadecimal-digit hexadecimal-digit hexadecimal-digithexadecimal-digit hexadecimal-digit hexadecimal-digit hexadecimal-digit

ConstantesConstants

constant :constant :
integer-constant
floating-constant
enumeration-constant
character-constant

integer-constant :integer-constant :
decimal-constant integer-suffix opt\ decimal-constant integer-suffixopt</span> binary-constant 1 integer-suffix optbinary-constant1 integer-suffixopt
octal-constant integer-suffix opt\ octal-constant integer-suffixopt</span> hexadecimal-constant integer-suffix opthexadecimal-constant integer-suffixopt

decimal-constant :decimal-constant :
nonzero-digit
decimal-constant digitdecimal-constant digit

binary-constant :1binary-constant :1
binary-prefix binary-digitbinary-prefix binary-digit
binary-constant binary-digitbinary-constant binary-digit

binary-prefix 1: uno debinary-prefix1: one of
0b 0B0b 0B

binary-digit 1: uno debinary-digit1: one of
0 10 1

octal-constant :octal-constant :
0
octal-constant octal-digitoctal-constant octal-digit

hexadecimal-constant :hexadecimal-constant :
hexadecimal-prefix hexadecimal-digithexadecimal-prefix hexadecimal-digit
hexadecimal-constant hexadecimal-digithexadecimal-constant hexadecimal-digit

hexadecimal-prefix : uno dehexadecimal-prefix : one of
0x 0X0x 0X

nonzero-digit : uno denonzero-digit : one of
1 2 3 4 5 6 7 8 91 2 3 4 5 6 7 8 9

octal-digit : uno deoctal-digit : one of
0 1 2 3 4 5 6 70 1 2 3 4 5 6 7

hexadecimal-digit : uno dehexadecimal-digit : one of
0 1 2 3 4 5 6 7 80 1 2 3 4 5 6 7 8
a b c d e fa b c d e f
A B C D E FA B C D E F

integer-suffix :integer-suffix :
unsigned-suffix long-suffix opt\ unsigned-suffix long-suffixopt</span> unsigned-suffix long-long-suffix opt\ unsigned-suffix long-long-suffixopt</span> long-suffix unsigned-suffix opt\ long-suffix unsigned-suffixopt</span> long-long-suffix unsigned-suffix optlong-long-suffix unsigned-suffixopt

unsigned-suffix : uno deunsigned-suffix : one of
u Uu U

long-suffix : uno delong-suffix : one of
l Ll L

long-long-suffix : uno delong-long-suffix : one of
ll LLll LL

floating-constant :floating-constant :
decimal-floating-constant
hexadecimal-floating-constant

decimal-floating-constant :decimal-floating-constant :
fractional-constant exponent-part opt floating-suffix optfractional-constant exponent-partopt floating-suffixopt
digit-sequence exponent-part floating-suffix optdigit-sequence exponent-part floating-suffixopt

hexadecimal-floating-constant :hexadecimal-floating-constant :
hexadecimal-prefix hexadecimal-fractional-constant binary-exponent-part opt floating-suffix opthexadecimal-prefix hexadecimal-fractional-constant binary-exponent-partopt floating-suffixopt
hexadecimal-prefix hexadecimal-digit-sequence binary-exponent-part floating-suffix opthexadecimal-prefix hexadecimal-digit-sequence binary-exponent-part floating-suffixopt

fractional-constant :fractional-constant :
digit-sequence opt . digit-sequence digit-sequenceopt . digit-sequence
digit-sequence .digit-sequence .

exponent-part :exponent-part :
e sign opt digit-sequence\ e signopt digit-sequence</span> E sign opt digit-sequenceE signopt digit-sequence

sign : uno design : one of
+ -+ -

digit-sequence :digit-sequence :
digit
digit-sequence digitdigit-sequence digit

hexadecimal-fractional-constant :hexadecimal-fractional-constant :
hexadecimal-digit-sequence opt . hexadecimal-digit-sequence hexadecimal-digit-sequenceopt . hexadecimal-digit-sequence
hexadecimal-digit-sequence .hexadecimal-digit-sequence .

binary-exponent-part :binary-exponent-part :
p sign opt digit-sequence\ p signopt digit-sequence</span> P sign opt digit-sequenceP signopt digit-sequence

hexadecimal-digit-sequence :hexadecimal-digit-sequence :
hexadecimal-digit
hexadecimal-digit-sequence hexadecimal-digithexadecimal-digit-sequence hexadecimal-digit

floating-suffix : uno defloating-suffix : one of
f l F Lf l F L

enumeration-constant :enumeration-constant :
identifier

character-constant :character-constant :
' c-char-sequence '' c-char-sequence '
L' c-char-sequence 'L' c-char-sequence '

c-char-sequence :c-char-sequence :
c-char
c-char-sequence c-charc-char-sequence c-char

c-char :c-char :
 Cualquier miembro del juego de caracteres de origen, excepto la comilla simple ( ' ), la barra diagonal inversa ( \ ) o el carácter de nueva línea Any member of the source character set except the single quotation mark ( ' ), backslash ( \ ), or newline character
escape-sequence

escape-sequence :escape-sequence :
simple-escape-sequence
octal-escape-sequence
hexadecimal-escape-sequence
universal-character-name

simple-escape-sequence : uno desimple-escape-sequence : one of
\a \b \f \n \r \t \v\a \b \f \n \r \t \v
\' \" \\ \?\' \" \\ \?

octal-escape-sequence :octal-escape-sequence :
\ octal-digit\ octal-digit
\ octal-digit octal-digit\ octal-digit octal-digit
\ octal-digit octal-digit octal-digit\ octal-digit octal-digit octal-digit

hexadecimal-escape-sequence :hexadecimal-escape-sequence :
\x hexadecimal-digit\x hexadecimal-digit
hexadecimal-escape-sequence hexadecimal-digithexadecimal-escape-sequence hexadecimal-digit

Literales de cadenaString literals

string-literal :string-literal :
encoding-prefix s-char-sequence opt "encoding-prefix s-char-sequenceopt "

encoding-prefix :encoding-prefix :
u8
u
U
L

s-char-sequence :s-char-sequence :
s-char
s-char-sequence s-chars-char-sequence s-char

s-char :s-char :
 cualquier miembro del juego de caracteres de origen, excepto las comillas dobles ( " ), la barra diagonal inversa ( \ ) o el carácter de nueva línea any member of the source character set except the double-quotation mark ( " ), backslash ( \ ), or newline character
escape-sequence

Signos de puntuaciónPunctuators

punctuator : uno depunctuator : one of
[ ] ( ) { } . ->[ ] ( ) { } . ->
++ -- & * + - ~ !++ -- & * + - ~ !
/ % << >> < > <= >= ==/ % << >> < > <= >= ==
!= ^ | && || ? : ; ...!= ^ | && || ? : ; ...
= *= /= %= += -= <<= >>== *= /= %= += -= <<= >>=
&= ^= |= , # ##&= ^= |= , # ##
<: :> <% %> %: %:%:<: :> <% %> %: %:%:

Nombres de encabezadosHeader names

header-name :header-name :
< h-char-sequence >< h-char-sequence >
" q-char-sequence "" q-char-sequence "

h-char-sequence :h-char-sequence :
h-char
h-char-sequence h-charh-char-sequence h-char

h-char :h-char :
 cualquier miembro del juego de caracteres de origen, excepto el carácter de nueva línea y > any member of the source character set except the new-line character and >

q-char-sequence :q-char-sequence :
q-char
q-char-sequence q-charq-char-sequence q-char

q-char :q-char :
 cualquier miembro del juego de caracteres de origen, excepto el carácter de nueva línea y " any member of the source character set except the new-line character and "

Preprocesamiento de númerosPreprocessing numbers

pp-number :pp-number :
digit
. digit. digit
pp-number digit pp-number digit
pp-number identifier-nondigitpp-number identifier-nondigit
pp-number e signpp-number e sign
pp-number E signpp-number E sign
pp-number p signpp-number p sign
pp-number P signpp-number P sign
pp-number .pp-number .

1 binary-constant , binary-prefix y binary-digit son extensiones específicas de Microsoft.1 binary-constant , binary-prefix , and binary-digit are Microsoft-specific extensions.

Vea tambiénSee also

Resumen de la sintaxis de lenguaje CC Language Syntax Summary