#include "parser.h"
+static int ltt_isalpha(char c)
+{
+ int i,j;
+ if(c == '_')return 1;
+ i = c - 'a';
+ j = c - 'A';
+ if((i>=0 && i<26) || (j>=0 && j<26)) return 1;
+ return 0;
+}
+
+static int ltt_isalnum(char c)
+{
+ return (ltt_isalpha(c) || isdigit(c));
+}
+
/*****************************************************************************
*Function name
* getSize : translate from string to integer
printf("Error in file %s, line %d: %s\n", in->name, in->lineno, msg);
else
printf("%s\n",msg);
- exit(1);
}
/*****************************************************************************
if(pos == BUFFER_SIZE) in->error(in, "number token too large");
in->type = NUMBER;
}
- else if(isalpha(car)) {
+ else if(ltt_isalpha(car)) {
in->buffer[0] = car;
pos = 1;
while((car = getc(fp)) != EOF && pos < BUFFER_SIZE) {
- if(!isalnum(car)) {
+ if(!ltt_isalnum(car)) {
ungetc(car,fp);
break;
}
/*****************************************************************************
*Function name
* checkNamedTypesImplemented : check if all named types have definition
+ * returns -1 on error, 0 if ok
****************************************************************************/
-void checkNamedTypesImplemented(table * named_types)
+int checkNamedTypesImplemented(table * named_types)
{
type_descriptor *t;
int pos;
for(pos = 0 ; pos < named_types->values.position; pos++) {
t = (type_descriptor *) named_types->values.array[pos];
if(t->type == NONE){
- sprintf(str,"named type '%s' has no definition",(char*)named_types->keys.array[pos]);
- error_callback(NULL,str);
+ sprintf(str,"named type '%s' has no definition",
+ (char*)named_types->keys.array[pos]);
+ error_callback(NULL,str);
+ return -1;
}
}
+ return 0;
}
* checksum : checksum for the facility
****************************************************************************/
-void generateChecksum( char* facName, unsigned long * checksum, sequence * events)
+int generateChecksum(char* facName, unsigned long * checksum, sequence * events)
{
unsigned long crc ;
int pos;
if(ev->type->type != STRUCT){
sprintf(str,"event '%s' has a type other than STRUCT",ev->name);
error_callback(NULL, str);
+ return -1;
}
crc = getTypeChecksum(crc, ev->type);
}
*checksum = crc;
+ return 0;
}
/*****************************************************************************
void parseTypeDefinition(parse_file *in, sequence * unnamed_types, table * named_types);
type_descriptor *parseType(parse_file *in, type_descriptor *t, sequence * unnamed_types, table * named_types);
void parseFields(parse_file *in, type_descriptor *t, sequence * unnamed_types, table * named_types);
-void checkNamedTypesImplemented(table * namedTypes);
+int checkNamedTypesImplemented(table * namedTypes);
type_descriptor * find_named_type(char *name, table * named_types);
-void generateChecksum(char * facName, unsigned long * checksum, sequence * events);
+int generateChecksum(char * facName, unsigned long * checksum, sequence * events);
/* get attributes */