-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSymbol_Table_Row.h
More file actions
79 lines (68 loc) · 5.18 KB
/
Copy pathSymbol_Table_Row.h
File metadata and controls
79 lines (68 loc) · 5.18 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\
* Header File: Definition of the 'Symbol_Table_Row' Class *
* CISC 3160 - Programming Languages - Fall 2019 - Toy Language Project *
* Author: *
* Miriam Briskman *
* Supervised by: *
* Professor Neng-Fa Zhou *
\* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#ifndef SYMBOL_TABLE_ROW_H
#define SYMBOL_TABLE_ROW_H
using namespace std;
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\
* The Symbol_Table_Row Class *
* Purpose: *
* To preserve the attributes of identifiers. Each object is a row in the Symbol Table. *
* Data variables (private): *
* 1) 'isInit' (bool) - tells if a variable was initialized. *
* 2) 'intValue' (long long) - keeps the value that corresponds to identifier. *
* Functions (public): *
* 1) Constructor. *
* 2) 'isInitialized' - returns 'true' if variable was initialized and false otherwise (bool). *
* 3) 'getValue' - returns the value of the variable (long long). *
* 4) 'initialize' - updates that the variable was initialized (void). *
* 5) 'setValue' - changes the value of the variable (void). *
\* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
class Symbol_Table_Row
{
private:
/* Data Fields: */
bool isInit; // Has the variable (identifier) been initialized before use?
long long intValue; // The value that corresponds to an identifier or literal
public:
/* Constructor */
Symbol_Table_Row (bool isInitialized = false, long long intValue = 0)
{
this -> isInit = isInitialized;
this -> intValue = intValue;
}
/* Accessors (Getters) Functions (all inline functions) */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\
* 'isInitialized': *
* Input: None. *
* Output: True if 'isInit' is True; False otherwise. *
\* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
bool isInitialized (void) { return isInit; }
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\
* 'getValue': *
* Input: None. *
* Output: the content of 'intValue' (long long int). *
\* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
long long getValue (void) { return intValue; }
/* Mutators (Setters) Functions (all inline functions) */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\
* 'initialize': *
* Input: None. *
* Output: Sets 'isInit' to True. *
* No object is returned. *
\* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
void initialize (void) { isInit = true; }
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\
* 'setValue': *
* Input: 'intValue' (long long int). *
* Output: Sets the object's 'intValue' to the content of the argument. *
* No object is returned. *
\* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
void setValue (long long intValue) { this -> intValue = intValue; }
}; // End of the Symbol_Table_Row class
#endif