Files
the-swift-programming-langu…/source/chapter3/09_Summary_of_the_Grammar.md
2014-06-09 16:36:13 +08:00

1.7 KiB

语法总结 (Summary of the Grammar)

语句

语句
statementexpression ; opt
statementdeclaration ; opt
statementloop-statement ; opt
statementbranch-statement ; opt
statementlabeled-statement
statementcontrol-transfer-statement ; opt
statementsstatement statement opt

循环语句
loop-statementfor-statement
loop-statementfor-in-statement
loop-statementwhile-statement
loop-statementdo-while-statement

for 循环
for-statementfor for-init opt ; expression opt ; expression opt code-block
for-statementfor ( for-init opt ; expression opt ; expression opt ) code-block
for-initvariable-declaration | expression-list

for-in 循环
for-in-statementfor pattern in expression code-block

while 循环
while-statementwhile while-condition code-block
while-conditionexpression | declaration

do-while 循环
do-while-statementdo code-block while while-condition

判断语句(Branch Statement)
branch-statementif-statement
branch-statementswitch-statement

if 语句
if-statementif if-condition code-block else-clause opt
if-conditionexpression | declaration
else-clauseelse code-block | else if-statement