mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
spec: align EBNF rules consistently (cosmetic change)
Change-Id: Ib1b14b8880c6de5606f7f425a5fc1c8749d8a4b7 Reviewed-on: https://go-review.googlesource.com/c/go/+/635799 TryBot-Bypass: Robert Griesemer <gri@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Robert Griesemer <gri@google.com> Auto-Submit: Robert Griesemer <gri@google.com>
This commit is contained in:
parent
38e9a671d7
commit
80a2982a80
1 changed files with 62 additions and 64 deletions
126
doc/go_spec.html
126
doc/go_spec.html
|
|
@ -1,6 +1,6 @@
|
||||||
<!--{
|
<!--{
|
||||||
"Title": "The Go Programming Language Specification",
|
"Title": "The Go Programming Language Specification",
|
||||||
"Subtitle": "Language version go1.24 (Nov 20, 2024)",
|
"Subtitle": "Language version go1.24 (Dec 12, 2024)",
|
||||||
"Path": "/ref/spec"
|
"Path": "/ref/spec"
|
||||||
}-->
|
}-->
|
||||||
|
|
||||||
|
|
@ -810,12 +810,12 @@ from existing types.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<pre class="ebnf">
|
<pre class="ebnf">
|
||||||
Type = TypeName [ TypeArgs ] | TypeLit | "(" Type ")" .
|
Type = TypeName [ TypeArgs ] | TypeLit | "(" Type ")" .
|
||||||
TypeName = identifier | QualifiedIdent .
|
TypeName = identifier | QualifiedIdent .
|
||||||
TypeArgs = "[" TypeList [ "," ] "]" .
|
TypeArgs = "[" TypeList [ "," ] "]" .
|
||||||
TypeList = Type { "," Type } .
|
TypeList = Type { "," Type } .
|
||||||
TypeLit = ArrayType | StructType | PointerType | FunctionType | InterfaceType |
|
TypeLit = ArrayType | StructType | PointerType | FunctionType | InterfaceType |
|
||||||
SliceType | MapType | ChannelType .
|
SliceType | MapType | ChannelType .
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1222,12 +1222,12 @@ is <code>nil</code>.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<pre class="ebnf">
|
<pre class="ebnf">
|
||||||
FunctionType = "func" Signature .
|
FunctionType = "func" Signature .
|
||||||
Signature = Parameters [ Result ] .
|
Signature = Parameters [ Result ] .
|
||||||
Result = Parameters | Type .
|
Result = Parameters | Type .
|
||||||
Parameters = "(" [ ParameterList [ "," ] ] ")" .
|
Parameters = "(" [ ParameterList [ "," ] ] ")" .
|
||||||
ParameterList = ParameterDecl { "," ParameterDecl } .
|
ParameterList = ParameterDecl { "," ParameterDecl } .
|
||||||
ParameterDecl = [ IdentifierList ] [ "..." ] Type .
|
ParameterDecl = [ IdentifierList ] [ "..." ] Type .
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -1634,8 +1634,8 @@ The value of an uninitialized map is <code>nil</code>.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<pre class="ebnf">
|
<pre class="ebnf">
|
||||||
MapType = "map" "[" KeyType "]" ElementType .
|
MapType = "map" "[" KeyType "]" ElementType .
|
||||||
KeyType = Type .
|
KeyType = Type .
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -2176,7 +2176,7 @@ within matching brace brackets.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<pre class="ebnf">
|
<pre class="ebnf">
|
||||||
Block = "{" StatementList "}" .
|
Block = "{" StatementList "}" .
|
||||||
StatementList = { Statement ";" } .
|
StatementList = { Statement ";" } .
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
|
|
@ -2233,8 +2233,8 @@ and like the blank identifier it does not introduce a new binding.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<pre class="ebnf">
|
<pre class="ebnf">
|
||||||
Declaration = ConstDecl | TypeDecl | VarDecl .
|
Declaration = ConstDecl | TypeDecl | VarDecl .
|
||||||
TopLevelDecl = Declaration | FunctionDecl | MethodDecl .
|
TopLevelDecl = Declaration | FunctionDecl | MethodDecl .
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -2679,9 +2679,9 @@ in square brackets rather than parentheses
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<pre class="ebnf">
|
<pre class="ebnf">
|
||||||
TypeParameters = "[" TypeParamList [ "," ] "]" .
|
TypeParameters = "[" TypeParamList [ "," ] "]" .
|
||||||
TypeParamList = TypeParamDecl { "," TypeParamDecl } .
|
TypeParamList = TypeParamDecl { "," TypeParamDecl } .
|
||||||
TypeParamDecl = IdentifierList TypeConstraint .
|
TypeParamDecl = IdentifierList TypeConstraint .
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -2869,8 +2869,8 @@ binds corresponding identifiers to them, and gives each a type and an initial va
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<pre class="ebnf">
|
<pre class="ebnf">
|
||||||
VarDecl = "var" ( VarSpec | "(" { VarSpec ";" } ")" ) .
|
VarDecl = "var" ( VarSpec | "(" { VarSpec ";" } ")" ) .
|
||||||
VarSpec = IdentifierList ( Type [ "=" ExpressionList ] | "=" ExpressionList ) .
|
VarSpec = IdentifierList ( Type [ "=" ExpressionList ] | "=" ExpressionList ) .
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
|
|
@ -3210,15 +3210,15 @@ Each element may optionally be preceded by a corresponding key.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<pre class="ebnf">
|
<pre class="ebnf">
|
||||||
CompositeLit = LiteralType LiteralValue .
|
CompositeLit = LiteralType LiteralValue .
|
||||||
LiteralType = StructType | ArrayType | "[" "..." "]" ElementType |
|
LiteralType = StructType | ArrayType | "[" "..." "]" ElementType |
|
||||||
SliceType | MapType | TypeName [ TypeArgs ] .
|
SliceType | MapType | TypeName [ TypeArgs ] .
|
||||||
LiteralValue = "{" [ ElementList [ "," ] ] "}" .
|
LiteralValue = "{" [ ElementList [ "," ] ] "}" .
|
||||||
ElementList = KeyedElement { "," KeyedElement } .
|
ElementList = KeyedElement { "," KeyedElement } .
|
||||||
KeyedElement = [ Key ":" ] Element .
|
KeyedElement = [ Key ":" ] Element .
|
||||||
Key = FieldName | Expression | LiteralValue .
|
Key = FieldName | Expression | LiteralValue .
|
||||||
FieldName = identifier .
|
FieldName = identifier .
|
||||||
Element = Expression | LiteralValue .
|
Element = Expression | LiteralValue .
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -3450,22 +3450,21 @@ Primary expressions are the operands for unary and binary expressions.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<pre class="ebnf">
|
<pre class="ebnf">
|
||||||
PrimaryExpr =
|
PrimaryExpr = Operand |
|
||||||
Operand |
|
Conversion |
|
||||||
Conversion |
|
MethodExpr |
|
||||||
MethodExpr |
|
PrimaryExpr Selector |
|
||||||
PrimaryExpr Selector |
|
PrimaryExpr Index |
|
||||||
PrimaryExpr Index |
|
PrimaryExpr Slice |
|
||||||
PrimaryExpr Slice |
|
PrimaryExpr TypeAssertion |
|
||||||
PrimaryExpr TypeAssertion |
|
PrimaryExpr Arguments .
|
||||||
PrimaryExpr Arguments .
|
|
||||||
|
|
||||||
Selector = "." identifier .
|
Selector = "." identifier .
|
||||||
Index = "[" Expression [ "," ] "]" .
|
Index = "[" Expression [ "," ] "]" .
|
||||||
Slice = "[" [ Expression ] ":" [ Expression ] "]" |
|
Slice = "[" [ Expression ] ":" [ Expression ] "]" |
|
||||||
"[" [ Expression ] ":" Expression ":" Expression "]" .
|
"[" [ Expression ] ":" Expression ":" Expression "]" .
|
||||||
TypeAssertion = "." "(" Type ")" .
|
TypeAssertion = "." "(" Type ")" .
|
||||||
Arguments = "(" [ ( ExpressionList | Type [ "," ExpressionList ] ) [ "..." ] [ "," ] ] ")" .
|
Arguments = "(" [ ( ExpressionList | Type [ "," ExpressionList ] ) [ "..." ] [ "," ] ] ")" .
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -3638,8 +3637,8 @@ argument that is the receiver of the method.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<pre class="ebnf">
|
<pre class="ebnf">
|
||||||
MethodExpr = ReceiverType "." MethodName .
|
MethodExpr = ReceiverType "." MethodName .
|
||||||
ReceiverType = Type .
|
ReceiverType = Type .
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -5916,11 +5915,10 @@ Statements control execution.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<pre class="ebnf">
|
<pre class="ebnf">
|
||||||
Statement =
|
Statement = Declaration | LabeledStmt | SimpleStmt |
|
||||||
Declaration | LabeledStmt | SimpleStmt |
|
GoStmt | ReturnStmt | BreakStmt | ContinueStmt | GotoStmt |
|
||||||
GoStmt | ReturnStmt | BreakStmt | ContinueStmt | GotoStmt |
|
FallthroughStmt | Block | IfStmt | SwitchStmt | SelectStmt | ForStmt |
|
||||||
FallthroughStmt | Block | IfStmt | SwitchStmt | SelectStmt | ForStmt |
|
DeferStmt .
|
||||||
DeferStmt .
|
|
||||||
|
|
||||||
SimpleStmt = EmptyStmt | ExpressionStmt | SendStmt | IncDecStmt | Assignment | ShortVarDecl .
|
SimpleStmt = EmptyStmt | ExpressionStmt | SendStmt | IncDecStmt | Assignment | ShortVarDecl .
|
||||||
</pre>
|
</pre>
|
||||||
|
|
@ -6132,7 +6130,7 @@ matching number of variables.
|
||||||
<pre class="ebnf">
|
<pre class="ebnf">
|
||||||
Assignment = ExpressionList assign_op ExpressionList .
|
Assignment = ExpressionList assign_op ExpressionList .
|
||||||
|
|
||||||
assign_op = [ add_op | mul_op ] "=" .
|
assign_op = [ add_op | mul_op ] "=" .
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -6548,7 +6546,7 @@ The iteration may be controlled by a single condition, a "for" clause, or a "ran
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<pre class="ebnf">
|
<pre class="ebnf">
|
||||||
ForStmt = "for" [ Condition | ForClause | RangeClause ] Block .
|
ForStmt = "for" [ Condition | ForClause | RangeClause ] Block .
|
||||||
Condition = Expression .
|
Condition = Expression .
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
|
|
@ -6580,8 +6578,8 @@ an increment or decrement statement. The init statement may be a
|
||||||
|
|
||||||
<pre class="ebnf">
|
<pre class="ebnf">
|
||||||
ForClause = [ InitStmt ] ";" [ Condition ] ";" [ PostStmt ] .
|
ForClause = [ InitStmt ] ";" [ Condition ] ";" [ PostStmt ] .
|
||||||
InitStmt = SimpleStmt .
|
InitStmt = SimpleStmt .
|
||||||
PostStmt = SimpleStmt .
|
PostStmt = SimpleStmt .
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
|
|
@ -7909,7 +7907,7 @@ types, variables, and constants.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<pre class="ebnf">
|
<pre class="ebnf">
|
||||||
SourceFile = PackageClause ";" { ImportDecl ";" } { TopLevelDecl ";" } .
|
SourceFile = PackageClause ";" { ImportDecl ";" } { TopLevelDecl ";" } .
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<h3 id="Package_clause">Package clause</h3>
|
<h3 id="Package_clause">Package clause</h3>
|
||||||
|
|
@ -7920,8 +7918,8 @@ to which the file belongs.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<pre class="ebnf">
|
<pre class="ebnf">
|
||||||
PackageClause = "package" PackageName .
|
PackageClause = "package" PackageName .
|
||||||
PackageName = identifier .
|
PackageName = identifier .
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -7950,9 +7948,9 @@ that specifies the package to be imported.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<pre class="ebnf">
|
<pre class="ebnf">
|
||||||
ImportDecl = "import" ( ImportSpec | "(" { ImportSpec ";" } ")" ) .
|
ImportDecl = "import" ( ImportSpec | "(" { ImportSpec ";" } ")" ) .
|
||||||
ImportSpec = [ "." | PackageName ] ImportPath .
|
ImportSpec = [ "." | PackageName ] ImportPath .
|
||||||
ImportPath = string_lit .
|
ImportPath = string_lit .
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue