BNF for Go
The Go programming language specification [1] is written in BNF if someone needs a detailed syntax explanation. The following examples are taken from the language specification.
Constant declarations
ConstDecl = "const" ( ConstSpec | "(" { ConstSpec ";" } ")" ) .
ConstSpec = IdentifierList [ [ Type ] "=" ExpressionList ] .
IdentifierList = identifier { "," identifier } .
ExpressionList = Expression { "," Expression } .
Type declarations
TypeDecl = "type" ( TypeSpec | "(" { TypeSpec ";" } ")" ) .
TypeSpec = identifier Type .
For loops
ForStmt = "for" [ Condition | ForClause | RangeClause ] Block .
Condition = Expression .
Select statements
SelectStmt = "select" "{" { CommClause } "}" .
CommClause = CommCase ":" StatementList .
CommCase = "case" ( SendStmt | RecvStmt ) | "default" .
RecvStmt = [ ExpressionList "=" | IdentifierList ":=" ] RecvExpr .
RecvExpr = Expression .
Return statements
ReturnStmt = "return" [ ExpressionList ] .