2010-01-03 Zoltan Varga <vargaz@gmail.com>
[mcs.git] / docs / ecma334 / 5.xml
blob71b5e207be0a3fb5949f5398f98132fff1d2f721
1 <?xml version="1.0"?>
2 <clause number="5" title="Notational conventions">
3   <paragraph>Lexical and syntactic grammars for C# are interspersed throughout this specification. The lexical grammar defines how characters can be combined to form tokens (<hyperlink>9.4</hyperlink>), the minimal lexical elements of the language. The syntactic grammar defines how tokens can be combined to make valid C# programs. </paragraph>
4   <paragraph>Grammar productions include both non-terminal and terminal symbols. In grammar productions,  non-terminal symbols are shown in italic type, and terminal symbols are shown in a fixed-width font. Each non-terminal is defined by a set of productions. The first line of a set of productions is the name of the  non-terminal, followed by a colon. Each successive indented line contains the right-hand side for a production that has the non-terminal symbol as the left-hand side. For example: <grammar_production><name><non_terminal where="17.1.1">class-modifier</non_terminal></name> : <rhs><keyword>new</keyword></rhs><rhs><keyword>public</keyword></rhs><rhs><keyword>protected</keyword></rhs><rhs><keyword>internal</keyword></rhs><rhs><keyword>private</keyword></rhs><rhs><keyword>abstract</keyword></rhs><rhs><keyword>sealed</keyword></rhs></grammar_production>defines the <non_terminal where="17.1.1">class-modifier</non_terminal> non-terminal as having seven productions. </paragraph>
5   <paragraph>Alternatives are normally listed on separate lines, as shown above, though in cases where there are many alternatives, the phrase &quot;one of&quot; precedes a list of the options. This is simply shorthand for listing each of the alternatives on a separate line. For example: <grammar_production><name><non_terminal where="9.4.4.2">decimal-digit</non_terminal></name> : one of <rhs><terminal>0</terminal><terminal>1</terminal><terminal>2</terminal><terminal>3</terminal><terminal>4</terminal><terminal>5</terminal><terminal>6</terminal><terminal>7</terminal><terminal>8</terminal><terminal>9</terminal></rhs></grammar_production>is equivalent to: <grammar_production><name><non_terminal where="9.4.4.2">decimal-digit</non_terminal></name> : <rhs><terminal>0</terminal></rhs><rhs><terminal>1</terminal></rhs><rhs><terminal>2</terminal></rhs><rhs><terminal>3</terminal></rhs><rhs><terminal>4</terminal></rhs><rhs><terminal>5</terminal></rhs><rhs><terminal>6</terminal></rhs><rhs><terminal>7</terminal></rhs><rhs><terminal>8</terminal></rhs><rhs><terminal>9</terminal></rhs></grammar_production></paragraph>
6   <paragraph>A subscripted suffix &quot;opt&quot;, as in identifier<opt/>, is used as shorthand to indicate an optional symbol. The example: <grammar_production><name><non_terminal where="15.8.3">for-statement</non_terminal></name> : <rhs><keyword>for</keyword><terminal>(</terminal><non_terminal where="15.8.3">for-initializer</non_terminal><opt/><terminal>;</terminal><non_terminal where="15.8.3">for-condition</non_terminal><opt/><terminal>;</terminal><non_terminal where="15.8.3">for-iterator</non_terminal><opt/><terminal>)</terminal><non_terminal where="15">embedded-statement</non_terminal></rhs></grammar_production>is equivalent to: <grammar_production><name><non_terminal where="15.8.3">for-statement</non_terminal></name> : <rhs><keyword>for</keyword><terminal>(</terminal><terminal>;</terminal><terminal>;</terminal><terminal>)</terminal><non_terminal where="15">embedded-statement</non_terminal></rhs><rhs><keyword>for</keyword><terminal>(</terminal><non_terminal where="15.8.3">for-initializer</non_terminal><terminal>;</terminal><terminal>;</terminal><terminal>)</terminal><non_terminal where="15">embedded-statement</non_terminal></rhs><rhs><keyword>for</keyword><terminal>(</terminal><terminal>;</terminal><non_terminal where="15.8.3">for-condition</non_terminal><terminal>;</terminal><terminal>)</terminal><non_terminal where="15">embedded-statement</non_terminal></rhs><rhs><keyword>for</keyword><terminal>(</terminal><terminal>;</terminal><terminal>;</terminal><non_terminal where="15.8.3">for-iterator</non_terminal><terminal>)</terminal><non_terminal where="15">embedded-statement</non_terminal></rhs><rhs><keyword>for</keyword><terminal>(</terminal><non_terminal where="15.8.3">for-initializer</non_terminal><terminal>;</terminal><non_terminal where="15.8.3">for-condition</non_terminal><terminal>;</terminal><terminal>)</terminal><non_terminal where="15">embedded-statement</non_terminal></rhs><rhs><keyword>for</keyword><terminal>(</terminal><terminal>;</terminal><non_terminal where="15.8.3">for-condition</non_terminal><terminal>;</terminal><non_terminal where="15.8.3">for-iterator</non_terminal><terminal>)</terminal><non_terminal where="15">embedded-statement</non_terminal></rhs><rhs><keyword>for</keyword><terminal>(</terminal><non_terminal where="15.8.3">for-initializer</non_terminal><terminal>;</terminal><terminal>;</terminal><non_terminal where="15.8.3">for-iterator</non_terminal><terminal>)</terminal><non_terminal where="15">embedded-statement</non_terminal></rhs><rhs><keyword>for</keyword><terminal>(</terminal><non_terminal where="15.8.3">for-initializer</non_terminal><terminal>;</terminal><non_terminal where="15.8.3">for-condition</non_terminal><terminal>;</terminal><non_terminal where="15.8.3">for-iterator</non_terminal><terminal>)</terminal><non_terminal where="15">embedded-statement</non_terminal></rhs></grammar_production></paragraph>
7   <paragraph>All terminal characters are to be understood as the appropriate Unicode character from the ASCII range, as opposed to any similar-looking characters from other Unicode ranges. </paragraph>
8 </clause>