mirror of
https://github.com/golang/go
synced 2024-11-25 12:57:58 -07:00
- changed if/switch initial stat syntax to match go compiler and make
it consistent - changed declaration syntax to match go compiler SVN=112122
This commit is contained in:
parent
7acb294d58
commit
78e4320fdc
@ -878,7 +878,7 @@ A variable declaration creates a variable and gives it a type and a name.
|
|||||||
It may optionally give the variable an initial value; in some forms of
|
It may optionally give the variable an initial value; in some forms of
|
||||||
declaration the type of the initial value defines the type of the variable.
|
declaration the type of the initial value defines the type of the variable.
|
||||||
|
|
||||||
VarDecl = "var" ( VarSpec | "(" VarSpecList [ ";" ] ")" ) | SimpleVarDecl .
|
VarDecl = "var" ( VarSpec | "(" VarSpecList [ ";" ] ")" ) .
|
||||||
VarSpec = IdentifierList ( Type [ "=" ExpressionList ] | "=" ExpressionList ) .
|
VarSpec = IdentifierList ( Type [ "=" ExpressionList ] | "=" ExpressionList ) .
|
||||||
VarSpecList = VarSpec { ";" VarSpec } .
|
VarSpecList = VarSpec { ";" VarSpec } .
|
||||||
|
|
||||||
@ -1102,7 +1102,7 @@ Statements control execution.
|
|||||||
Block | IfStat | SwitchStat | ForStat | RangeStat .
|
Block | IfStat | SwitchStat | ForStat | RangeStat .
|
||||||
|
|
||||||
UnstructuredStat =
|
UnstructuredStat =
|
||||||
Declaration |
|
Declaration | SimpleVarDecl |
|
||||||
SimpleStat | GoStat | ReturnStat | BreakStat | ContinueStat | GotoStat .
|
SimpleStat | GoStat | ReturnStat | BreakStat | ContinueStat | GotoStat .
|
||||||
|
|
||||||
SimpleStat =
|
SimpleStat =
|
||||||
@ -1260,7 +1260,7 @@ 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.
|
must be in brace brackets.
|
||||||
|
|
||||||
IfStat = "if" [ SimpleVarDecl ";" ] Expression Block [ "else" Statement ] .
|
IfStat = "if" [ SimpleStat ";" ] Expression Block [ "else" Statement ] .
|
||||||
|
|
||||||
if x > 0 {
|
if x > 0 {
|
||||||
return true;
|
return true;
|
||||||
@ -1284,7 +1284,7 @@ Switch statements
|
|||||||
|
|
||||||
Switches provide multi-way execution.
|
Switches provide multi-way execution.
|
||||||
|
|
||||||
SwitchStat = "switch" [ SimpleVarDecl ";" ] [ "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 New Issue
Block a user