Commit 8b212f67 authored by Robert Griesemer's avatar Robert Griesemer

- attemp to correct statement syntax

- introduced FieldDeclList and MethodDeclList
  in consistency with other lists
- made labels declarations

SVN=111982
parent 2aae3fcb
...@@ -601,7 +601,8 @@ Struct types are similar to C structs. ...@@ -601,7 +601,8 @@ Struct types are similar to C structs.
Each field of a struct represents a variable within the data Each field of a struct represents a variable within the data
structure. structure.
StructType = 'struct' '{' [ FieldDecl { ';' FieldDecl } [ ';' ] ] '}' . StructType = 'struct' '{' [ FieldDeclList [ ';' ] ] '}' .
FieldDeclList = FieldDecl { ';' FieldDeclList } .
FieldDecl = IdentifierList Type . FieldDecl = IdentifierList Type .
// An empty struct. // An empty struct.
...@@ -712,7 +713,7 @@ Function Literals ...@@ -712,7 +713,7 @@ Function Literals
Function literals represent anonymous functions. Function literals represent anonymous functions.
FunctionLit = FunctionType Block . FunctionLit = FunctionType Block .
Block = '{' [ StatementList ] '}' . Block = CompoundStat .
A function literal can be invoked A function literal can be invoked
or assigned to a variable of the corresponding function pointer type. or assigned to a variable of the corresponding function pointer type.
...@@ -768,7 +769,8 @@ Interface types ...@@ -768,7 +769,8 @@ Interface types
An interface type denotes a set of methods. An interface type denotes a set of methods.
InterfaceType = 'interface' '{' [ MethodDecl { ';' MethodDecl } [ ';' ] ] '}' . InterfaceType = 'interface' '{' [ MethodDeclList [ ';' ] ] '}' .
MethodDeclList = MethodDecl { ';' MethodDecl } .
MethodDecl = identifier Parameters [ Result ] . MethodDecl = identifier Parameters [ Result ] .
// A basic file interface. // A basic file interface.
...@@ -1089,17 +1091,31 @@ Statements ...@@ -1089,17 +1091,31 @@ Statements
Statements control execution. Statements control execution.
Statement = Statement =
[ LabelDecl ] ( StructuredStat | UnstructuredStat ) .
StructuredStat =
CompoundStat | IfStat | SwitchStat | ForStat | RangeStat .
UnstructuredStat =
Declaration | Declaration |
SimpleStat | CompoundStat | SimpleStat | GoStat | ReturnStat | BreakStat | ContinueStat | GotoStat .
GoStat |
ReturnStat |
IfStat | SwitchStat |
ForStat | RangeStat |
BreakStat | ContinueStat | GotoStat | LabelStat .
SimpleStat = SimpleStat =
ExpressionStat | IncDecStat | Assignment | SimpleVarDecl . ExpressionStat | IncDecStat | Assignment | SimpleVarDecl .
Statement lists
----
Semicolons are used to separate individual statements of a statement list.
They are optional after a statement that ends with a closing curly brace '}'.
StatementList =
StructuredStat |
UnstructuredStat |
StructuredStat [ ";" ] StatementList |
UnstructuredStat ";" StatementList .
Expression statements Expression statements
---- ----
...@@ -1122,7 +1138,7 @@ Note that ++ and -- are not operators for expressions. ...@@ -1122,7 +1138,7 @@ Note that ++ and -- are not operators for expressions.
Compound statements Compound statements
---- ----
CompoundStat = '{' { Statement } '}' . CompoundStat = '{' [ StatementList [ ";" ] ] '}' .
{ {
x := 1; x := 1;
...@@ -1278,7 +1294,7 @@ Switch statements ...@@ -1278,7 +1294,7 @@ Switch statements
Switches provide multi-way execution. Switches provide multi-way execution.
SwitchStat = 'switch' [ [ SimpleVarDecl ';' ] [ Expression ] ] '{' { CaseClause } '}' . SwitchStat = 'switch' [ [ SimpleVarDecl ';' ] [ Expression ] ] '{' { CaseClause } '}' .
CaseClause = CaseList { Statement } [ 'fallthrough' ] . CaseClause = CaseList StatementList [ ';' ] [ 'fallthrough' [ ';' ] ] .
CaseList = Case { Case } . CaseList = Case { Case } .
Case = ( 'case' ExpressionList | 'default' ) ':' . Case = ( 'case' ExpressionList | 'default' ) ':' .
...@@ -1426,12 +1442,12 @@ A goto statement transfers control to the corresponding label statement. ...@@ -1426,12 +1442,12 @@ A goto statement transfers control to the corresponding label statement.
goto Error goto Error
Label statement Label declaration
---- ----
A label statement serves as the target of a 'goto', 'break' or 'continue' statement. A label declaration serves as the target of a 'goto', 'break' or 'continue' statement.
LabelStat = identifier ':' . LabelDecl = identifier ':' .
Error: Error:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment