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

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

Parent Directory Parent Directory | Revision Log Revision Log


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

1 johnpye 485 /* ASCEND modelling environment
2     Copyright (C) 1990, 1993, 1994 Thomas Guthrie Epperly
3     Copyright (C) 2006 Carnegie Mellon University
4 aw0a 1
5 johnpye 485 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 aw0a 1
10 johnpye 485 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 jpye 2648 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 johnpye 485 *//** @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 johnpye 1209 by Tom Epperly, 7/24/89
26     Last in CVS $Revision: 1.7 $ $Date: 1998/02/05 16:38:07 $ $Author: ballan $
27 johnpye 485 */
28    
29 johnpye 67 #ifndef ASC_SYMTAB_H
30     #define ASC_SYMTAB_H
31 aw0a 1
32 jpye 2323 #include <ascend/general/platform.h>
33 johnpye 1209 #include "compiler.h"
34    
35 jpye 2321 /** @addtogroup compiler_common Compiler Common
36 johnpye 1066 @{
37     */
38    
39 aw0a 1 #define MAXIMUM_STRING_LENGTH (2*MAXTOKENLENGTH)
40    
41 jpye 3348 ASC_DLLSPEC void DestroyStringSpace(void);
42 johnpye 480 /**<
43 aw0a 1 * This deallocates all the memory associated with the string space.
44     */
45    
46 johnpye 1063 ASC_DLLSPEC void InitSymbolTable(void);
47 johnpye 480 /**<
48 jpye 3348 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 aw0a 1
56 jpye 3348 Note: you need to DestroySymbolTable as well as DestroyStringSpace if you
57     want to clean up everything from this file.
58     */
59    
60 johnpye 1063 ASC_DLLSPEC symchar*AddSymbol(CONST char *c);
61 johnpye 480 /**<
62 aw0a 1 * 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 jds 54 * by the user.<br><br>
67 aw0a 1 *
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 jds 54 * for the life of the ASCEND process.<br><br>
75 aw0a 1 *
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 johnpye 380 *
80     * @example symchar *permanentstring = AddSymbol(c);
81 aw0a 1 */
82    
83 johnpye 1063 ASC_DLLSPEC symchar *AddSymbolL(CONST char *c, int len);
84 johnpye 480 /**<
85 aw0a 1 * 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 jds 54 * for some other reason.<br><br>
90 aw0a 1 *
91     * Assumptions to be satisfied before calling:
92 jds 54 * Symbol table initialized and c is a null terminated string.<br><br>
93 aw0a 1 *
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 johnpye 1063 ASC_DLLSPEC symchar*AscFindSymbol(symchar *s);
101 johnpye 480 /**<
102 aw0a 1 * Returns NULL if the pointer s given is not from the table.
103 johnpye 480 * Otherwise returns the pointer given.
104 aw0a 1 * 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 jpye 3369 ASC_DLLSPEC void PrintTab(int noisy);
110 johnpye 480 /**<
111 jds 54 * Print a report on stdout about the string hash table.
112 aw0a 1 * if (noisy) prints lots of goop.
113     */
114    
115 johnpye 1063 ASC_DLLSPEC void DestroySymbolTable(void);
116 johnpye 480 /**<
117 aw0a 1 * This function will deallocate all the memory associated with the
118     * symbol table and the symbols it contains.
119     */
120    
121 johnpye 1066 /* @} */
122    
123 johnpye 67 #endif /* ASC_SYMTAB_H */
124 jds 54

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