mirror of
https://github.com/lcn2/calc.git
synced 2025-08-16 01:03:29 +03:00
78 lines
1.8 KiB
C
78 lines
1.8 KiB
C
/*
|
|
* Copyright (c) 1993 David I. Bell
|
|
* Permission is granted to use, distribute, or modify this source,
|
|
* provided that this copyright notice remains intact.
|
|
*/
|
|
|
|
#ifndef SYMBOL_H
|
|
#define SYMBOL_H
|
|
|
|
#include "zmath.h"
|
|
|
|
|
|
/*
|
|
* Symbol Declarations.
|
|
*/
|
|
#define SYM_UNDEFINED 0 /* undefined symbol */
|
|
#define SYM_PARAM 1 /* parameter symbol */
|
|
#define SYM_LOCAL 2 /* local symbol */
|
|
#define SYM_GLOBAL 3 /* global symbol */
|
|
#define SYM_STATIC 4 /* static symbol */
|
|
|
|
#define SCOPE_GLOBAL 0 /* file scope level for global variables */
|
|
#define SCOPE_STATIC 1 /* lowest file scope for static variables */
|
|
|
|
|
|
typedef struct global GLOBAL;
|
|
struct global {
|
|
int g_len; /* length of symbol name */
|
|
short g_filescope; /* file scope level of symbol (0 if global) */
|
|
short g_funcscope; /* function scope level of symbol */
|
|
char *g_name; /* global symbol name */
|
|
VALUE g_value; /* global symbol value */
|
|
GLOBAL *g_next; /* next symbol in hash chain */
|
|
};
|
|
|
|
|
|
/*
|
|
* Routines to search for global symbols.
|
|
*/
|
|
extern GLOBAL *addglobal(char *name, BOOL isstatic);
|
|
extern GLOBAL *findglobal(char *name);
|
|
|
|
|
|
/*
|
|
* Routines to return names of variables.
|
|
*/
|
|
extern char *localname(long n);
|
|
extern char *paramname(long n);
|
|
extern char *globalname(GLOBAL *sp);
|
|
|
|
|
|
/*
|
|
* Routines to handle entering and leaving of scope levels.
|
|
*/
|
|
extern void resetscopes(void);
|
|
extern void enterfilescope(void);
|
|
extern void exitfilescope(void);
|
|
extern void enterfuncscope(void);
|
|
extern void exitfuncscope(void);
|
|
|
|
|
|
/*
|
|
* Other routines.
|
|
*/
|
|
extern long addlocal(char *name);
|
|
extern long findlocal(char *name);
|
|
extern long addparam(char *name);
|
|
extern long findparam(char *name);
|
|
extern void initlocals(void);
|
|
extern void initglobals(void);
|
|
extern int writeglobals(char *name);
|
|
extern int symboltype(char *name);
|
|
extern void showglobals(void);
|
|
|
|
#endif
|
|
|
|
/* END CODE */
|