Contents | Prev | Next | Index
The purpose of a case statement is to specify the selection and execution of a statement sequence according to the value of an expression. It starts by first evaluating the expression; then that statement sequence is executed whose case label list contains the obtained value. The case expression has to be either an integer value that includes the types of all case label values, or both the case expression and the case labels must be of type CHAR. Case labels are constants, and no value may occur than once. If the case expression value does not match any label, the default statement sequence following symbol ELSE is executed if one exists. Otherwise, the program is aborted.
case_stmt ::= switch_expr case_list else_case
END switch_expr ::= CASE expr OF case_list ::= case_list | case ::= case case ::= case_label_list : stmt_seq ::= <empty> case_label_list ::= case_label_list , case_label ::= case_label case_label ::= const_expr .. const_expr ::= const_expr else_case ::= ELSE stmt_seq ::= <empty> |
Example:
CASE ch OF
"A".."Z": ReadIdentifier
| "0".."9": ReadNumber
| "'",'"': ReadString
ELSE SpecialCharacter
END
Contents | Prev | Next | Index
Canterbury Oberon-2 for JVM (Last documentation update
Jun 2, 2000)
Copyright © 1998 Mill Hill &
Canterbury Corporation, Ltd. All rights reserved
Please send any comments or corrections to
mhc@webcom.com