Go语言规范(记法)

    原文:http://golang.org/doc/go_spec.html
    翻译:红猎人 ([email protected])

Notation 记法[Top]

The syntax is specified using Extended Backus-Naur Form (EBNF):

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)来描述语法:

生产式  = 生产式名称 "=" 表达式 "." .
表达式  = 选择式 { "|" 选择式 } .
选择式  = 术语 { 术语 } .
术语      = 生产式名称 | 符号 [ "..." 符号 ] | 组 | 选项 | 重复 .
组      = "(" 表达式 ")" .
选项    = "[" 表达式 "]" .
重复    = "{" 表达式 "}" .

Productions are expressions constructed from terms and the following operators, in increasing precedence:

|   alternation
()  grouping
[]  option (0 or 1 times)
{}  repetition (0 to n times)

生产式由术语和下面的操作符构成,优先级依次递增:

|   分隔
()  分组
[]  可选 (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 ``.

小写生产式名用于识别词汇记号。非终结符用骆驼拼写法。词汇符号被包围在双引号 "" 或单引号 `` 中.

The form a ... b represents the set of characters from a through b as alternatives.

a ... b 的形式表示把 a 到 b 的字母 组成的集合当作可选项。

 

你可能感兴趣的:(Go语言规范(记法))