2 * symbol - global and local symbol routines
4 * Copyright (C) 1999-2007 David I. Bell
6 * Calc is open software; you can redistribute it and/or modify it under
7 * the terms of the version 2.1 of the GNU Lesser General Public License
8 * as published by the Free Software Foundation.
10 * Calc is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
13 * Public License for more details.
15 * A copy of version 2.1 of the GNU Lesser General Public License is
16 * distributed with calc under the filename COPYING-LGPL. You should have
17 * received a copy with calc; if not, write to Free Software Foundation, Inc.
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 * @(#) $Revision: 30.1 $
21 * @(#) $Id: symbol.h,v 30.1 2007/03/16 11:09:46 chongo Exp $
22 * @(#) $Source: /usr/local/src/bin/calc/RCS/symbol.h,v $
24 * Under source code control: 1990/02/15 01:48:37
25 * File existed as early as: before 1990
27 * Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
31 #if !defined(__SYMBOL_H__)
35 #if defined(CALC_SRC) /* if we are building from the calc source tree */
38 # include <calc/zmath.h>
43 * Symbol Declarations.
45 #define SYM_UNDEFINED 0 /* undefined symbol */
46 #define SYM_PARAM 1 /* parameter symbol */
47 #define SYM_LOCAL 2 /* local symbol */
48 #define SYM_GLOBAL 3 /* global symbol */
49 #define SYM_STATIC 4 /* static symbol */
51 #define SCOPE_GLOBAL 0 /* file scope level for global variables */
52 #define SCOPE_STATIC 1 /* lowest file scope for static variables */
55 typedef struct global GLOBAL
;
57 size_t g_len
; /* length of symbol name */
58 short g_filescope
; /* file scope level of symbol (0 if global) */
59 short g_funcscope
; /* function scope level of symbol */
60 char *g_name
; /* global symbol name */
61 VALUE g_value
; /* global symbol value */
62 GLOBAL
*g_next
; /* next symbol in hash chain */
67 * Routines to search for global symbols.
69 E_FUNC GLOBAL
*addglobal(char *name
, BOOL isstatic
);
70 E_FUNC GLOBAL
*findglobal(char *name
);
74 * Routines to return names of variables.
76 E_FUNC
char *localname(long n
);
77 E_FUNC
char *paramname(long n
);
78 E_FUNC
char *globalname(GLOBAL
*sp
);
82 * Routines to handle entering and leaving of scope levels.
84 E_FUNC
void resetscopes(void);
85 E_FUNC
void enterfilescope(void);
86 E_FUNC
void exitfilescope(void);
87 E_FUNC
void enterfuncscope(void);
88 E_FUNC
void exitfuncscope(void);
89 E_FUNC
void endscope (char *name
, BOOL isglobal
);
95 E_FUNC
long addlocal(char *name
);
96 E_FUNC
long findlocal(char *name
);
97 E_FUNC
long addparam(char *name
);
98 E_FUNC
long findparam(char *name
);
99 E_FUNC
void initlocals(void);
100 E_FUNC
void initglobals(void);
101 E_FUNC
int writeglobals(char *name
);
102 E_FUNC
int symboltype(char *name
);
103 E_FUNC
void showglobals(void);
104 E_FUNC
void showallglobals(void);
105 E_FUNC
void freeglobals(void);
106 E_FUNC
void showstatics(void);
107 E_FUNC
void freestatics(void);
110 #endif /* !__SYMBOL_H__ */