Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
C-sharp language specification.2004.pdf
Скачиваний:
14
Добавлен:
23.08.2013
Размер:
2.55 Mб
Скачать

Annex A Grammar

1Annex A. Grammar

2This clause is informative.

3This annex contains summaries of the lexical and syntactic grammars found in the main document, and of

4the grammar extensions for unsafe code. Grammar productions appear here in the same order that they

5appear in the main document.

6A.1 Lexical grammar

7input::

8

input-sectionopt

9

input-section::

10

input-section-part

11

input-section input-section-part

12

input-section-part::

13

input-elementsopt new-line

14

pp-directive

15

input-elements::

16

input-element

17

input-elements input-element

18

input-element::

19

whitespace

20

comment

21

token

22A.1.1 Line terminators

23new-line::

24

Carriage return character (U+000D)

25

Line feed character (U+000A)

26

Carriage return character (U+000D) followed by line feed character (U+000A)

27

Next line character (U+0085)

28

Line separator character (U+2028)

29

Paragraph separator character (U+2029)

30A.1.2 White space

31whitespace::

32

whitespace-characters

33

whitespace-characters::

34

whitespace-character

35

whitespace-characters whitespace-character

36

whitespace-character::

37

Any character with Unicode class Zs

38

Horizontal tab character (U+0009)

39

Vertical tab character (U+000B)

40

Form feed character (U+000C)

433

C# LANGUAGE SPECIFICATION

1A.1.3 Comments

2comment::

3

single-line-comment

4

delimited-comment

5 single-line-comment::

6// input-charactersopt

7input-characters::

8

input-character

9

input-characters input-character

10

input-character::

11

Any Unicode character except a new-line-character

12

new-line-character::

13

Carriage return character (U+000D)

14

Line feed character (U+000A)

15

Next line character (U+0085)

16

Line separator character (U+2028)

17

Paragraph separator character (U+2029)

18

delimited-comment::

19

/* delimited-comment-textopt asterisks /

20

delimited-comment-text::

21

delimited-comment-section

22

delimited-comment-text delimited-comment-section

23

delimited-comment-section::

24

not-asterisk

25

asterisks

not-slash

26

asterisks::

 

27

*

 

28

asterisks

*

29

not-asterisk::

 

30

Any Unicode character except *

31

not-slash::

 

32

Any Unicode character except /

33

A.1.4 Tokens

 

34

35

36

37

38

39

40

41

token:: identifier keyword

integer-literal real-literal character-literal string-literal operator-or-punctuator

42A.1.5 Unicode character escape sequences

43unicode-character-escape-sequence::

44

\u

hex-digit

hex-digit

hex-digit

hex-digit

45

\U

hex-digit

hex-digit

hex-digit

hex-digit hex-digit hex-digit hex-digit hex-digit

434

Annex A Grammar

1A.1.6 Identifiers

2identifier::

3

available-identifier

4@ identifier-or-keyword

5available-identifier::

6

An identifier-or-keyword that is not a keyword

7

identifier-or-keyword::

8

identifier-start-character identifier-part-charactersopt

9

identifier-start-character::

10

letter-character

11_ (the underscore character)

12identifier-part-characters::

13

identifier-part-character

14

identifier-part-characters identifier-part-character

15

identifier-part-character::

16

letter-character

17

decimal-digit-character

18

connecting-character

19

combining-character

20

formatting-character

21

letter-character::

22

A Unicode character of classes Lu, Ll, Lt, Lm, Lo, or Nl

23

A unicode-character-escape-sequence representing a character of classes Lu, Ll, Lt, Lm, Lo, or

24

Nl

25

combining-character::

26

A Unicode character of classes Mn or Mc

27

A unicode-character-escape-sequence representing a character of classes Mn or Mc

28

decimal-digit-character::

29

A Unicode character of the class Nd

30

A unicode-character-escape-sequence representing a character of the class Nd

31

connecting-character::

32

A Unicode character of the class Pc

33

A unicode-character-escape-sequence representing a character of the class Pc

34

formatting-character::

35

A Unicode character of the class Cf

36

A unicode-character-escape-sequence representing a character of the class Cf

435

C# LANGUAGE SPECIFICATION

1A.1.7 Keywords

2keyword:: one of

3

abstract

as

base

bool

break

4

byte

case

catch

char

checked

5

class

const

continue

decimal

default

6

delegate

do

double

else

enum

7

event

explicit

extern

false

finally

8

fixed

float

for

foreach

goto

9

if

implicit

in

int

interface

10

internal

is

lock

long

namespace

11

new

null

object

operator

out

12

override

params

private

protected

public

13

readonly

ref

return

sbyte

sealed

14

short

sizeof

stackalloc

static

string

15

struct

switch

this

throw

true

16

try

typeof

uint

ulong

unchecked

17

unsafe

ushort

using

virtual

void

18

volatile

while

 

 

 

19A.1.8 Literals

20literal::

21

boolean-literal

22

integer-literal

23

real-literal

24

character-literal

25

string-literal

26

null-literal

27

boolean-literal::

28

true

29false

30integer-literal::

31

decimal-integer-literal

 

 

 

 

32

hexadecimal-integer-literal

 

 

 

33

decimal-integer-literal::

 

 

 

 

 

34

decimal-digits integer-type-suffixopt

 

35

decimal-digits::

 

 

 

 

 

 

 

36

decimal-digit

 

 

 

 

 

 

37

decimal-digits decimal-digit

 

 

38

decimal-digit:: one of

 

 

 

 

 

39

0

1

2

3

4

5

6

7

8

9

40

integer-type-suffix::

one of

 

 

 

 

41

U

u

L

l

UL Ul uL ul LU Lu lU lu

42

hexadecimal-integer-literal::

 

 

 

43

0x

hex-digits

integer-type-suffixopt

 

440X hex-digits integer-type-suffixopt

45hex-digits::

46

hex-digit

47

hex-digits hex-digit

48

hex-digit:: one of

49

0 1 2 3 4 5 6 7 8 9 A B C D E F a b c d e f

436

Annex A Grammar

1

real-literal::

2

decimal-digits . decimal-digits exponent-partopt real-type-suffixopt

3

. decimal-digits exponent-partopt real-type-suffixopt

4

decimal-digits exponent-part real-type-suffixopt

5

decimal-digits real-type-suffix

6

exponent-part::

7

e signopt decimal-digits

8

E signopt decimal-digits

9

sign:: one of

10+ -

11real-type-suffix:: one of

12

F f D d M m

13 character-literal::

14' character '

15character::

16

single-character

17

simple-escape-sequence

18

hexadecimal-escape-sequence

19

unicode-character-escape-sequence

20

single-character::

21

Any character except ' (U+0027), \ (U+005C), and new-line-character

22

simple-escape-sequence:: one of

23

\' \" \\ \0 \a \b \f \n \r \t \v

24

hexadecimal-escape-sequence::

25

\x hex-digit hex-digitopt hex-digitopt hex-digitopt

26

string-literal::

27

regular-string-literal

28

verbatim-string-literal

29 regular-string-literal::

30" regular-string-literal-charactersopt "

31regular-string-literal-characters::

32

regular-string-literal-character

33

regular-string-literal-characters regular-string-literal-character

34

regular-string-literal-character::

35

single-regular-string-literal-character

36

simple-escape-sequence

37

hexadecimal-escape-sequence

38

unicode-character-escape-sequence

39

single-regular-string-literal-character::

40

Any character except " (U+0022), \ (U+005C), and new-line-character

41 verbatim-string-literal::

42@" verbatim -string-literal-charactersopt "

43verbatim-string-literal-characters::

44

verbatim-string-literal-character

45

verbatim-string-literal-characters verbatim-string-literal-character

46

verbatim-string-literal-character::

47

single-verbatim-string-literal-character

48

quote-escape-sequence

437

Соседние файлы в предмете Электротехника