原文:http://golang.org/doc/go_spec.html 翻译:红猎人 (zengsai@gmail.com)
The syntax is specified using Extended Backus-Naur Form (EBNF):html
Production = production_name "=" Expression "." . Expression = Alternative { "|" Alternative } . Alternative = Term { Term } . Term = production_name | token [ "..." token ] | Group | Option | Repetition . Group = "(" Expression ")" . Option = "[" Expression "]" . Repetition = "{" Expression "}" .
使用扩展巴科斯-诺尔范式(FBNF)来描述语法:golang
生产式 = 生产式名称 "=" 表达式 "." . 表达式 = 选择式 { "|" 选择式 } . 选择式 = 术语 { 术语 } . 术语 = 生产式名称 | 符号 [ "..." 符号 ] | 组 | 选项 | 重复 . 组 = "(" 表达式 ")" . 选项 = "[" 表达式 "]" . 重复 = "{" 表达式 "}" .
Productions are expressions constructed from terms and the following operators, in increasing precedence:express
| alternation () grouping [] option (0 or 1 times) {} repetition (0 to n times)
生产式由术语和下面的操做符构成,优先级依次递增:ide
| 分隔 () 分组 [] 可选 (0 或 1 次) {} 重复 (0 或 n 次)
Lower-case production names are used to identify lexical tokens. Non-terminals are in CamelCase. Lexical symbols are enclosed in double quotes ""
or back quotes ``
.spa
小写生产式名用于识别词汇记号。非终结符用骆驼拼写法。词汇符号被包围在双引号 ""
或单引号 ``
中..net
The form a ... b
represents the set of characters from a
through b
as alternatives.翻译
a ... b
的形式表示把 a
到 b
的字母 组成的集合看成可选项。code