| 1 |
(* M2CaseList.def implement ISO case label lists. |
| 2 |
|
| 3 |
Copyright (C) 2009-2025 Free Software Foundation, Inc. |
| 4 |
Contributed by Gaius Mulley <[email protected]>. |
| 5 |
|
| 6 |
This file is part of GNU Modula-2. |
| 7 |
|
| 8 |
GNU Modula-2 is free software; you can redistribute it and/or modify |
| 9 |
it under the terms of the GNU General Public License as published by |
| 10 |
the Free Software Foundation; either version 3, or (at your option) |
| 11 |
any later version. |
| 12 |
|
| 13 |
GNU Modula-2 is distributed in the hope that it will be useful, but |
| 14 |
WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 16 |
General Public License for more details. |
| 17 |
|
| 18 |
You should have received a copy of the GNU General Public License |
| 19 |
along with GNU Modula-2; see the file COPYING3. If not see |
| 20 |
<http://www.gnu.org/licenses/>. *) |
| 21 |
|
| 22 |
DEFINITION MODULE M2CaseList ; |
| 23 |
|
| 24 |
(* |
| 25 |
Title : M2CaseList |
| 26 |
Author : Gaius Mulley |
| 27 |
System : GNU Modula-2 |
| 28 |
Date : Fri Jul 24 09:53:48 2009 |
| 29 |
Revision : $Version$ |
| 30 |
Description: |
| 31 |
*) |
| 32 |
|
| 33 |
FROM DynamicStrings IMPORT String ; |
| 34 |
FROM Lists IMPORT List ; |
| 35 |
|
| 36 |
|
| 37 |
(* |
| 38 |
PushCase - create a case entity and push it to an internal stack. |
| 39 |
rec is NulSym if this is a CASE statement. |
| 40 |
If rec is a record then it indicates a possible |
| 41 |
varients reside in the record to check. |
| 42 |
Both rec and va might be NulSym and then the expr |
| 43 |
will contain the selector expression to a case statement. |
| 44 |
Return the case id. |
| 45 |
*) |
| 46 |
|
| 47 |
PROCEDURE PushCase (rec, va, expr: CARDINAL) : CARDINAL ; |
| 48 |
|
| 49 |
|
| 50 |
(* |
| 51 |
PopCase - pop the top element of the case entity from the internal |
| 52 |
stack. |
| 53 |
*) |
| 54 |
|
| 55 |
PROCEDURE PopCase ; |
| 56 |
|
| 57 |
|
| 58 |
(* |
| 59 |
ElseCase - indicates that this case varient does have an else clause. |
| 60 |
*) |
| 61 |
|
| 62 |
PROCEDURE ElseCase (f: CARDINAL) ; |
| 63 |
|
| 64 |
|
| 65 |
(* |
| 66 |
BeginCaseList - create a new label list. |
| 67 |
*) |
| 68 |
|
| 69 |
PROCEDURE BeginCaseList (v: CARDINAL) ; |
| 70 |
|
| 71 |
|
| 72 |
(* |
| 73 |
EndCaseList - terminate the current label list. |
| 74 |
*) |
| 75 |
|
| 76 |
PROCEDURE EndCaseList ; |
| 77 |
|
| 78 |
|
| 79 |
(* |
| 80 |
AddRange - add a range to the current label list. |
| 81 |
*) |
| 82 |
|
| 83 |
PROCEDURE AddRange (r1, r2: CARDINAL; tok: CARDINAL) ; |
| 84 |
|
| 85 |
|
| 86 |
(* |
| 87 |
CaseBoundsResolved - returns TRUE if all constants in the case list, c, |
| 88 |
are known to GCC. |
| 89 |
*) |
| 90 |
|
| 91 |
PROCEDURE CaseBoundsResolved (tokenno: CARDINAL; c: CARDINAL) : BOOLEAN ; |
| 92 |
|
| 93 |
|
| 94 |
(* |
| 95 |
TypeCaseBounds - returns TRUE if all bounds in case list, c, are |
| 96 |
compatible with the tagged type. |
| 97 |
*) |
| 98 |
|
| 99 |
PROCEDURE TypeCaseBounds (c: CARDINAL) : BOOLEAN ; |
| 100 |
|
| 101 |
|
| 102 |
(* |
| 103 |
OverlappingCaseBounds - returns TRUE if there were any overlapping bounds |
| 104 |
in the case list, c. It will generate an error |
| 105 |
messages for each overlapping bound found. |
| 106 |
*) |
| 107 |
|
| 108 |
PROCEDURE OverlappingCaseBounds (c: CARDINAL) : BOOLEAN ; |
| 109 |
|
| 110 |
|
| 111 |
(* |
| 112 |
MissingCaseBounds - returns TRUE if there were any missing bounds |
| 113 |
in the varient record case list, c. It will |
| 114 |
generate an error message for each missing |
| 115 |
bounds found. |
| 116 |
*) |
| 117 |
|
| 118 |
PROCEDURE MissingCaseBounds (tokenno: CARDINAL; c: CARDINAL) : BOOLEAN ; |
| 119 |
|
| 120 |
|
| 121 |
(* |
| 122 |
MissingCaseStatementBounds - returns TRUE if the case statement has a missing |
| 123 |
clause. It will also generate error messages. |
| 124 |
*) |
| 125 |
|
| 126 |
PROCEDURE MissingCaseStatementBounds (tokenno: CARDINAL; c: CARDINAL) : BOOLEAN ; |
| 127 |
|
| 128 |
|
| 129 |
(* |
| 130 |
WriteCase - displays the case list. |
| 131 |
*) |
| 132 |
|
| 133 |
PROCEDURE WriteCase (c: CARDINAL) ; |
| 134 |
|
| 135 |
|
| 136 |
END M2CaseList. |