raz / conform / run / EnumNames.raz

44 lines · 1.4 KiB · raw · history · last change 3e1c4e5b

1(* A name of an enumeration may be written with its type; two
2 enumerations of a scope may share a name, and an enumeration may share
3 one with another declaration: written alone, the name is that other
4 one (report 2026-10.31, section 5.7). *)
5module EnumNames;
6import Out, EnumKinds;
7
8type
9 Style = (bold, italic);
10 Elem = (para, bold, rule);
11 Light = (red, amber, green);
12
13const Stop = Light.red;
14
15var s: Style; e: Elem; ss: set of Style; k: EnumKinds.Elem;
16
17proc rule; (* beside Elem's rule *)
18begin
19 Out.str("the procedure rule\n");
20end;
21
22proc main*;
23begin
24 s := Style.bold; e := Elem.bold;
25 if (s = Style.bold) and (e = Elem.bold) and (INT(e) = 1) then Out.str("Style.bold and Elem.bold\n"); end;
26 e := para; (* Elem's alone *)
27 e := Elem.rule;
28 rule; (* the procedure *)
29 s := italic;
30 match e of
31 | Elem.rule: Out.str("an arm with its type\n");
32 | para, bold: Out.str("an arm without\n");
33 end;
34 ss := {Style.bold, italic};
35 if Style.bold in ss then Out.str("in the set\n"); end;
36 if (Stop = red) and (Light.green > amber) then Out.str("ordered\n"); end;
37 k := EnumKinds.Elem.bold;
38 if (k = EnumKinds.Elem.bold) and (EnumKinds.Style.bold # EnumKinds.Style.plain) then
39 Out.str("imported, with module and type\n");
40 end;
41 if EnumKinds.para = k then Out.str("no\n"); end;
42end;
43
44end EnumNames.