1 |
/* ASCEND modelling environment |
2 |
Copyright (C) 1990, 1993, 1994 Thomas Guthrie Epperly |
3 |
Copyright (C) 2006 Carnegie Mellon University |
4 |
|
5 |
This program is free software; you can redistribute it and/or modify |
6 |
it under the terms of the GNU General Public License as published by |
7 |
the Free Software Foundation; either version 2, or (at your option) |
8 |
any later version. |
9 |
|
10 |
This program is distributed in the hope that it will be useful, |
11 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 |
GNU General Public License for more details. |
14 |
|
15 |
You should have received a copy of the GNU General Public License |
16 |
along with this program; if not, write to the Free Software |
17 |
Foundation, Inc., 59 Temple Place - Suite 330, |
18 |
Boston, MA 02111-1307, USA. |
19 |
*//** @file |
20 |
Symbol Table Management. |
21 |
|
22 |
Provide symbol table management facilities for Ascend compiler. For |
23 |
now all the symbol table has to do is make sure that only one copy of each |
24 |
string is stored(to save space). In the future it could have more |
25 |
information store in it. |
26 |
|
27 |
Requires: |
28 |
#include "utilities/ascConfig.h" |
29 |
#include "compiler.h" |
30 |
*//* |
31 |
by Tom Epperly |
32 |
7/24/89 |
33 |
Version: $Revision: 1.7 $ |
34 |
Version control file: $RCSfile: symtab.h,v $ |
35 |
Date last modified: $Date: 1998/02/05 16:38:07 $ |
36 |
Last modified by: $Author: ballan $ |
37 |
*/ |
38 |
|
39 |
#ifndef ASC_SYMTAB_H |
40 |
#define ASC_SYMTAB_H |
41 |
|
42 |
#include <utilities/ascConfig.h> |
43 |
|
44 |
#define MAXIMUM_STRING_LENGTH (2*MAXTOKENLENGTH) |
45 |
|
46 |
extern void DestroyStringSpace(void); |
47 |
/**< |
48 |
* This deallocates all the memory associated with the string space. |
49 |
*/ |
50 |
|
51 |
ASC_DLLSPEC(void) InitSymbolTable(void); |
52 |
/**< |
53 |
* This procedure performs all the necessary initialization for the symbol |
54 |
* table manager. It should be called once and only once, and it must |
55 |
* be called before any of the other symbol table routines have been |
56 |
* called. |
57 |
* Assumptions: |
58 |
* Pre: none |
59 |
* Post: the symbol table is initialized |
60 |
*/ |
61 |
|
62 |
ASC_DLLSPEC(symchar*) AddSymbol(CONST char *c); |
63 |
/**< |
64 |
* This function adds the string c to the symbol table if it is not already |
65 |
* defined. This uses a copy of c rather than c itself. c must be a |
66 |
* NULL terminated string. allocation/deallocation of c is the users |
67 |
* responsibility. The symchar pointer returned should never be freed |
68 |
* by the user.<br><br> |
69 |
* |
70 |
* Assumptions that must be satisfied before calling: |
71 |
* Symbol table initialized and c is a null terminated string. |
72 |
* |
73 |
* Assumptions valid after calling: |
74 |
* The value of c has been added to the symbol table and the symbol table is |
75 |
* not changed in any other way. The symchar * returned will be the same |
76 |
* for the life of the ASCEND process.<br><br> |
77 |
* |
78 |
* Any size string can be stored in this table, though it's a bad |
79 |
* idea to store very large ones. Strings below MAXIMUM_STRING_LENGTH |
80 |
* we store efficiently. |
81 |
* |
82 |
* @example symchar *permanentstring = AddSymbol(c); |
83 |
*/ |
84 |
|
85 |
ASC_DLLSPEC(symchar *) AddSymbolL(CONST char *c, int len); |
86 |
/**< |
87 |
* This function does exactly what add symbol does except the length of the |
88 |
* string is passed as a parameter. The length is the number of characters |
89 |
* before the terminating '\0'. |
90 |
* This function is mildly faster than AddSymbol if you already know clen |
91 |
* for some other reason.<br><br> |
92 |
* |
93 |
* Assumptions to be satisfied before calling: |
94 |
* Symbol table initialized and c is a null terminated string.<br><br> |
95 |
* |
96 |
* Assumptions valid after calling: |
97 |
* The value of c has been added to the symbol table and the symbol table is |
98 |
* not changed in any other way. The symchar * returned will be the same |
99 |
* for the life of the ASCEND process. |
100 |
*/ |
101 |
|
102 |
ASC_DLLSPEC(symchar*) AscFindSymbol(symchar *s); |
103 |
/**< |
104 |
* Returns NULL if the pointer s given is not from the table. |
105 |
* Otherwise returns the pointer given. |
106 |
* This function does not check whether a string with the value |
107 |
* that s points to is in the table; this function checks that _s_ |
108 |
* is in the table. |
109 |
*/ |
110 |
|
111 |
extern void PrintTab(int noisy); |
112 |
/**< |
113 |
* Print a report on stdout about the string hash table. |
114 |
* if (noisy) prints lots of goop. |
115 |
*/ |
116 |
|
117 |
ASC_DLLSPEC(void) DestroySymbolTable(void); |
118 |
/**< |
119 |
* This function will deallocate all the memory associated with the |
120 |
* symbol table and the symbols it contains. |
121 |
*/ |
122 |
|
123 |
#endif /* ASC_SYMTAB_H */ |
124 |
|