2004-04-23 11:58:43 +01:00
|
|
|
#ifndef SYMBOLS
|
|
|
|
#define SYMBOLS
|
|
|
|
|
2004-05-15 16:45:08 +01:00
|
|
|
//! Size of symbol hashtable.
|
|
|
|
/** Optimistically large. Should be a prime, says theory.
|
|
|
|
*/
|
2004-04-23 11:58:43 +01:00
|
|
|
#define HASHSIZE 997
|
|
|
|
|
2004-07-29 12:26:59 +01:00
|
|
|
enum symboltypes { T_UNDEF = -1, T_PROTOCOL, T_CONST, T_VAR, T_SYSCONST };
|
2004-04-23 11:58:43 +01:00
|
|
|
|
|
|
|
#define EOS 0
|
|
|
|
|
|
|
|
struct symbol
|
|
|
|
{
|
2004-05-15 16:45:08 +01:00
|
|
|
//! Type of symbol.
|
|
|
|
/**
|
|
|
|
*\sa T_UNDEF, T_PROTOCOL, T_CONST, T_VAR, T_SYSCONST
|
|
|
|
*/
|
2004-04-23 11:58:43 +01:00
|
|
|
int type;
|
2004-05-15 16:45:08 +01:00
|
|
|
//! Line number at which it occurred.
|
2004-04-23 11:58:43 +01:00
|
|
|
int lineno;
|
2004-05-15 16:45:08 +01:00
|
|
|
//! Ascii string with name of the symbol.
|
2004-08-09 10:42:58 +01:00
|
|
|
const char *text;
|
2004-05-15 16:45:08 +01:00
|
|
|
//! Possible next pointer.
|
2004-04-23 11:58:43 +01:00
|
|
|
struct symbol *next;
|
2004-05-15 16:45:08 +01:00
|
|
|
//! Used for linking all symbol blocks, freed or in use.
|
2004-04-23 11:58:43 +01:00
|
|
|
struct symbol *allocnext;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct symbol *Symbol;
|
|
|
|
|
|
|
|
void symbolsInit (void);
|
|
|
|
void symbolsDone (void);
|
|
|
|
|
|
|
|
Symbol get_symb (void);
|
2004-08-09 10:42:58 +01:00
|
|
|
void free_symb (const Symbol s);
|
2004-04-23 11:58:43 +01:00
|
|
|
|
2004-08-09 10:42:58 +01:00
|
|
|
void insert (const Symbol s);
|
|
|
|
Symbol lookup (const char *s);
|
|
|
|
void symbolPrint (const Symbol s);
|
|
|
|
void symbolPrintAll (void);
|
|
|
|
Symbol symbolSysConst (const char *str);
|
2004-04-23 11:58:43 +01:00
|
|
|
|
2004-07-29 13:36:24 +01:00
|
|
|
void eprintf (char *fmt, ... );
|
|
|
|
|
|
|
|
extern int globalError;
|
|
|
|
|
2004-04-23 11:58:43 +01:00
|
|
|
#endif
|