Sather Home Page

Section 6.7.5:
Case Statement

A case statement first evaluates a guard value and compares this in turn with the constant guard for each clause until one is found which is equal. The corresponding code sequence is then executed. If no guard is found with equality testing then, if an else-clause is provided the corresponding code sequence is executed. If there is no else-clause then an exception is raised.
NOTE Current implementations of Sather do not raise a catchable exception. This is an implementation error. The language definition indicates that all exceptions whether raised by explicit use of the raise statement or for any other reason are catchable unless the execution environment indicates otherwise!

Concrete Syntax

case statement = Case_SY, expression,
value guard, guarded clause,
[{value guard, guarded clause}],
[default clause], End_SY ;
guard = value guard | type guard ;
value guard = When_SY, expression, {Comma_SY, expression} ;
type guard = When_SY, type specifier ;

Abstract Syntax

Case_Statement ::
when : [seq of Guard_Clause]
default : [seq of Statement] ;


Guard_Clause ::
val : Expression
body : [seq of Statement] ;

Static Semantics

The val expression of each guard clause shall be of the form variable.is_eq(constant value). Note that it is a dynamic, rather than static, error if there is no else-clause - except when there are no when-clauses - when the else-clause absence becomes part of the well-formedness criteria.

TO BE DONE

Dynamic Semantics

TO BE DONE


Specification Index Language Index Section 6 Index
Comments or enquiries should be made to Keith Hopper.
Page last modified: Wednesday, 31 May 2000.
Produced with Amaya