Contents | Prev | Next | Index


If Statements

if_stmt         ::= IF boolean_expr then_stmt
                    elsif_stmt_list else_stmt END
boolean_expr    ::= expr
then_stmt       ::= THEN stmt_seq
elsif_stmt_list ::= elsif_stmt_list elsif_stmt
                ::= <empty>
elsif_stmt      ::= ELSIF boolean_expr THEN stmt_seq
else_stmt       ::= ELSE stmt_seq
                ::= <empty>

If statements specify the conditional execution of statement sequences. The expressions following the symbols IF and ELSIF are of type BOOLEAN. They are in sequence of occurrence until one evaluates to TRUE, whereafter its associated statement sequence is executed. If none of these conditional expressions avaluates to TRUE, the statement sequence following the symbol ELSE is executed, if present. Example:

IF (ch >= "A") & (ch <= "Z") THEN ReadIdentifier
ELSIF (ch >= "0") & (ch <= "9") THEN ReadNumber
ELSIF (ch = "'") OR (ch = '"') THEN ReadString
ELSE SpecialCharacter
END


Contents | Prev | Next | Index

Canterbury Modula-2 for Java  (Last documentation update Feb 8, 2000)
Copyright © 1998 Mill Hill & Canterbury Corporation, Ltd. All rights reserved
Please send any comments or corrections to mhc@webcom.com