A pattern is a template that accepts a set of values. Those values are all of a certain type, the type of the pattern. IBAL provides the following kinds of patterns.
c, where c is a string,
Boolean or integer literal, accepts only the value c.
{ s_0, ..., s n } where the s_i are string
literals, accepts the values s_0, ..., s_n.
i_1 .. i_2 (.. is the dotdot token), where
i_1 and i_2 are integers with i_1 <=
i_2, accepts all integers i such that i_1 <=
i <=i_2.
<n_0 : p_0, ..., n_m : p_m>, where the n_i are
lidents and the p_i are patterns, accepts all tuples of the
form <n_0 : v_0, ..., n_m : v_m> such that each p_i
accepts v_i.
<p_0, ..., p_m>, where the p_i are patterns,
accepts all anonymous tuples of the form
<v_0, ..., v_m> such that each p_i accepts v_i.
L(p_0,...,p_m) where L is a ulongvar with final
identifier C, accepts all ADT values C(v_0, ..., v_m)
such that each p_i accepts v_i. Only the final
identifier in L is used to indicate which patterns are
accepted, by specifying the required ADT constructor.
However, the remainder of L is used to indicate where the ADT
is defined, so that the constructor and the types of its fields can be
examined. If no such constructor exists in the specified location, or
it has a different number of fields, a type error is signalled.
_ is the wildcard pattern, that accepts all values. This
pattern matches all types.
x is the variable pattern. Like the wildcard
pattern, it accepts all values, but it also associates the variable
x with the value accepted.
The same variable name cannot appear more than once in a pattern.
A set of patterns of the same type is called exhaustive if every value of that type is accepted by at least one of the patterns.