a575963da9
Former-commit-id: da6be194a6b1221998fc28233f2503bd61dd9d14
29 lines
3.9 KiB
XML
29 lines
3.9 KiB
XML
<?xml version="1.0"?>
|
|
<clause number="9.3.2" title="Comments">
|
|
<paragraph>Two forms of comments are supported: delimited comments and single-line comments. </paragraph>
|
|
<paragraph>A delimited comment begins with the characters /* and ends with the characters */. Delimited comments can occupy a portion of a line, a single line, or multiple lines. <example>[Example: The example <code_example><![CDATA[
|
|
/* Hello, world program
|
|
This program writes "hello, world" to the console
|
|
*/
|
|
class Hello
|
|
{
|
|
static void Main() {
|
|
System.Console.WriteLine("hello, world");
|
|
}
|
|
}
|
|
]]></code_example>includes a delimited comment. end example]</example> </paragraph>
|
|
<paragraph>A single-line comment begins with the characters // and extends to the end of the line. <example>[Example: The example <code_example><![CDATA[
|
|
// Hello, world program
|
|
// This program writes "hello, world" to the console
|
|
//
|
|
class Hello // any name will do for this class
|
|
{
|
|
static void Main() { // this method must be named "Main"
|
|
System.Console.WriteLine("hello, world");
|
|
}
|
|
}
|
|
]]></code_example>shows several single-line comments. end example]</example> <grammar_production><name>comment</name> :: <rhs><non_terminal where="9.3.2">single-line-comment</non_terminal></rhs><rhs><non_terminal where="9.3.2">delimited-comment</non_terminal></rhs></grammar_production><grammar_production><name><non_terminal where="9.3.2">single-line-comment</non_terminal></name> :: <rhs><terminal>//</terminal><non_terminal where="9.3.2">input-characters</non_terminal><opt/></rhs></grammar_production><grammar_production><name><non_terminal where="9.3.2">input-character</non_terminal>s</name> :: <rhs><non_terminal where="9.3.2">input-character</non_terminal></rhs><rhs><non_terminal where="9.3.2">input-characters</non_terminal><non_terminal where="9.3.2">input-character</non_terminal></rhs></grammar_production><grammar_production><name><non_terminal where="9.3.2">input-character</non_terminal></name> :: <rhs>Any Unicode character except a <non_terminal where="9.3.2">new-line-character</non_terminal> </rhs></grammar_production><grammar_production><name><non_terminal where="9.3.2">new-line-character</non_terminal></name> :: <rhs>Carriage return character (U+000D) </rhs><rhs>Line feed character (U+000A) </rhs><rhs>Line separator character (U+2028) </rhs><rhs>Paragraph separator character (U+2029) </rhs></grammar_production><grammar_production><name><non_terminal where="9.3.2">delimited-comment</non_terminal></name> :: <rhs><terminal>/*</terminal><non_terminal where="9.3.2">delimited-comment-characters</non_terminal><opt/><terminal>*/</terminal></rhs></grammar_production><grammar_production><name><non_terminal where="9.3.2">delimited-comment-character</non_terminal>s</name> :: <rhs><non_terminal where="9.3.2">delimited-comment-character</non_terminal></rhs><rhs><non_terminal where="9.3.2">delimited-comment-characters</non_terminal><non_terminal where="9.3.2">delimited-comment-character</non_terminal></rhs></grammar_production><grammar_production><name><non_terminal where="9.3.2">delimited-comment-character</non_terminal></name> :: <rhs><non_terminal where="9.3.2">not-asterisk</non_terminal></rhs><rhs><terminal>*</terminal><non_terminal where="9.3.2">not-slash</non_terminal></rhs></grammar_production><grammar_production><name><non_terminal where="9.3.2">not-asterisk</non_terminal></name> :: <rhs>Any Unicode character except * </rhs></grammar_production><grammar_production><name><non_terminal where="9.3.2">not-slash</non_terminal></name> :: <rhs>Any Unicode character except / </rhs></grammar_production></paragraph>
|
|
<paragraph>Comments do not nest. The character sequences /* and */ have no special meaning within a single-line comment, and the character sequences // and /* have no special meaning within a delimited comment. </paragraph>
|
|
<paragraph>Comments are not processed within character and string literals. </paragraph>
|
|
</clause>
|