/[ascend]/trunk/ascend/compiler/symtab.h
ViewVC logotype

Contents of /trunk/ascend/compiler/symtab.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3369 - (show annotations) (download) (as text)
Sun May 27 00:44:12 2018 UTC (3 months, 3 weeks ago) by jpye
File MIME type: text/x-chdr
File size: 4252 byte(s)
symbol table test

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, see <http://www.gnu.org/licenses/>.
17 *//** @file
18 Symbol Table Management.
19
20 Provide symbol table management facilities for Ascend compiler. For
21 now all the symbol table has to do is make sure that only one copy of each
22 string is stored(to save space). In the future it could have more
23 information store in it.
24 *//*
25 by Tom Epperly, 7/24/89
26 Last in CVS $Revision: 1.7 $ $Date: 1998/02/05 16:38:07 $ $Author: ballan $
27 */
28
29 #ifndef ASC_SYMTAB_H
30 #define ASC_SYMTAB_H
31
32 #include <ascend/general/platform.h>
33 #include "compiler.h"
34
35 /** @addtogroup compiler_common Compiler Common
36 @{
37 */
38
39 #define MAXIMUM_STRING_LENGTH (2*MAXTOKENLENGTH)
40
41 ASC_DLLSPEC void DestroyStringSpace(void);
42 /**<
43 * This deallocates all the memory associated with the string space.
44 */
45
46 ASC_DLLSPEC void InitSymbolTable(void);
47 /**<
48 This procedure performs all the necessary initialization for the symbol
49 table manager. It should be called once and only once, and it must
50 be called before any of the other symbol table routines have been
51 called.
52 Assumptions:
53 Pre: none
54 Post: the symbol table is initialized
55
56 Note: you need to DestroySymbolTable as well as DestroyStringSpace if you
57 want to clean up everything from this file.
58 */
59
60 ASC_DLLSPEC symchar*AddSymbol(CONST char *c);
61 /**<
62 * This function adds the string c to the symbol table if it is not already
63 * defined. This uses a copy of c rather than c itself. c must be a
64 * NULL terminated string. allocation/deallocation of c is the users
65 * responsibility. The symchar pointer returned should never be freed
66 * by the user.<br><br>
67 *
68 * Assumptions that must be satisfied before calling:
69 * Symbol table initialized and c is a null terminated string.
70 *
71 * Assumptions valid after calling:
72 * The value of c has been added to the symbol table and the symbol table is
73 * not changed in any other way. The symchar * returned will be the same
74 * for the life of the ASCEND process.<br><br>
75 *
76 * Any size string can be stored in this table, though it's a bad
77 * idea to store very large ones. Strings below MAXIMUM_STRING_LENGTH
78 * we store efficiently.
79 *
80 * @example symchar *permanentstring = AddSymbol(c);
81 */
82
83 ASC_DLLSPEC symchar *AddSymbolL(CONST char *c, int len);
84 /**<
85 * This function does exactly what add symbol does except the length of the
86 * string is passed as a parameter. The length is the number of characters
87 * before the terminating '\0'.
88 * This function is mildly faster than AddSymbol if you already know clen
89 * for some other reason.<br><br>
90 *
91 * Assumptions to be satisfied before calling:
92 * Symbol table initialized and c is a null terminated string.<br><br>
93 *
94 * Assumptions valid after calling:
95 * The value of c has been added to the symbol table and the symbol table is
96 * not changed in any other way. The symchar * returned will be the same
97 * for the life of the ASCEND process.
98 */
99
100 ASC_DLLSPEC symchar*AscFindSymbol(symchar *s);
101 /**<
102 * Returns NULL if the pointer s given is not from the table.
103 * Otherwise returns the pointer given.
104 * This function does not check whether a string with the value
105 * that s points to is in the table; this function checks that _s_
106 * is in the table.
107 */
108
109 ASC_DLLSPEC void PrintTab(int noisy);
110 /**<
111 * Print a report on stdout about the string hash table.
112 * if (noisy) prints lots of goop.
113 */
114
115 ASC_DLLSPEC void DestroySymbolTable(void);
116 /**<
117 * This function will deallocate all the memory associated with the
118 * symbol table and the symbols it contains.
119 */
120
121 /* @} */
122
123 #endif /* ASC_SYMTAB_H */
124

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22