mirror of
https://github.com/UberGames/rpgxEF.git
synced 2024-11-10 15:21:34 +00:00
Modified lexer to automatically skip LMT_IGNORE
This commit is contained in:
parent
fc9bfc84a8
commit
5c3773a902
3 changed files with 34 additions and 4 deletions
|
@ -417,10 +417,21 @@ void bgLex_destroy(bgLex* lex) {
|
|||
}
|
||||
|
||||
int bgLex_lex(bgLex* lex) {
|
||||
int res;
|
||||
|
||||
if(lex->morphem->data.str != NULL) {
|
||||
free(lex->morphem->data.str);
|
||||
}
|
||||
return yylex(lex->lex);
|
||||
|
||||
/* skip LMT_IGNORE */
|
||||
while(1) {
|
||||
res = yylex(lex->lex);
|
||||
if(lex->morphem->type != LMT_IGNORE) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
bgLexSymbol bgLex_textToSymbol(char* text) {
|
||||
|
|
|
@ -2559,10 +2559,21 @@ void bgLex_destroy(bgLex* lex) {
|
|||
}
|
||||
|
||||
int bgLex_lex(bgLex* lex) {
|
||||
int res;
|
||||
|
||||
if(lex->morphem->data.str != NULL) {
|
||||
free(lex->morphem->data.str);
|
||||
}
|
||||
return yylex(lex->lex);
|
||||
|
||||
/* skip LMT_IGNORE */
|
||||
while(1) {
|
||||
res = yylex(lex->lex);
|
||||
if(lex->morphem->type != LMT_IGNORE) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
bgLexSymbol bgLex_textToSymbol(char* text) {
|
||||
|
|
|
@ -935,9 +935,15 @@ static void G_LoadTimedMessages(void) {
|
|||
}
|
||||
|
||||
trap_FS_Read(buffer, len, f);
|
||||
trap_FS_FCloseFile(f);
|
||||
|
||||
lexer = bgLex_create(buffer);
|
||||
|
||||
if(lexer == NULL) {
|
||||
G_Printf(S_COLOR_RED "ERROR: Could not create new bgLex to lex timed messages.\n");
|
||||
free(buffer);
|
||||
}
|
||||
|
||||
while(bgLex_lex(lexer)) {
|
||||
if(lexer->morphem->type == LMT_IGNORE) {
|
||||
continue;
|
||||
|
@ -949,9 +955,9 @@ static void G_LoadTimedMessages(void) {
|
|||
G_Printf(S_COLOR_YELLOW "WARNING: Unexpected token in timedmessages.cfg:%d:%d!\n", lexer->morphem->line, lexer->morphem->column);
|
||||
}
|
||||
}
|
||||
G_Printf("Loaded %d timed messages.\n", level.timedMessages->length);
|
||||
|
||||
bgLex_destroy(lexer);
|
||||
trap_FS_FCloseFile(f);
|
||||
free(buffer);
|
||||
}
|
||||
|
||||
|
@ -1095,9 +1101,11 @@ static void G_LoadServerChangeFile(void) {
|
|||
|
||||
file_len = trap_FS_FOpenFile(fileRoute, &f, FS_READ);
|
||||
|
||||
if(!file_len)
|
||||
if(!file_len) {
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO dynamic buffer size
|
||||
buffer = (char *)malloc(32000 * sizeof(char));
|
||||
if(!buffer) {
|
||||
G_Printf(S_COLOR_RED "ERROR: Was unable to allocate %i bytes.\n", 32000 * sizeof(char) );
|
||||
|
|
Loading…
Reference in a new issue