13.07.2015 Views

C# Language Specification - Willy .Net

C# Language Specification - Willy .Net

C# Language Specification - Willy .Net

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 5 Notational conventions5. Notational conventionsLexical and syntactic grammars for <strong>C#</strong> are interspersed throughout this specification. The lexical grammardefines how characters can be combined to form tokens (§9.4), the minimal lexical elements of the language.The syntactic grammar defines how tokens can be combined to make valid <strong>C#</strong> programs.Grammar productions include both non-terminal and terminal symbols. In grammar productions, nonterminalsymbols are shown in italic type, and terminal symbols are shown in a fixed-width font. Eachnon-terminal is defined by a set of productions. The first line of a set of productions is the name of the nonterminal,followed by one or two colons. One colon is used for a production in the syntactic grammar, twocolons for a production in the lexical grammar. Each successive indented line contains the right-hand sidefor a production that has the non-terminal symbol as the left-hand side. For example:class-modifier:newpublicprotectedinternalprivateabstractsealeddefines the class-modifier non-terminal as having seven productions.Alternatives are normally listed on separate lines, as shown above, though in cases where there are manyalternatives, the phrase “one of” precedes a list of the options. This is simply shorthand for listing each ofthe alternatives on a separate line. For example:decimal-digit: one of0 1 2 3 4 5 6 7 8 9is equivalent to:decimal-digit:0123456789A subscripted suffix “ opt ”, as in identifier opt , is used as shorthand to indicate an optional symbol. Theexample:for-statement:for ( for-initializer opt ; for-condition opt ; for-iterator opt ) embedded-statementis equivalent to:9

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!