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

Go to the source code of this file.

Functions

int hashfunct (char[], int)
 
struct hash_entryfindsym (char *sym, struct hash_entry **table, int table_size)
 
int addsym (char *sym, char *str_def, int int_def, struct hash_entry **table, int table_size)
 
void cclinstal (Char *ccltxt, int cclnum)
 
int ccllookup (Char *ccltxt)
 
int hashfunct (char *str, int hash_size)
 
void ndinstal (char *nd, Char *def)
 
Charndlookup (char *nd)
 
void scinstal (char *str, int xcluflg)
 
int sclookup (char *str)
 

Variables

struct hash_entryndtbl [NAME_TABLE_HASH_SIZE]
 
struct hash_entrysctbl [START_COND_HASH_SIZE]
 
struct hash_entryccltab [CCL_HASH_SIZE]
 

Function Documentation

int addsym ( char *  sym,
char *  str_def,
int  int_def,
struct hash_entry **  table,
int  table_size 
)

Definition at line 64 of file sym.c.

65 {
66  int hash_val = hashfunct( sym, table_size );
67  struct hash_entry *sym_entry = table[hash_val];
68  struct hash_entry *new_entry;
69  struct hash_entry *successor;
70 
71  while ( sym_entry )
72  {
73  if ( ! strcmp( sym, sym_entry->name ) )
74  { /* entry already exists */
75  return ( -1 );
76  }
77 
78  sym_entry = sym_entry->next;
79  }
80 
81  /* create new entry */
82  new_entry = (struct hash_entry *) malloc( sizeof( struct hash_entry ) );
83 
84  if ( new_entry == NULL )
85  flexfatal( "symbol table memory allocation failed" );
86 
87  if ( (successor = table[hash_val]) )
88  {
89  new_entry->next = successor;
90  successor->prev = new_entry;
91  }
92  else
93  new_entry->next = NULL;
94 
95  new_entry->prev = NULL;
96  new_entry->name = sym;
97  new_entry->str_val = str_def;
98  new_entry->int_val = int_def;
99 
100  table[hash_val] = new_entry;
101 
102  return ( 0 );
103  }
struct hash_entry * next
Definition: flexdef.h:286
char * name
Definition: flexdef.h:287
#define NULL
Definition: catime.c:38
Definition: flexdef.h:284
int hashfunct(char[], int)
char * str_val
Definition: flexdef.h:288
void flexfatal(char[])
struct hash_entry * prev
Definition: flexdef.h:286
int int_val
Definition: flexdef.h:289
void cclinstal ( Char ccltxt,
int  cclnum 
)

Definition at line 114 of file sym.c.

115 {
116  /* we don't bother checking the return status because we are not called
117  * unless the symbol is new
118  */
120 
121  (void) addsym( (char *) copy_unsigned_string( ccltxt ), (char *) 0, cclnum,
123  }
int addsym(char *sym, char *str_def, int int_def, struct hash_entry **table, int table_size)
Definition: sym.c:64
#define CCL_HASH_SIZE
Definition: flexdef.h:296
struct hash_entry * ccltab[CCL_HASH_SIZE]
Definition: sym.c:47
#define Char
Definition: flexdef.h:59
Char * copy_unsigned_string(Char *str)
Definition: misc.c:217
int ccllookup ( Char ccltxt)

Definition at line 134 of file sym.c.

135 {
136  return ( findsym( (char *) ccltxt, ccltab, CCL_HASH_SIZE )->int_val );
137  }
#define CCL_HASH_SIZE
Definition: flexdef.h:296
struct hash_entry * ccltab[CCL_HASH_SIZE]
Definition: sym.c:47
struct hash_entry * findsym(char *sym, struct hash_entry **table, int table_size)
Definition: sym.c:150
int int_val
Definition: flexdef.h:289
struct hash_entry * findsym ( char *  sym,
struct hash_entry **  table,
int  table_size 
)

Definition at line 150 of file sym.c.

151 {
152  struct hash_entry *sym_entry = table[hashfunct( sym, table_size )];
153  static struct hash_entry empty_entry =
154  {
155  (struct hash_entry *) 0, (struct hash_entry *) 0, NULL, NULL, 0,
156  } ;
157 
158  while ( sym_entry )
159  {
160  if ( ! strcmp( sym, sym_entry->name ) )
161  return ( sym_entry );
162  sym_entry = sym_entry->next;
163  }
164 
165  return ( &empty_entry );
166  }
struct hash_entry * next
Definition: flexdef.h:286
char * name
Definition: flexdef.h:287
#define NULL
Definition: catime.c:38
Definition: flexdef.h:284
int hashfunct(char[], int)
int hashfunct ( char  [],
int   
)
int hashfunct ( char *  str,
int  hash_size 
)

Definition at line 177 of file sym.c.

178 {
179  int hashval;
180  int locstr;
181 
182  hashval = 0;
183  locstr = 0;
184 
185  while ( str[locstr] )
186  hashval = ((hashval << 1) + str[locstr++]) % hash_size;
187 
188  return ( hashval );
189  }
#define str(v)
void ndinstal ( char *  nd,
Char def 
)

Definition at line 200 of file sym.c.

201 {
202  char *copy_string();
204 
205  if ( addsym( copy_string( nd ), (char *) copy_unsigned_string( def ), 0,
207  synerr( "name defined twice" );
208  }
int addsym(char *sym, char *str_def, int int_def, struct hash_entry **table, int table_size)
Definition: sym.c:64
#define NAME_TABLE_HASH_SIZE
Definition: flexdef.h:294
void synerr(char[])
char * copy_string(char *str)
Definition: misc.c:188
#define Char
Definition: flexdef.h:59
struct hash_entry * ndtbl[NAME_TABLE_HASH_SIZE]
Definition: sym.c:45
Char * copy_unsigned_string(Char *str)
Definition: misc.c:217
int * def
Definition: flex.c:92
Char* ndlookup ( char *  nd)

Definition at line 219 of file sym.c.

220 {
221  return ( (Char *) findsym( nd, ndtbl, NAME_TABLE_HASH_SIZE )->str_val );
222  }
#define NAME_TABLE_HASH_SIZE
Definition: flexdef.h:294
#define Char
Definition: flexdef.h:59
char * str_val
Definition: flexdef.h:288
struct hash_entry * ndtbl[NAME_TABLE_HASH_SIZE]
Definition: sym.c:45
struct hash_entry * findsym(char *sym, struct hash_entry **table, int table_size)
Definition: sym.c:150
void scinstal ( char *  str,
int  xcluflg 
)

Definition at line 236 of file sym.c.

237 {
238  char *copy_string();
239 
240  /* bit of a hack. We know how the default start-condition is
241  * declared, and don't put out a define for it, because it
242  * would come out as "#define 0 1"
243  */
244  /* actually, this is no longer the case. The default start-condition
245  * is now called "INITIAL". But we keep the following for the sake
246  * of future robustness.
247  */
248 
249  if ( strcmp( str, "0" ) )
250  printf( "#define %s %d\n", str, lastsc );
251 
252  if ( ++lastsc >= current_max_scs )
253  {
255 
256  ++num_reallocs;
257 
264  }
265 
267 
268  if ( addsym( scname[lastsc], (char *) 0, lastsc,
270  format_pinpoint_message( "start condition %s declared twice", str );
271 
274  scxclu[lastsc] = xcluflg;
275  sceof[lastsc] = false;
276  }
int * actvsc
Definition: flex.c:87
int addsym(char *sym, char *str_def, int int_def, struct hash_entry **table, int table_size)
Definition: sym.c:64
char ** scname
Definition: flex.c:88
void format_pinpoint_message(char[], char[])
int * scxclu
Definition: flex.c:87
#define START_COND_HASH_SIZE
Definition: flexdef.h:295
#define MAX_SCS_INCREMENT
Definition: flexdef.h:195
#define SYM_EPSILON
Definition: flexdef.h:192
int num_reallocs
Definition: flex.c:100
#define printf
Definition: epicsStdio.h:41
#define str(v)
int mkstate(int)
Definition: nfa.c:578
int * scset
Definition: flex.c:87
int * scbol
Definition: flex.c:87
char * copy_string(char *str)
Definition: misc.c:188
int current_max_scs
Definition: flex.c:87
struct hash_entry * sctbl[START_COND_HASH_SIZE]
Definition: sym.c:46
#define reallocate_integer_array(array, size)
Definition: flexdef.h:584
#define reallocate_char_ptr_array(array, size)
Definition: flexdef.h:600
int lastsc
Definition: flex.c:87
int * sceof
Definition: flex.c:87
int sclookup ( char *  str)

Definition at line 287 of file sym.c.

288 {
289  return ( findsym( str, sctbl, START_COND_HASH_SIZE )->int_val );
290  }
#define START_COND_HASH_SIZE
Definition: flexdef.h:295
#define str(v)
struct hash_entry * sctbl[START_COND_HASH_SIZE]
Definition: sym.c:46
struct hash_entry * findsym(char *sym, struct hash_entry **table, int table_size)
Definition: sym.c:150
int int_val
Definition: flexdef.h:289

Variable Documentation

struct hash_entry* ccltab[CCL_HASH_SIZE]

Definition at line 47 of file sym.c.

Definition at line 45 of file sym.c.

Definition at line 46 of file sym.c.