Compound Statements
A sequence of statements within a scope[1] is called a block. Sometimes the
scope is the entire file, such as a required file
or the file containing your main program. Sometimes the scope is a
string being evaluated with eval. But generally, a
block is surrounded by braces ({}). When we say
scope, we mean any of these three. When we mean a block with braces,
we'll use the term BLOCK.
Compound statements are built out of expressions and
BLOCKs. Expressions are built out of terms
and operators. In our syntax descriptions, we'll use the word
EXPR to indicate a place where you can use
any scalar expression. To indicate an expression evaluated in list
context, we'll say LIST.
The following statements may be used to control conditional and
repeated execution of BLOCKs. (The
LABEL portion is optional.)
if (EXPR)BLOCKif (EXPR)BLOCKelseBLOCKif (EXPR)BLOCKelsif (EXPR)BLOCK… if (EXPR)BLOCKelsif (EXPR)BLOCK… elseBLOCKunless (EXPR)BLOCKunless (EXPR)BLOCKelseBLOCKunless (EXPR)BLOCKelsif (EXPR)BLOCK… unless (EXPR)BLOCKelsif (EXPR)BLOCK… elseBLOCKLABELwhile (EXPR)BLOCKLABELwhile (EXPR)BLOCKcontinueBLOCKLABELuntil (EXPR)BLOCKLABELuntil (EXPR)BLOCKcontinueBLOCKLABELfor (EXPR;EXPR;EXPR)BLOCKLABELforeach (LIST)BLOCKLABELforeachVAR(LIST)BLOCKLABELforeachVAR(LIST)BLOCKcontinueBLOCKLABELBLOCKLABELBLOCKcontinueBLOCK
Note that unlike in C and Java, these are defined in
terms of BLOCKs, not statements. This means ...