Previous Up Next

8  Statements

The first rule statement describes the various forms of a statement. The remaining rules implement the constraints that are sensitive to the context in which the statement occurs: single_statement for a context in which only one statement is allowed, and decl_statement for a context in which a declaration, statement, or sequence thereof is allowed.

stmt   ::=  include
|metaidStmt
|expr;
|if (dot_expr) single_stmt [else single_stmt]
|for ([dot_expr]; [dot_expr]; [dot_expr]) single_stmt
|while (dot_expr) single_stmt
|do single_stmt while (dot_expr);
|iter_ident (dot_expr *) single_stmt
|switch ([dot_expr]) {case_line * }
|return [dot_expr];
|{ [stmt_seq] }
|NEST(decl_stmt +, when)
|NEST(expr, when)
|break;
|continue;
|id:
|goto id;
|{stmt_seq }
single_stmt   ::=  stmt
|OR(stmt)
decl_stmt   ::=  metaidStmtList
|decl_var
|stmt
|OR(stmt_seq)
stmt_seq   ::=  decl_stmt * [DOTSEQ(decl_stmt +, when) decl_stmt *]
|decl_stmt * [DOTSEQ(expr, when) decl_stmt *]
case_line   ::=  default : stmt_seq
|case dot_exprstmt_seq
iter_ident   ::=  IteratorId
|metaidIterator
OR(gram_o)   ::=  ( gram_o (|gram_o) *)
DOTSEQ(gram_d, when_d)   ::=  [when_d] (gram_d[when_d]) *
NEST(gram_n, when_n)   ::=  <…[when_n] gram_n ([when_n] gram_n) * …>
|<+…[when_n] gram_n ([when_n] gram_n) * …+>

OR is a macro that generates a disjunction of patterns. The three tokens (, |, and ) must appear in the leftmost column, to differentiate them from the parentheses and bit-or tokens that can appear within expressions (and cannot appear in the leftmost column). These token may also be preceded by \ when they are used in an other column. These tokens are furthermore different from (, ∣, and ), which are part of the grammar metalanguage.


Previous Up Next