ECMA-334
5
th
Edition / December 2017
C# Language
Specification
ECMA-334
5
th
Edition / December 2017
C# Language Specification
Ecma International Rue du Rhône 114 CH-1204 Geneva T/F: +41 22 849 6000/01 www.ecma-international.org
.
Table of Contents
iii
Table of Contents
Foreword ............................................................................................................................................ xix
Introduction ........................................................................................................................................ xx
1. Scope ................................................................................................................................................. 1
2. Conformance ..................................................................................................................................... 3
3. Normative references ........................................................................................................................ 5
4. Terms and definitions......................................................................................................................... 7
5. Acronyms and abbreviations .............................................................................................................. 9
6. General description .......................................................................................................................... 11
7. Lexical structure ............................................................................................................................... 13
7.1 Programs ............................................................................................................................................... 13
7.2 Grammars .............................................................................................................................................. 13
7.2.1 General ........................................................................................................................................... 13
7.2.2 Grammar notation ......................................................................................................................... 13
7.2.3 Lexical grammar ............................................................................................................................. 14
7.2.4 Syntactic grammar ......................................................................................................................... 15
7.2.5 Grammar ambiguities .................................................................................................................... 15
7.3 Lexical analysis ...................................................................................................................................... 15
7.3.1 General ........................................................................................................................................... 15
7.3.2 Line terminators ............................................................................................................................. 16
7.3.3 Comments ...................................................................................................................................... 16
7.3.4 White space .................................................................................................................................... 18
7.4 Tokens ................................................................................................................................................... 18
7.4.1 General ........................................................................................................................................... 18
7.4.2 Unicode character escape sequences ............................................................................................ 19
7.4.3 Identifiers ....................................................................................................................................... 19
7.4.4 Keywords ........................................................................................................................................ 21
7.4.5 Literals ............................................................................................................................................ 22
7.4.5.1 General .................................................................................................................................... 22
7.4.5.2 Boolean literals ........................................................................................................................ 22
7.4.5.3 Integer literals ......................................................................................................................... 22
7.4.5.4 Real literals .............................................................................................................................. 23
7.4.5.5 Character literals ..................................................................................................................... 24
7.4.5.6 String literals ........................................................................................................................... 25
7.4.5.7 The null literal ......................................................................................................................... 27
7.4.6 Operators and punctuators ............................................................................................................ 27
7.5 Pre-processing directives ...................................................................................................................... 27
7.5.1 General ........................................................................................................................................... 27
7.5.2 Conditional compilation symbols ................................................................................................... 28
7.5.3 Pre-processing expressions ............................................................................................................ 29
7.5.4 Definition directives ....................................................................................................................... 29
7.5.5 Conditional compilation directives ................................................................................................ 30
7.5.6 Diagnostic directives ...................................................................................................................... 33
7.5.7 Region directives ............................................................................................................................ 33