原文: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