CASE(4)

Table of Contents

Name

case multi-way conditional construct

Synopsis

%case C-expression
[ %when constant template-stuff ] ...
[ %other template-stuff ]
%end-case

Description

The case template construct provides multi-way branching within template and proc sections. The value of the Cexpression is used to determine which branch to take. Each when branch is followed by a constant terminated by white space. Each constant must have a different value. If the value of the C-expression matches the value of one of the constants, then the template-stuff in that branch is generated to the product file. If no when branch matches the value of the C-expression, then the template-stuff in the other branch, if any, is generated to the product file. The C-expression and constants must have an integer or character type (the index type, TYPE, is an integer type).

Example

If the grammar section for an SDTool were: %grammar
expr: (id | num | left:expr oper right:expr ) id: <[a-zA-Z]+>
num: <[0-9]+>
and the product section in one of the SDTool's product description files were:
The root expression is
%case tag(top)
%when Id the identifier «%(tok(id(top)))." %when Num the number «%(tok(num(top)))." %other a binary expression.
%end-case
then if the specification input were:
alpha
the generated product would contain:
The root expression is the identifier «alpha."

See Also

IF(4)


© 1990 Lucent Technologies, Inc
© 1998 Harmony Software, Inc