ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE-3.0/src/io/BASS_parse.c
(Generate patch)

Comparing trunk/OOPSE-3.0/src/io/BASS_parse.c (file contents):
Revision 2204 by gezelter, Fri Apr 15 22:04:00 2005 UTC vs.
Revision 2263 by tim, Wed Jul 13 15:54:00 2005 UTC

# Line 51 | Line 51
51   #include "io/mpiBASS.h"
52   #endif
53  
54 < #define HASH_SIZE 211 // the size of the hash table
55 < #define SHIFT 4 // the bit shift for the hash index
54 > #define HASH_SIZE 211 /* the size of the hash table*/
55 > #define SHIFT 4 /* the bit shift for the hash index */
56  
57  
58 < //*** Global functions, variables, and structures ************
58 > /**** Global functions, variables, and structures *************/
59  
60 <    unsigned short is_initialized = 0; // tells whether to init the linked list
60 >    unsigned short is_initialized = 0; /* tells whether to init the linked list*/
61  
62 < // reserved word elements for the hash table
62 > /* reserved word elements for the hash table*/
63   struct res_element{
64 <  char word[100];        //the reserved word
65 <  int token;             //the token to return;
64 >  char word[100];        /*the reserved word*/
65 >  int token;             /*the token to return;*/
66    struct res_element* next;
67   };
68  
69 < struct res_element** reserved = NULL; //the table of reserved words
69 > struct res_element** reserved = NULL; /*the table of reserved words*/
70  
71 < void initialize_res_list(void); // function to initialize the list
71 > void initialize_res_list(void); /* function to initialize the list*/
72  
73 < int hash ( char* text ); // generates the hash key
73 > int hash ( char* text ); /* generates the hash key*/
74  
75 < void add_res_element( char* text, int the_token ); //adds elements to the table
75 > void add_res_element( char* text, int the_token ); /*adds elements to the table*/
76  
77 < // the elements of the defined Hash table
77 > /* the elements of the defined Hash table*/
78   struct defined_element{
79    char defined[100];
80    char definition[DEFINED_BUFFER_SIZE];
81    struct defined_element* next;
82   };
83  
84 < struct defined_element** defined_list = NULL; // the defined hash table
84 > struct defined_element** defined_list = NULL; /* the defined hash table*/
85  
86  
87  
88 < //*** The Functions *******************************************
88 > /**** The Functions ********************************************/
89  
90  
91    /*
# Line 94 | Line 94 | void initialize_res_list(){
94  
95   void initialize_res_list(){
96    
97 <  register unsigned short i; // loop counter
97 >  register unsigned short i; /* loop counter*/
98  
99    reserved = ( struct res_element ** )
100      calloc( HASH_SIZE, sizeof( struct hash__element* ) );
# Line 104 | Line 104 | void initialize_res_list(){
104      reserved[i] = NULL;
105    }
106  
107 <  // add the reserved words
107 >  /* add the reserved words*/
108  
109    add_res_element( "molecule", MOLECULE );
110    add_res_element( "atom", ATOM );
# Line 120 | Line 120 | void initialize_res_list(){
120    add_res_element( "rigidBody", RIGIDBODY );
121    add_res_element( "cutoffGroup", CUTOFFGROUP );
122    
123 <  is_initialized = 1; // set the initialization boolean to true
123 >  is_initialized = 1; /* set the initialization boolean to true*/
124   }
125  
126  
# Line 133 | Line 133 | int res_word( char* text ){
133   int res_word( char* text ){
134    
135    int matched = 0;
136 <  int key; // the hash key
137 <  struct res_element* current_ptr; // points to the current hash element
138 <  struct defined_element* def_ptr; // points to the current define element
136 >  int key; /* the hash key*/
137 >  struct res_element* current_ptr; /* points to the current hash element*/
138 >  struct defined_element* def_ptr; /* points to the current define element*/
139  
140 <  if( !is_initialized ){ // initialize the list if not already done
140 >  if( !is_initialized ){ /* initialize the list if not already done*/
141  
142      initialize_res_list();
143    }
144    
145 <  // get the hash key
145 >  /* get the hash key*/
146  
147    key = hash( text );
148    current_ptr = reserved[key];
149  
150 <  // walk through possible mutiple entries
150 >  /* walk through possible mutiple entries*/
151  
152    while( current_ptr != NULL ){
153      
154      matched = !strcmp( text, current_ptr->word );
155 <    if( matched ) return current_ptr->token; // search successful
155 >    if( matched ) return current_ptr->token; /* search successful*/
156  
157      current_ptr = current_ptr->next;
158    }
159  
160 <  // if no keywords turn up, check the word against the list of defines
160 >  /* if no keywords turn up, check the word against the list of defines*/
161    
162    if( defined_list != NULL ){
163  
# Line 172 | Line 172 | int res_word( char* text ){
172      }
173    }
174  
175 <  return 0; //search failed
175 >  return 0; /*search failed*/
176   }
177  
178   /*
# Line 184 | Line 184 | int is_defined( char* text ){
184  
185    int matched = 0;
186    int key;
187 <  struct defined_element* def_ptr; // points to the current define element
187 >  struct defined_element* def_ptr; /* points to the current define element*/
188    
189    key = hash( text );
190  
# Line 194 | Line 194 | int is_defined( char* text ){
194      while( def_ptr != NULL ){
195        
196        matched = !strcmp( text, def_ptr->defined );
197 <      if( matched ) return 1; // search succesful
197 >      if( matched ) return 1; /* search succesful*/
198        
199        def_ptr = def_ptr->next;
200      }
201    }
202  
203 <  return 0; //search failed
203 >  return 0; /*search failed*/
204   }
205  
206   /*
# Line 226 | Line 226 | char* get_definition( char* defined ){
226      }
227    }
228    
229 <  // search failed, therefore there is an error
229 >  /* search failed, therefore there is an error*/
230  
231    sprintf( painCave.errMsg, "%s was not found in the defined list\n",
232             defined );
# Line 259 | Line 259 | void insert_define( char* defined, char* definition ){
259    element = (struct defined_element* )
260      malloc( sizeof( struct defined_element ) );
261  
262 <  // fill the element
262 >  /* fill the element*/
263    
264    strcpy( element->defined, defined );
265    strcpy( element->definition, definition );
266  
267 <  // add the element to the table
267 >  /* add the element to the table*/
268  
269    element->next = defined_list[key];
270    defined_list[key] = element;
# Line 276 | Line 276 | void add_res_element( char* text, int the_token ){
276  
277   void add_res_element( char* text, int the_token ){
278    
279 <  int key; // the calculated hash key;
280 <  struct res_element* element; // the element being added
279 >  int key; /* the calculated hash key;*/
280 >  struct res_element* element; /* the element being added*/
281  
282    key = hash( text );
283    element = (struct res_element *) malloc( sizeof( struct res_element ) );
284    
285 <  // fill the element
285 >  /* fill the element*/
286  
287    strcpy( element->word, text );
288    element->token = the_token;
289  
290 <  // add the element to the table
290 >  /* add the element to the table*/
291  
292    element->next = reserved[key];
293    reserved[key] = element;
# Line 299 | Line 299 | int hash ( char* text ){
299  
300   int hash ( char* text ){
301  
302 <  register unsigned short int i = 0; // loop counter
303 <  int key = 0; // the hash key
302 >  register unsigned short int i = 0; /* loop counter*/
303 >  int key = 0; /* the hash key*/
304  
305    while( text[i] != '\0' ){
306  
# Line 311 | Line 311 | int hash ( char* text ){
311    
312    if( key < 0 ){
313  
314 <    // if the key is less than zero, we've had an overflow error
314 >    /* if the key is less than zero, we've had an overflow error*/
315  
316      sprintf( painCave.errMsg,
317               "Meta-data parse error: There has been an overflow error in the hash key.");
# Line 373 | Line 373 | void kill_lists( ){
373    reserved = NULL;
374    defined_list = NULL;
375  
376 <  is_initialized = 0; // initialization is now false
376 >  is_initialized = 0; /* initialization is now false*/
377   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines