Swift 关于语言附注


用来描述Swift编程语言形式语法的记法遵循下面几个约定:

举个例子,getter-setter的语法块的定义如下:

GRAMMAR OF A GETTER-SETTER BLOCK

getter-setter-block → {­ getter-clause ­setter-clause­opt ­}­ | {­ setter-clause ­getter-clause­}­

这个定义表明,一个getter-setter方法​​块可以由一个getter子句后跟一个可选的setter子句构成,用大括号括起来,或者由一个setter子句后跟一个getter子句构成,用大括号括起来。上述的文法产生等价于下面的两个产生,明确阐明如何二中择一:

GRAMMAR OF A GETTER-SETTER BLOCK

getter-setter-block → {­ getter-clause ­setter-clause­opt ­}­­

getter-setter-block → {­ setter-clause ­getter-clause­}­

粤ICP备11097351号-1