Repository navigation
Expand file tree
/
Copy pathscopeStack.h
More file actions
47 lines (45 loc) · 1.88 KB
/
Copy pathscopeStack.h
File metadata and controls
47 lines (45 loc) · 1.88 KB
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
/***************************************************************************
scopeStack code Module
***************************************************************************/
/*=========================================================================
DECLARATIONS
=========================================================================*/
/*-------------------------------------------------------------------------
scopeStack code RECORD
-------------------------------------------------------------------------*/
struct scopeStack {
struct symrec * scope;
struct scopeStack* next;
};
/*-------------------------------------------------------------------------
scopeStack code ENTRY
-------------------------------------------------------------------------*/
struct scopeStack* SStop = (struct scopeStack*) 0;
/*-------------------------------------------------------------------------
scopeStack code
Implementation: a chain of records.
------------------------------------------------------------------------*/
/*-------------------------------------------------------------------------
initialization
------------------------------------------------------------------------*/
/*========================================================================
Operations: enQueue, deQueue, isEmpty.
========================================================================*/
void SSPush(struct symrec * scope){
struct scopeStack* newOne = (struct scopeStack* ) malloc(sizeof(struct scopeStack));
newOne->scope = scope;
newOne->next = SStop;
SStop= newOne;
}
int SSIsEmpty(){
return SStop == (struct scopeStack*) 0;
}
struct symrec * SSPop(){
if(SSIsEmpty()) return 0;
struct symrec * tempScope = SStop->scope;
struct scopeStack* temp = SStop;
SStop = temp->next;
free(temp);
return tempScope;
}
/************************** End scopeStack code **************************/