diff --git a/doc/go_spec.txt b/doc/go_spec.txt index 2f71c8d0aa..d3fd4714ed 100644 --- a/doc/go_spec.txt +++ b/doc/go_spec.txt @@ -3,7 +3,7 @@ The Go Programming Language Specification (DRAFT) Robert Griesemer, Rob Pike, Ken Thompson -(December 16, 2008) +(December 17, 2008) ---- @@ -358,30 +358,26 @@ language support. Notation ---- -The syntax is specified using Parameterized Extended Backus-Naur Form (PEBNF). -Specifically, productions are expressions constructed from terms and the -following operators: +The syntax is specified using Extended Backus-Naur Form (EBNF): -- | separates alternatives (least binding strength) -- () groups -- [] specifies an option (0 or 1 times) -- {} specifies repetition (0 to n times) - -The syntax of PEBNF can be expressed in itself: - - Production = production_name [ Parameters ] "=" Expression . - Parameters = "<" production_name { "," production_name } ">" . + Production = production_name "=" Expression . Expression = Alternative { "|" Alternative } . Alternative = Term { Term } . - Term = production_name [ Arguments ] | token [ "..." token ] | Group | Option | Repetition . - Arguments = "<" Expression { "," Expression } ">" . + Term = production_name | token [ "..." token ] | Group | Option | Repetition . Group = "(" Expression ")" . Option = "[" Expression ")" . Repetition = "{" Expression "}" . +Productions are expressions constructed from terms and the following operators: + + | separates alternatives (least binding strength) + () groups + [] specifies an option (0 or 1 times) + {} specifies repetition (0 to n times) + Lower-case production names are used to identify productions that cannot -be broken by white space or comments; they are usually tokens. Other -production names are in CamelCase. +be broken by white space or comments; they are tokens. Other production +names are in CamelCase. Tokens (lexical symbols) are enclosed in double quotes '''' (the double quote symbol is written as ''"''). @@ -389,15 +385,6 @@ double quote symbol is written as ''"''). The form "a ... b" represents the set of characters from "a" through "b" as alternatives. -Productions can be parameterized. To get the actual production the parameter is -substituted with the argument provided where the production name is used. For -instance, there are various forms of semicolon-separated lists in the grammar. -The parameterized production for such lists is: - - List
= P { ";" P } [ ";" ] . - -In this case, P stands for the actual list element. - Where possible, recursive productions are used to express evaluation order and operator precedence syntactically (for instance for expressions). @@ -684,14 +671,6 @@ function, method) and specifies properties of that entity such as its type. [ "export" | "package" ] ( ConstDecl | TypeDecl | VarDecl | FunctionDecl | MethodDecl ) . -Except for function, method and abbreviated variable declarations (using ":="), -all declarations follow the same pattern. There is either a single declaration -of the form P, or an optional semicolon-separated list of declarations of the -form P surrounded by parentheses: - - Decl
= P | "(" [ List
] ")" . - List
= P { ";" P } [ ";" ] .
-
Every identifier in a program must be declared; some identifiers, such as "int"
and "true", are predeclared (§Predeclared identifiers).
@@ -796,7 +775,8 @@ Const declarations
A constant declaration binds an identifier to the value of a constant
expression (§Constant expressions).
- ConstDecl = "const" Decl