Last change
on this file since 187 was 2, checked in by Rick van der Zwet, 15 years ago |
Initial import of data of old repository ('data') worth keeping (e.g. tracking
means of URL access statistics)
|
File size:
1.4 KB
|
Line | |
---|
1 | /*
|
---|
2 | * Scope.h
|
---|
3 | *
|
---|
4 | * This file contains the declaration of the "Scope" structure.
|
---|
5 | * It is part of the assignment for the Compiler Construction course at the
|
---|
6 | * Leiden Institute of Advanced Computer Science (LIACS), Leiden University.
|
---|
7 | *
|
---|
8 | * Note: when a Scope object is deleted, all Symbol objects contained in that
|
---|
9 | * Scope are also deleted.
|
---|
10 | */
|
---|
11 |
|
---|
12 | #ifndef _SCOPE_H_
|
---|
13 | #define _SCOPE_H_
|
---|
14 |
|
---|
15 | #include <cstdio>
|
---|
16 | #include <string>
|
---|
17 | #include <vector>
|
---|
18 |
|
---|
19 | #include "Symbol.h"
|
---|
20 |
|
---|
21 | using namespace std;
|
---|
22 |
|
---|
23 | // Class representing a scope
|
---|
24 | class Scope {
|
---|
25 | public:
|
---|
26 | // Constructor
|
---|
27 | Scope (string scope);
|
---|
28 |
|
---|
29 | // Destructor: deletes all Symbols contained in this Scope
|
---|
30 | ~Scope ();
|
---|
31 |
|
---|
32 | // Sets the name of the scope
|
---|
33 | void SetName(string name);
|
---|
34 |
|
---|
35 | // Gets the name of the scope
|
---|
36 | string GetName ();
|
---|
37 |
|
---|
38 | // Adds the given symbol to this scope
|
---|
39 | // Returns -1 if the symbol could not be added
|
---|
40 | int AddSymbol (Symbol * symbol);
|
---|
41 |
|
---|
42 | // Returns the symbol identified by <name> in this scope.
|
---|
43 | // Returns NULL if the symbol cannot be found.
|
---|
44 | Symbol * GetSymbol (string name);
|
---|
45 |
|
---|
46 | // Returns the i-th symbol of this scope.
|
---|
47 | Symbol * GetSymbol (unsigned int i);
|
---|
48 |
|
---|
49 | // Returns the number of symbols in this scope
|
---|
50 | unsigned int GetNumberOfSymbols ();
|
---|
51 |
|
---|
52 | // Dumps the contents of this scope
|
---|
53 | void Dump (FILE * file, int indent);
|
---|
54 |
|
---|
55 | private:
|
---|
56 | string myName;
|
---|
57 | vector<Symbol *> mySymbols;
|
---|
58 | };//Scope
|
---|
59 |
|
---|
60 | #endif
|
---|
61 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.