File: symbol.h

package info (click to toggle)
cproto 4.7f-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 804 kB
  • ctags: 656
  • sloc: ansic: 4,017; sh: 2,987; lex: 1,056; yacc: 872; makefile: 232
file content (32 lines) | stat: -rw-r--r-- 911 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/* $Id: symbol.h,v 4.2 2004/03/24 19:56:11 tom Exp $
 *
 * A symbol table is a collection of string identifiers stored in a
 * hash table.
 */
#ifndef SYMBOL_H
#define SYMBOL_H

typedef struct symbol {
    struct symbol *next;	/* next symbol in list */
    char *name; 		/* name of symbol */
    char *value;		/* value of symbol (for defines) */
    short flags;		/* symbol attributes */
} Symbol;

/* The hash table length should be a prime number. */
#define SYM_MAX_HASH 251

typedef struct symbol_table {
    Symbol *bucket[SYM_MAX_HASH];	/* hash buckets */
} SymbolTable;

extern SymbolTable *new_symbol_table	/* Create symbol table */
	(void);
extern void free_symbol_table		/* Destroy symbol table */
	(SymbolTable *s);
extern Symbol *find_symbol		/* Lookup symbol name */
	(SymbolTable *s, char *n);
extern Symbol *new_symbol		/* Define new symbol */
	(SymbolTable *s, char *n, char *v, int f);

#endif