mirror of
https://github.com/golang/go
synced 2024-09-15 22:20:06 +00:00
fix up grammar for optional elements in if and switch conditions
SVN=122915
This commit is contained in:
parent
39b28df01e
commit
daebf91d2c
|
@ -1582,10 +1582,10 @@ If statements
|
||||||
|
|
||||||
If statements have the traditional form except that the
|
If statements have the traditional form except that the
|
||||||
condition need not be parenthesized and the "then" statement
|
condition need not be parenthesized and the "then" statement
|
||||||
must be in brace brackets. The condition may be omitted in which
|
must be in brace brackets. The condition may be omitted, in which
|
||||||
case it is assumed to have the value "true".
|
case it is assumed to have the value "true".
|
||||||
|
|
||||||
IfStat = "if" [ [ SimpleStat ";" ] Expression ] Block [ "else" Statement ] .
|
IfStat = "if" [ [ Simplestat ] ";" ] [ Condition ] Block [ "else" Statement ] .
|
||||||
|
|
||||||
if x > 0 {
|
if x > 0 {
|
||||||
return true;
|
return true;
|
||||||
|
@ -1593,8 +1593,7 @@ case it is assumed to have the value "true".
|
||||||
|
|
||||||
An "if" statement may include the declaration of a single temporary variable.
|
An "if" statement may include the declaration of a single temporary variable.
|
||||||
The scope of the declared variable extends to the end of the if statement, and
|
The scope of the declared variable extends to the end of the if statement, and
|
||||||
the variable is initialized once before the statement is entered. If a variable
|
the variable is initialized once before the statement is entered.
|
||||||
is declared, the condition cannot be omitted.
|
|
||||||
|
|
||||||
if x := f(); x < y {
|
if x := f(); x < y {
|
||||||
return x;
|
return x;
|
||||||
|
@ -1610,7 +1609,7 @@ Switch statements
|
||||||
|
|
||||||
Switches provide multi-way execution.
|
Switches provide multi-way execution.
|
||||||
|
|
||||||
SwitchStat = "switch" [ [ SimpleStat ";" ] Expression ] "{" { CaseClause } "}" .
|
SwitchStat = "switch" [ [ Simplestat ] ";" ] [ Expression ] "{" { CaseClause } "}" .
|
||||||
CaseClause = CaseList StatementList [ ";" ] [ "fallthrough" [ ";" ] ] .
|
CaseClause = CaseList StatementList [ ";" ] [ "fallthrough" [ ";" ] ] .
|
||||||
CaseList = Case { Case } .
|
CaseList = Case { Case } .
|
||||||
Case = ( "case" ExpressionList | "default" ) ":" .
|
Case = ( "case" ExpressionList | "default" ) ":" .
|
||||||
|
|
Loading…
Reference in a new issue