Hi all,
I'm writing a language file parsing utility and have a hit a brick wall using the new operator.
I have a struct for keywords as follows :
The keywordbin belongs in turn to a language struct as follows :
Both of these structs are protected within the DATACOLLECTOR class.
I have a top level parse function that handles collating the info from an unknown number of keyword groups in a file.
The first keyword group is parsed correctly but, running through my while loop a second time, the program UAE's when I try to create the keywordbin.
KEYWORDBIN *kwd = new KEYWORDBIN;
I'm totally bamboozled as to why this is happening - any help or pointers would be most welcome. Does this sort of problem mean I've dropped the ball elsewhere (any ideas what I should be looking for?) or am I missing something...
Thx.
I'm writing a language file parsing utility and have a hit a brick wall using the new operator.
I have a struct for keywords as follows :
Code:
struct KEYWORDBIN
{ INT keywordindex;
CHAR name[MAX_STR_SIZE];
BOOL iscasesensitive;
COLOUR colour;
CHAR keywords[][MAX_KWD_LENGTH];
};
Code:
// Top Level Language Information container :
struct LANGUAGE
{ LANGUAGEHEADER lheader;
KEYWORDBIN keywordinfo[MAX_KEYWORD_TYPES]; };
I have a top level parse function that handles collating the info from an unknown number of keyword groups in a file.
Code:
BOOL DATACOLLECTOR::parselanguagekeywords (LANGUAGE *lng, FILE *fp)
/* This is the engine for parsing a keyword lists for a specific language.12 types of keywords are allowed per language and each is customisable in terms of colour and case sensitivity etc..
*/
{ INT kwdcount = 0;
CHAR *lptr = NULL;
INT kwdnum;
// Verify file pointer location :
fgets(linerecord,MAX_LINE_LENGTH,fp);
while ((lptr = strstr(linerecord,"/K")) != NULL)
{ getint (&(lptr+2),&kwdnum);
if (kwdnum > MAX_KEYWORD_TYPES)
{ // error msg here..
return FALSE;
}
if (kwdnum != kwdcount)
{ //log msg here..
}
// All goes Pete Tong here 2nd time round.
kwdcount++;
KEYWORDBIN *kwd = new KEYWORDBIN;
kwd->keywordindex = kwdnum;
if (!getkeywordheader(kwd,linerecord))
{ //error msg here..
return FALSE;
}
// Parse the keywords themselves for this keyword group :
if (getkeywords(fp,kwd->keywords) == 0)
return FALSE;
// Add the keyword group to the language :
lng->keywordinfo[kwdcount-1] = *kwd;
}
return TRUE;
}
KEYWORDBIN *kwd = new KEYWORDBIN;
I'm totally bamboozled as to why this is happening - any help or pointers would be most welcome. Does this sort of problem mean I've dropped the ball elsewhere (any ideas what I should be looking for?) or am I missing something...
Thx.