-
Notifications
You must be signed in to change notification settings - Fork 1
/
TokenSet.def
64 lines (39 loc) · 1.79 KB
/
TokenSet.def
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
(*!m2r10*) (* Copyright (c) 2015 B.Kowarsch. All rights reserved. *)
DEFINITION MODULE TokenSet;
(* Token Set ADT for Modula-2 R10 Core Compiler *)
IMPORT Token;
TYPE TokenSet = OPAQUE;
(* Constructor *)
PROCEDURE New
( VAR set : TokenSet; segment3, segment2, segment1, segment0 : LONGCARD );
(* Passes a newly allocated and initialised TokenSet instance back in set.
The set is initalised from parameters segment3 to segment0 as follows:
bit 127 bit 0
v v
[<-----------------set---------------->]
[segment3][segment2][segment1][segment0]
^ ^ ^ ^
bit 32 bit 32 bit 32 bit 32
The bits in set correspond to the token values of type Token.
If the bitwidth of type LONGCARD is larger than 32, any higher bits are
ignored. The procedure passes back NIL if allocation is unsuccessful. *)
(* Destructor *)
PROCEDURE Release ( VAR set : TokenSet );
(* Releases set and passes back NIL if successful. *)
(* Operations *)
PROCEDURE Insert ( set : TokenSet; token : Token );
(* Inserts token into set. *)
PROCEDURE Remove ( set : TokenSet; token : Token );
(* Removes token from set. *)
PROCEDURE isEmpty ( set : TokenSet ) : BOOLEAN;
(* Returns TRUE if set is empty, otherwise FALSE. *)
PROCEDURE isElem ( set : TokenSet; token : Token ) : BOOLEAN;
(* Returns TRUE if token is an element of set, otherwise FALSE. *)
PROCEDURE count ( set : TokenSet ) : CARDINAL;
(* Returns the number of tokens in set. *)
(* Data Output *)
PROCEDURE PrintTokenList ( set : TokenSet );
(* Prints a comma separated list of tokens in set. *)
PROCEDURE PrintSegments ( set : TokenSet );
(* Prints a comma separated list of the data segments of set in base-16. *)
END TokenSet.