This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!
22.2 Lexical structure Grammar
2.2 Grammar notation
- nonsense:
- terminal1
terminal2
- letter: one of
- A B C a b c
- letter: one of
- A
B
C
a
b
c
- whole:
- first-part second-partopt last-part
- whole:
- first-part last-part
first-part second-part last-part
2.3 Pre-processing
- pp-unit:
- pp-groupopt
- pp-group:
- pp-group-part
pp-group pp-group-part
- pp-group-part:
- pp-tokensopt new-line
pp-declaration
pp-if-section
pp-control-line
pp-line-number
- pp-tokens:
- pp-token
pp-tokens pp-token
- pp-token:
- identifier
keyword
literal
operator-or-punctuator
- new-line:
- The carriage return character (U+000D)
The line feed character (U+000A)
The carriage return character followed by a line feed character
The line separator character (U+2028)
The paragraph separator character (U+2029)
2.3.1 Pre-processing declarations
- pp-declaration:
- #define pp-identifier
#undef pp-identifier
2.3.2 #if, #elif, #else, #endif
- pp-if-section:
- pp-if-group pp-elif-groupsopt pp-else-groupopt pp-endif-line
- pp-if-group:
- #if pp-expression new-line pp-groupopt
- pp-elif-groups
- pp-elif-group
pp-elif-groups pp-elif-group
- pp-elif-group:
- #elif pp-expression new-line groupopt
- pp-else-group:
- #else new-line groupopt
- pp-endif-line
- #endif new-line
2.3.3 Pre-processing control lines
- pp-control-line:
- #error pp-message
#warning pp-message
- pp-message:
- pp-tokensopt
2.3.4 #line
- pp-line-number:
- #line integer-literal
#line integer-literal string-literal
- pp-integer-literal:
- decimal-digit
decimal-digits decimal-digit
- pp-string-literal:
- " pp-string-literal-characters "
- pp-string-literal-characters:
- pp-string-literal-character
pp-string-literal-characters pp-string-literal-character
2.3.5 pp-string-literal-character:
Any character except " (U+0022), and white-spacePre-processing identifiers
- pp-identifier:
- pp-available-identifier
- pp-available-identifier:
- A pp-identifier-or-keyword that is not true or false
- pp-identifier-or-keyword:
- identifier-start-character identifier-part-charactersopt
2.3.6 Pre-processing expressions
- pp-expression:
- pp-equality-expression
- pp-primary-expression:
- true
false
pp-identifier
( pp-expression )
- pp-unary-expression:
- pp-primary-expression
! pp-unary-expression
- pp-equality-expression:
- pp-equality-expression == pp-logical-and-expression
pp-equality-expression != pp-logical-and-expression
- pp-logical-and-expression:
- pp-unary-expression
pp-logical-and-expression && pp-unary-expression
- pp-logical-or-expression:
- pp-logical-and-expression
pp-logical-or-expression || pp-logical-and-expression
2.4.1 Input
- input:
- input-elementsopt
- input-elements:
- input-element
input-elements input-element
- input-element:
- comment
white-space
token
2.4.2 Input characters
- input-character:
- any Unicode character
2.4.3 Line terminators
- line-terminator:
- TBD
2.4.4 Comments
- comment:
- TBD
2.4.5 White space
- white-space:
- new-line
The tab character (U+0009)
The vertical tab character (U+000B)
The form feed character (U+000C)
The "control-Z" or "substitute" character (U+001A)
All characters with Unicode class "Zs"
2.4.6 Tokens
- token:
- identifier
keyword
literal
operator-or-punctuator
2.5 Processing of Unicode character escape sequences
- unicode-character-escape-sequence:
- \u hex-digit hex-digit hex-digit hex-digit
2.5.1 Identifiers
- identifier:
- available-identifier
@ identifier-or-keyword
- available-identifier:
- An identifier-or-keyword that is not a keyword
- identifier-or-keyword:
- identifier-start-character identifier-part-charactersopt
- identifier-start-character:
- letter-character
underscore-character
- identifier-part-characters:
- identifier-part-character
identifier-part-characters identifier-part-character
- identifier-part-character:
- letter-character
combining-character
decimal-digit-character
underscore-character
- letter-character:
- A Unicode character of classes Lu, Ll, Lt, Lm, Lo, or Nl
A unicode-character-escape-sequence representing a character of classes Lu, Ll, Lt, Lm, Lo, or Nl
- combining-character:
- A Unicode character of classes Mn or Mc
A unicode-character-escape-sequence representing a character of classes Mn or Mcdecimal-digit-character:
A Unicode character of the class Nd
A unicode-character-escape-sequence representing a character of the class Nd
- underscore-character:
- A Unicode character of the class Pc
A unicode-character-escape-sequence representing a character of the class Pc
2.5.2 Keywords
- keyword: one of
- abstract base bool break byte
case catch char checked class
const continue decimal default delegate
do double else enum event
explicit extern false finally fixed
float for foreach goto if
implicit in int interface internal
is lock long namespace new
null object operator out override
params private protected public readonly
ref return sbyte sealed short
sizeof static string struct switch
this throw true try typeof
uint ulong unchecked unsafe ushort
using virtual void while
2.5.3 Literals
- literal:
- boolean-literal
integer-literal
real-literal
character-literal
string-literal
null-literal
2.5.3.1 Boolean literals
- boolean-literal:
- true
false
2.5.3.2 Integer literals
- integer-literal:
- decimal-integer-literal
hexadecimal-integer-literal
- decimal-integer-literal:
- decimal-digits integer-type-suffixopt
- decimal-digits:
- decimal-digit
decimal-digits decimal-digit
- decimal-digit: one of
- 0 1 2 3 4 5 6 7 8 9
- integer-type-suffix: one of
- U u L l UL Ul uL ul LU Lu lU lu
- hexadecimal-integer-literal:
- 0x hex-digits integer-type-suffixopt
- hex-digits:
- hex-digit
hex-digits hex-digit
- hex-digit: one of
- 0 1 2 3 4 5 6 7 8 9 A B C D E F a b c d e f
2.5.3.3 Real literals
- real-literal:
- decimal-digits . decimal-digits exponent-partopt real-type-suffixopt
. decimal-digits exponent-partopt real-type-suffixopt
decimal-digits exponent-part real-type-suffixopt
decimal-digits real-type-suffix
- exponent-part:
- e signopt decimal-digits
E signopt decimal-digits
- sign: one of
- + -
- real-type-suffix: one of
- F f D d M m
2.5.3.4 Character literals
- character-literal:
- ' character '
- character:
- single-character
simple-escape-sequence
hexadecimal-escape-sequence
unicode-character-escape-sequence
- single-character:
- Any character except ' (U+0027), \ (U+005C), and white-space other than space (U+0020)
- simple-escape-sequence: one of
- \' \" \\ \0 \a \b \f \n \r \t \v
- hexadecimal-escape-sequence:
- \x hex-digit hex-digitopt hex-digitopt hex-digitopt
2.5.3.5 String literals
- string-literal:
- regular-string-literal
verbatim-string-literal
- regular-string-literal:
- " regular-string-literal-charactersopt "
- regular-string-literal-characters:
- regular-string-literal-character
regular-string-literal-characters regular-string-literal-character
- regular-string-literal-character:
- single-regular-string-literal-character
simple-escape-sequence
hexadecimal-escape-sequence
unicode-character-escape-sequence
- single-regular-string-literal-character:
- Any character except " (U+0022), \ (U+005C), and white-space other than space (U+0020)
- verbatim-string-literal:
- @" verbatim -string-literal-charactersopt "
- verbatim-string-literal-characters:
- verbatim-string-literal-character
verbatim-string-literal-characters verbatim-string-literal-character
- verbatim-string-literal-character:
- single-verbatim-string-literal-character
quote-escape-sequence
- single-verbatim-string-literal-character:
- any character except "
- quote-escape-sequence:
- ""
2.5.3.6 The null literal
- null-literal:
- null
2.5.4 Operators and punctuators
- operator-or-punctuator: one of
- { } [ ] ( ) . , : ;
+ - * / % & | ^ ! ~
= < > ? ++ -- && || << >>
== != <= >= += -= *= /= %= &=
|= ^= <<= >>= ->