This is Unofficial EPICS BASE Doxygen Site
symtab.c File Reference
#include "defs.h"
+ Include dependency graph for symtab.c:

Go to the source code of this file.

Macros

#define TABLE_SIZE   1024
 

Functions

bucketmake_bucket (char *name)
 
bucketlookup (char *name)
 
void create_symbol_table (void)
 
void free_symbol_table (void)
 
void free_symbols (void)
 

Variables

bucket ** symbol_table
 
bucketfirst_symbol
 
bucketlast_symbol
 

Macro Definition Documentation

#define TABLE_SIZE   1024

Definition at line 15 of file symtab.c.

Function Documentation

void create_symbol_table ( void  )

Definition at line 88 of file symtab.c.

89 {
90  int i;
91  bucket *bp;
92 
93  symbol_table = (bucket **) MALLOC(TABLE_SIZE*sizeof(bucket *));
94  if (symbol_table == 0) no_space();
95  for (i = 0; i < TABLE_SIZE; i++)
96  symbol_table[i] = 0;
97 
98  bp = make_bucket("error");
99  bp->index = 1;
100  bp->class = TERM;
101 
102  first_symbol = bp;
103  last_symbol = bp;
104  symbol_table[hash("error")] = bp;
105 }
#define MALLOC(n)
Definition: defs.h:111
int i
Definition: scan.c:967
bucket ** symbol_table
Definition: symtab.c:18
#define TERM
Definition: defs.h:79
bucket * make_bucket(char *name)
Definition: symtab.c:40
char class
Definition: defs.h:129
bucket * first_symbol
Definition: symtab.c:19
bucket * last_symbol
Definition: symtab.c:20
short index
Definition: defs.h:127
#define TABLE_SIZE
Definition: symtab.c:15
void no_space(void) NORETURN
Definition: error.c:23
Internal: Hash table structure.
Definition: bucketLib.h:48
void free_symbol_table ( void  )

Definition at line 109 of file symtab.c.

110 {
112  symbol_table = 0;
113 }
bucket ** symbol_table
Definition: symtab.c:18
#define FREE(x)
Definition: defs.h:110
void free_symbols ( void  )

Definition at line 117 of file symtab.c.

118 {
119  bucket *p, *q;
120 
121  for (p = first_symbol; p; p = q)
122  {
123  q = p->next;
124  FREE(p);
125  }
126 }
bucket * first_symbol
Definition: symtab.c:19
#define FREE(x)
Definition: defs.h:110
struct bucket * next
Definition: defs.h:123
Internal: Hash table structure.
Definition: bucketLib.h:48
bucket* lookup ( char *  name)

Definition at line 66 of file symtab.c.

67 {
68  bucket *bp, **bpp;
69 
70  bpp = symbol_table + hash(name);
71  bp = *bpp;
72 
73  while (bp)
74  {
75  if (strcmp(name, bp->name) == 0) return (bp);
76  bpp = &bp->link;
77  bp = *bpp;
78  }
79 
80  *bpp = bp = make_bucket(name);
81  last_symbol->next = bp;
82  last_symbol = bp;
83 
84  return (bp);
85 }
bucket ** symbol_table
Definition: symtab.c:18
char * name
Definition: defs.h:124
struct bucket * link
Definition: defs.h:122
bucket * make_bucket(char *name)
Definition: symtab.c:40
bucket * last_symbol
Definition: symtab.c:20
struct bucket * next
Definition: defs.h:123
Internal: Hash table structure.
Definition: bucketLib.h:48
bucket* make_bucket ( char *  name)

Definition at line 40 of file symtab.c.

41 {
42  bucket *bp;
43 
44  assert(name);
45  bp = (bucket *) MALLOC(sizeof(bucket));
46  if (bp == 0) no_space();
47  bp->link = 0;
48  bp->next = 0;
49  bp->name = MALLOC(strlen(name) + 1);
50  if (bp->name == 0) no_space();
51  bp->tag = 0;
52  bp->value = UNDEFINED;
53  bp->index = 0;
54  bp->prec = 0;
55  bp-> class = UNKNOWN;
56  bp->assoc = TOKEN;
57 
58  if (bp->name == 0) no_space();
59  strcpy(bp->name, name);
60 
61  return (bp);
62 }
char * tag
Definition: defs.h:125
#define TOKEN
Definition: defs.h:64
#define assert(exp)
Declare that a condition should be true.
Definition: epicsAssert.h:70
#define MALLOC(n)
Definition: defs.h:111
#define UNDEFINED
Definition: defs.h:85
char * name
Definition: defs.h:124
#define UNKNOWN
Definition: defs.h:78
short prec
Definition: defs.h:128
struct bucket * link
Definition: defs.h:122
short index
Definition: defs.h:127
struct bucket * next
Definition: defs.h:123
short value
Definition: defs.h:126
void no_space(void) NORETURN
Definition: error.c:23
char assoc
Definition: defs.h:130
Internal: Hash table structure.
Definition: bucketLib.h:48

Variable Documentation

bucket* first_symbol

Definition at line 19 of file symtab.c.

bucket* last_symbol

Definition at line 20 of file symtab.c.

bucket** symbol_table

Definition at line 18 of file symtab.c.