-
Notifications
You must be signed in to change notification settings - Fork 1
/
LexQueue.def
51 lines (30 loc) · 1.46 KB
/
LexQueue.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
(*!m2r10*) (* Copyright (c) 2015 B.Kowarsch. All rights reserved. *)
DEFINITION MODULE LexQueue;
(* Lexeme Queue for Modula-2 R10 Core Compiler *)
IMPORT Lexeme;
TYPE LexQueue = OPAQUE;
(* Constructor *)
PROCEDURE New ( VAR queue : LexQueue );
(* Allocates a new empty queue object and passes it back in queue.
Passes NIL if the allocation failed. *)
(* Destructor *)
PROCEDURE Release ( VAR queue : LexQueue );
(* Releases queue and passes back NIL if successful. *)
(* Operations *)
PROCEDURE enqueue ( queue : LexQueue; lexeme : Lexeme ) : Queue;
(* Adds lexeme to the head of queue and returns queue, or NIL on failure. *)
PROCEDURE enqueueUnique ( queue : LexQueue; lexeme : Lexeme ) : Queue;
(* Adds lexeme to the head of queue if and only if the value is not already
* present in queue. Returns queue on success, or NIL on failure. *)
PROCEDURE dequeue ( queue : LexQueue ) : Lexeme;
(* Removes the lexeme at the tail queue and returns it, or NIL on failure. *)
PROCEDURE isEmpty ( queue : LexQueue ) : BOOLEAN;
(* Returns TRUE if queue is empty, otherwise FALSE. *)
PROCEDURE isElem ( queue : LexQueue; lexeme : Lexeme ) : BOOLEAN;
(* Returns TRUE if node is stored in queue, otherwise FALSE. *)
PROCEDURE count ( queue : LexQueue ) : CARDINAL;
(* Returns the number of nodes in queue. *)
PROCEDURE Reset ( queue : LexQueue ) : AST;
(* Removes all nodes from queue but does not deallocate it.
Returns queue on success, or NIL if queue is NIL. *)
END LexQueue.