⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 c4

📁 UNIX v6源代码 这几乎是最经典的unix版本 unix操作系统设计和莱昂氏unix源代码分析都是用的该版
💻
字号:
.ul9.  Statements.etExcept as indicated, statements are executed in sequence..ms9.1  Expression statement.etMost statements are expression statements, which havethe form.dp 1	expression \fG;.edUsually expression statements are assignments or functioncalls..ms9.2  Compound statement.etSo that several statements can be used where one is expected,the compound statement is provided:.dp 2	compound-statement:		{ statement-list }	statement-list:		statement		statement statement-list.ed9.3  Conditional statement.etThe two forms of the conditional statement are.dp 2	\fGif ( \fIexpression \fG) \fIstatement	\fGif ( \fIexpression \fG) \fIstatement \fGelse \fIstatement.edIn both cases the expression is evaluatedand if it is non-zero, the first substatementis executed.In the second case the second substatement is executedif the expression is 0.As usual the ``else'' ambiguity is resolved by connectingan \fGelse\fR with the last encountered elseless \fGif\fR..ms9.4  While statement.etThe \fGwhile\fR statement has the form.dp 1	\fGwhile ( \fIexpression \fG) \fIstatement.edThe substatement is executed repeatedlyso long as the value of the expression remains non-zero.The test takes place before each execution of thestatement..ms9.5  Do statement.etThe \fGdo\fR statement has the form.dp 1	\fGdo \fIstatement \fGwhile ( \fIexpression \fG) ;.edThe substatement is executed repeatedly untilthe value of the expression becomes zero.The test takes place after each execution of thestatement..ms9.6  For statement.etThe \fGfor\fR statement has the form.dp 1.ft G	for ( \fIexpression-1\*(op \fG; \fIexpression-2\*(op \fG ; \c\fIexpression-3\*(op \fG) \fIstatement.edThis statement is equivalent to.dp 5	expression-1;	\fGwhile (\fI^expression-2\fG^) {		\fIstatement		expression-3^\fG;	}.edThus the first expression specifies initializationfor the loop; the second specifiesa test, made before each iteration, suchthat the loop is exited when the expression becomes0;the third expression typically specifies an incrementationwhich is performed after each iteration..pgAny or all of the expressions may be dropped.A missing.ft Iexpression-2.ft Rmakes theimplied \fGwhile\fR clause equivalent to ``while(^1^)'';other missing expressions are simplydropped from the expansion above..ms9.7  Switch statement.etThe \fGswitch\fR statement causes control to be transferredto one of several statements depending onthe value of an expression.It has the form.dp 1	\fGswitch ( \fIexpression \fG) \fIstatement.edThe expression must be \fGint\fR or \fGchar\fR.The statement is typically compound.Each statement within the statementmay be labelled with case prefixesas follows:.dp 1	\fGcase \fIconstant-expression \fG:.edwhere the constantexpressionmust be \fGint\fR or \fGchar\fR.No two of the case constants in a switchmay have the same value.Constant expressions are precisely defined in \(sc15..pgThere may also be at most one statement prefix of theform.dp 1	\fGdefault :.edWhen the \fGswitch\fR statement is executed, its expressionis evaluated and compared with each case constant inan undefined order.If one of the case constants isequal to the value of the expression,control is passed to the statementfollowing the matched case prefix.If no case constant matches the expression,and if there is a \fGdefault\fR prefix, controlpasses to the prefixedstatement.In the absence of a \fGdefault\fR prefixnone of the statements in theswitch is executed..pgCase or default prefixes in themselvesdo not alter the flow of control..ms9.8  Break statement.etThe statement.dp 1	\fGbreak ;.edcauses termination of the smallest enclosing \fGwhile\fR, \fGdo\fR,\fGfor\fR, or \fGswitch\fR statement;control passes to thestatement following the terminated statement..ms9.9  Continue statement.etThe statement.dp 1	\fGcontinue ;.edcauses control to pass to the loop-continuation portion of thesmallest enclosing \fGwhile\fR,\fGdo\fR, or \fGfor\fRstatement; that is to the end of the loop.More precisely, in each of the statements.dp 4.bG.ta .5i 2.5i 4.5i	while (^^.^.^.^^) {	do {	for (^^.^.^.^^) {	  ^.^.^.^	  ^.^.^.^	  ^.^.^.^	contin:^;	contin:^;	contin:^;	}	} while (^^.^.^.^^)^;	}.ed.eG.ta .5i 1i 1.5i 2i 2.5i 3ia \fGcontinue\fR is equivalent to ``goto contin''..ms9.10  Return statement.etA function returns to its caller by means ofthe \fGreturn\fR statement, which has one of theforms.dp 2.ft G	return ;	return ( \fIexpression \fG) ;.edIn the first case no value is returned.In the second case, the value of the expressionis returned to the callerof the function.If required, the expression is converted,as if by assignment, to the type of thefunction in which it appears.Flowing off the end of a function isequivalent to a return with no returned value..ms9.11  Goto statement.etControl may be transferred unconditionally by means ofthe statement.dp 1.ft G	goto \fIexpression \fG;.edThe expression should be a label (\(sc\(sc9.12, 14.4)or an expression of type ``pointer to \fGint\fR''which evaluates to a label.It is illegal to transfer to a labelnot located in the current functionunless some extra-language provisionhas been made to adjustthe stack correctly..ms9.12  Labelled statement.etAny statement may be preceded bylabel prefixes of the form.dp 1	identifier \fG:.edwhich serve to declare the identifieras a label.More details on the semantics of labels aregiven in \(sc14.4 below..ms9.13  Null statement.etThe null statement has the form.dp 1	\fG;.edA null statement is useful to carry a label just before the ``}''of a compound statement or to supply a nullbody to a looping statement such as \fGwhile\fR.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -