diff --git a/source/chapter3/04_Expressions.md b/source/chapter3/04_Expressions.md index 3635909c..53db2650 100644 --- a/source/chapter3/04_Expressions.md +++ b/source/chapter3/04_Expressions.md @@ -7,13 +7,13 @@ 本页包含内容: -- [前缀表达式(Prefix Expressions)] -- [二元表达式(Binary Expressions)] -- [赋值表达式(Assignment Operator)] -- [三元条件运算符(Ternary Conditional Operator)] -- [类型转换运算符(Type-Casting Operators)] -- [主要表达式(Primary Expressions)] -- [后缀表达式(Postfix Expressions)] +- [前缀表达式(Prefix Expressions)](#prefix_expressions) +- [二元表达式(Binary Expressions)](#binary_expressions) +- [赋值表达式(Assignment Operator)](#assignment_operator) +- [三元条件运算符(Ternary Conditional Operator)](#ternary_conditional_operator) +- [类型转换运算符(Type-Casting Operators)](#type-casting_operators) +- [主要表达式(Primary Expressions)](#primary_expressions) +- [后缀表达式(Postfix Expressions)](#postfix_expressions) Swift 中存在四种表达式: 前缀(prefix)表达式,二元(binary)表达式,主要(primary)表达式和后缀(postfix)表达式。表达式可以返回一个值,以及运行某些逻辑(causes a side effect)。 @@ -24,6 +24,7 @@ Swift 中存在四种表达式: 前缀(prefix)表达式,二元(binary > *expression* → *prefix-expression*­*binary-expressions(*opt) > *expression-list* → *expression*­| *expression*­,­*expression-list* + ## 前缀表达式(Prefix Expressions) 前缀表达式由 前缀符号和表达式组成。(这个前缀符号只能接收一个参数) @@ -47,6 +48,7 @@ Swift 标准库支持如下的前缀操作符: > *prefix-expression* → *in-out-expression*­ > *in-out-expression* → &­*identifier*­ + ## 二元表达式(Binary Expressions) 二元表达式由 "左边参数" + "二元运算符" + "右边参数" 组成, 它有如下的形式: @@ -124,6 +126,7 @@ Swift 标准库提供了如下的二元运算符: > *binary-expression* → *type-casting-operator*­ > *binary-expression*s → *binary-expression*­*binary-expressions*(opt) + ## 赋值表达式(Assignment Operator) The assigment operator sets a new value for a given expression. It has the following form: @@ -144,6 +147,7 @@ The assigment operator sets a new value for a given expression. It has the follo > > *assignment-operator* → =­ + ## 三元条件运算符(Ternary Conditional Operator) 三元条件运算符 是根据条件来获取值。 形式如下: @@ -158,6 +162,7 @@ The assigment operator sets a new value for a given expression. It has the follo > > `conditional-operator` → ?­`expression`­:­ + ## 类型转换运算符(Type-Casting Operators) 有两种类型转换操作符: as 和 is. 它们有如下的形式: @@ -208,6 +213,7 @@ The check must not be known to be true or false at compile time. The following a > > *type-casting-operator* → is­*type*­| as­?(opt)­*type* + ## 主要表达式(Primary Expressions) `主要表达式`是最基本的表达式。 它们可以跟 前缀表达式,二元表达式,后缀表达式以及其他主要表达式组合使用。 @@ -433,6 +439,7 @@ x = .AnotherValue > > *wildcard-expression* → _­ + ## 后缀表达式(Postfix Expressions) 后缀表达式就是在某个表达式的后面加上 操作符。 严格的讲,每个主要表达式(primary expression)都是一个后缀表达式 diff --git a/source/chapter3/08_Generic_Parameters_and_Arguments.md b/source/chapter3/08_Generic_Parameters_and_Arguments.md index 2779e782..c31e2fae 100644 --- a/source/chapter3/08_Generic_Parameters_and_Arguments.md +++ b/source/chapter3/08_Generic_Parameters_and_Arguments.md @@ -108,10 +108,4 @@ > generic-argument-list → generic-argument­ generic-argument­,­generic-argument-list­ -> generic-argument → type - - -============================================== -上篇:[模式](07_Patterns.md) - -下篇:[语法总结](09_Summary_of_the_Grammar.md) +> generic-argument → type \ No newline at end of file diff --git a/source/chapter3/09_Summary_of_the_Grammar.md b/source/chapter3/09_Summary_of_the_Grammar.md index 9369c4f7..bf8d0a27 100644 --- a/source/chapter3/09_Summary_of_the_Grammar.md +++ b/source/chapter3/09_Summary_of_the_Grammar.md @@ -1,3 +1,7 @@ +> 翻译:StanZhai + +> 校对:xielingwang + # 语法总结 _________________